-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto reconnect mode #721
Comments
Ref: #685 |
@rom1v If I make a patch to enable auto-reconnect, would you accept this functionality? |
In theory, I'm not against. In practice, there are a lot of questions to be discussed. For example (non exhaustive):
Just for info, I developed a separate tool to start scrcpy (or anything else) whenever a new device is connected: https://github.com/rom1v/autoadb |
Your other project would solve my problem, but I would like to contribute to the core program and make auto-reconnect self-contained inside it. This will make this functionality easily available with just a command-line switch. I propose that the auto-reconnect is enabled only for a short duration in order to "buffer" for intermittent disconnects. Or explicit short ones initiated by the user when the connection has stalled. Like 10 seconds by default, with an option to extend it. Something like: I'm having short disconnections from time to time on my machine for an unknown reason. Probably other people are having this problem as well. Using USB2 instead of USB3 is much better, but they still happen like 5-6 times a day. I'm using good cables and rear USB ports. I lack context in the program use cases. If a device is already connected and a new device is connected, nothing changes from current behavior (whatever it is). However, if the device was just disconnected, we open a "reconnection window" of up to X seconds. If no serial was given before, accept any device that makes it into this window. If a serial was given, accept only a device with this serial. I am not aware of the recording functionality. I'm open to suggestions here. So how does this sound? |
OK, I'm ok with that. 👍 There is a preliminary change to make: currently, scrcpy handles the connection in the main thread, then starts the UI event loop once connected. To be able to reconnect, we need to handle the connection in a separate thread, and send an event to the event loop when the device is connected. I could do that change (it's a refactor that could be done independently of the re connection feature) after the v1.13 release (btw, help wanted: #1307 😉). |
Very nice. When I have some time these days, I'll look into the application's code to understand what needs to be done and I'll comment on what I'm planning to do here. :) |
would really enjoy to have some auto restart function. any update on this? |
Not yet. I have it in mind, but I have more refactors to do beforehand. |
Oh, I completely forgot this one. I switched my project and I didn't need this functionality, so I forgot. My apologies. @rom1v can I take a look and try to implement it or you need to finish the refactoring before that? |
I have to move server to a separate thread first :) |
Sure. Please let me know when this is finished and I'll try my best to implement the feature from this issue. :) |
SOLUTION..!! I found a way to reconnect scrcpy with a simple workaround until the dev implements the auto-reconnect feature.. This can be performed by using a loop in a batch file..
With this batch file, the reconnect can automatically happen as long as you have an adb connection ready even if there are hiccups in the stability of the connection.. Although it may not resume/reconnect with the same thread, it will start a new instance as soon as the previous instance closes.. How does it work? => This loop is basically an infinite loop that runs the scrcpy command again each time the command execution is completed, which means the command execution is completed when scrcpy exits for any reason.. Note:
|
I would add a "timeout /t 1" just after :start to wait for a second when there's no connection.
|
Hello friends, Here is my pure batch solution for this issue
This will autorestart forever |
It would be nice if the app would wait for the same device to reconnect to it automatically (in case of a restart etc)
The text was updated successfully, but these errors were encountered: