Skip to content
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

Wrong phones opening when using a combined bat file #5301

Open
gdaviez opened this issue Sep 17, 2024 · 17 comments
Open

Wrong phones opening when using a combined bat file #5301

gdaviez opened this issue Sep 17, 2024 · 17 comments

Comments

@gdaviez
Copy link

gdaviez commented Sep 17, 2024

When using a bat file to open multiple phones with a "timeout 5" in-between each phone, sometimes it will open the wrong serial number with a different title, when i close that phone, others start to disconnect, it can normally be fixed with a PC restart or replugging in all the USBs but its a lot of work and frustrating when it still doesnt work, anybody know how to fix that?

@rom1v
Copy link
Collaborator

rom1v commented Sep 17, 2024

Please show your bat file.

@gdaviez
Copy link
Author

gdaviez commented Sep 17, 2024

start scrcpy-noconsole.vbs -s 232db144d10c7ece -m620 --stay-awake --turn-screen-off --prefer-text --window-x 0 --window-y 30 --window-title "Ang_w_6" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce081828d49e933b02 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 305 --window-y 30 --window-title "JuliaN_93" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s 24103874830c7ece -m620 --stay-awake --turn-screen-off --prefer-text --window-x 610 --window-y 30 --window-title "StaceyS1" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s 988a16435555534d3730 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 915 --window-y 30 --window-title "JanG_07" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce0718275d934b3701 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 1220 --window-y 30 --window-title "Adrian_9" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s 2258ccac3b057ece -m620 --stay-awake --turn-screen-off --prefer-text --window-x 1525 --window-y 30 --window-title "ShellP_8" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce07182764df573b05 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 1830 --window-y 30 --window-title "Suza_31" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce11182be4e9b53c03 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 0 --window-y 680 --window-title "NicF_9" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s 2a6dcdbcc70b7ece -m620 --stay-awake --turn-screen-off --prefer-text --window-x 305 --window-y 680 --window-title "Bronagh_22" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s 988a9743353350333930 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 610 --window-y 680 --window-title "KellyA_0" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce04171420dfbc2f0c -m620 --stay-awake --turn-screen-off --prefer-text --window-x 915 --window-y 680 --window-title "JacqJ_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s 4636454342553398 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 1220 --window-y 680 --window-title "Rose_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s 988837473434543844 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 1525 --window-y 680 --window-title "Michelle_" --power-off-on-close

timewout 5

start scrcpy-noconsole.vbs -s ce0317133048bd0f04 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 1830 --window-y 680 --window-title "Lynne_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce06171644b87cfd0d7e -m620 --stay-awake --turn-screen-off --prefer-text --window-x 0 --window-y 1330 --window-title "GemmaG_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce081828d954233e02 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 305 --window-y 1330 --window-title "NicB_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s 988a1c45445734374a -m620 --stay-awake --turn-screen-off --prefer-text --window-x 610 --window-y 1330 --window-title "Beat" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce031713f10b98e30d -m620 --stay-awake --turn-screen-off --prefer-text --window-x 915 --window-y 1330 --window-title "MattS_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s 98899a3443334d4548 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 1220 --window-y 1330 --window-title "Cla" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce05171578c2442c02 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 1525 --window-y 1330 --window-title "LeighJ_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s 9889db454641304943 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 1830 --window-y 1330 --window-title "LauraG_" --power-off-on-close

timeoiut 5

start scrcpy-noconsole.vbs -s ce0718272d7a152904 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 0 --window-y 1980 --window-title "EmmaS_5" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce031713e38008000d -m620 --stay-awake --turn-screen-off --prefer-text --window-x 305 --window-y 1980 --window-title "JulieH_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce0617164832d0d20d -m620 --stay-awake --turn-screen-off --prefer-text --window-x 610 --window-y 1980 --window-title "Katie_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce07182772afde2805 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 915 --window-y 1980 --window-title "Shannon_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce031713453734d00c -m620 --stay-awake --turn-screen-off --prefer-text --window-x 1220 --window-y 1980 --window-title "Graeme_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce031713bd8de10f05 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 1525 --window-y 1980 --window-title "KellyP_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s 29d948b4f10b7ece -m620 --stay-awake --turn-screen-off --prefer-text --window-x 1830 --window-y 1980 --window-title "JodieT_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce0317133209673703 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 0 --window-y 2630 --window-title "Tracey H_" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s 244bd2492b1c7ece -m620 --stay-awake --turn-screen-off --prefer-text --window-x 305 --window-y 2630 --window-title "Rachea" --power-off-on-close

timeout 5

start scrcpy-noconsole.vbs -s ce011821c4d7b71b02 -m620 --stay-awake --turn-screen-off --prefer-text --window-x 610 --window-y 2630 --window-title "JodyC_" --power-off-on-close

@rom1v
Copy link
Collaborator

rom1v commented Sep 17, 2024

sometimes it will open the wrong serial number with a different title

That is very surprising. Since all adb commands executed by scrcpy uses -s serial, such confusion looks impossible to me at the scrcpy level.

I've heard there can be usb issues when there are too many USB devices (especially on Windows), but that just means that a limited number of USB devices could be connected at once, it should not cause any confusion between devices.

when i close that phone, others start to disconnect

When you close 1 phone, several others get disconnected?

@gdaviez
Copy link
Author

gdaviez commented Sep 17, 2024

Its definitely something to do with too many phones connected, iv got around 40 connected at the minute, but majority of the time it works well, just now and then it starts playing up and can be quite annoying to fix.
I do have a USB card installed which massively helped, might just need another one so each port isn't under so much stress?

As for the phone disconnecting, so when it loads up in the wrong order it will be one hub (i have 10 phones connected per hub) so say phone 1 loads, the text box will all be correct, but it will be matched with the wrong serial, so its basically a different phone in that spot, then when i X that phone, the others connected to that HUB will start to disconnect

@rom1v
Copy link
Collaborator

rom1v commented Sep 17, 2024

Try to assign a different port to each device, because by default they all use the same (27183 by default, and increments until 27199 if it is already used):

scrcpy -p30001 …  # 1st device
scrcpy -p30002 …  # 2nd device

I thought that in any case it was not possible to confuse devices when they connect simultaneously, but if assigning a different port to each device works, then I might be wrong.

@gdaviez
Copy link
Author

gdaviez commented Sep 17, 2024

im a bit of a tech idiot so im a little confused by this, im guessing the ports aren't physical ports? its all working perfectly at the minute but ill test with the different ports when i get back to pc and see what happens, will report back

@rom1v
Copy link
Collaborator

rom1v commented Sep 17, 2024

im guessing the ports aren't physical ports?

No, they're TCP ports (the device and the client communicate using TCP sockets).

and see what happens, will report back

👍 thank you.

@gdaviez
Copy link
Author

gdaviez commented Sep 22, 2024

im guessing the ports aren't physical ports?

No, they're TCP ports (the device and the client communicate using TCP sockets).

and see what happens, will report back

👍 thank you.

Sorry it took so long to reply, this might be premature but i was having issues just now with it loading all the wrong phones, assigned ports and its all fixed!

You are a legend thank you so much

@rom1v
Copy link
Collaborator

rom1v commented Sep 22, 2024

I thought that in any case it was not possible to confuse devices when they connect simultaneously, but if assigning a different port to each device works, then I might be wrong.

Do any device use adb forward instead of adb reverse? (use the .bat instead of the .vbs to get logs)

adb -s DEVICE1 forward tcp:1234 localabstract:abc
adb -s DEVICE2 forward tcp:1234 localabstract:abc

Both command exit with success, but the second one silently "overwrites" the config set by the first one:

$ adb forward --list
DEVICE2 tcp:1234 localabstract:abc

So when the client of DEVICE1 connects, it can actually connect to DEVICE2. (I would have expected the second command to fail instead.)

I can't explain the same behavior with the default adb reverse though.

@gdaviez
Copy link
Author

gdaviez commented Sep 26, 2024

I thought that in any case it was not possible to confuse devices when they connect simultaneously, but if assigning a different port to each device works, then I might be wrong.

Do any device use adb forward instead of adb reverse? (use the .bat instead of the .vbs to get logs)

adb -s DEVICE1 forward tcp:1234 localabstract:abc
adb -s DEVICE2 forward tcp:1234 localabstract:abc

Both command exit with success, but the second one silently "overwrites" the config set by the first one:

$ adb forward --list
DEVICE2 tcp:1234 localabstract:abc

So when the client of DEVICE1 connects, it can actually connect to DEVICE2. (I would have expected the second command to fail instead.)

I can't explain the same behavior with the default adb reverse though.

Not a clue how to test this, just put all the decide IDs in the code you posted and run it as a bat?

I do have one new problem since using ports, one of the phones seems to be playing sound through my computer and seems as tho its using my processing power for the phone, PC lags a little bit while doing heavy things on the phone, but does that with no others, plus all the others only play sound through the phones themselves, not the PC

@rom1v
Copy link
Collaborator

rom1v commented Sep 26, 2024

one of the phones seems to be playing sound through my computer

All devices with Android >= 12 are expected to forward audio by default. If this is the only one, check the error message in the others.

If you want to disable audio forwarding, use --no-audio.

and seems as tho its using my processing power for the phone, PC lags a little bit while doing heavy things on the phone, but does that with no others

PC needs to decode the frames, so if the phone has a higher resolution than the others, it may require more power from the computer (especially when there is movement because there is more data). Try to limit the resolution and/or bit rate. Or maybe it's the audio processing. Is it better with --no-audio?

@gdaviez
Copy link
Author

gdaviez commented Sep 28, 2024

one of the phones seems to be playing sound through my computer

All devices with Android >= 12 are expected to forward audio by default. If this is the only one, check the error message in the others.

If you want to disable audio forwarding, use --no-audio.

and seems as tho its using my processing power for the phone, PC lags a little bit while doing heavy things on the phone, but does that with no others

PC needs to decode the frames, so if the phone has a higher resolution than the others, it may require more power from the computer (especially when there is movement because there is more data). Try to limit the resolution and/or bit rate. Or maybe it's the audio processing. Is it better with --no-audio?

The no-audio thing didnt help, it stopped the sound but its still really laggy, i reduced the resolution and will check the bitrate today, ill also no no-audio on all of the phones and see if that helps too

@gdaviez
Copy link
Author

gdaviez commented Sep 28, 2024

one of the phones seems to be playing sound through my computer

All devices with Android >= 12 are expected to forward audio by default. If this is the only one, check the error message in the others.

If you want to disable audio forwarding, use --no-audio.

and seems as tho its using my processing power for the phone, PC lags a little bit while doing heavy things on the phone, but does that with no others

PC needs to decode the frames, so if the phone has a higher resolution than the others, it may require more power from the computer (especially when there is movement because there is more data). Try to limit the resolution and/or bit rate. Or maybe it's the audio processing. Is it better with --no-audio?

So after checking task manager my CPU is running at 100% while im running slots on the phones, 50 connected right now, is there a way to reduce the strain or should i just upgrade my cpu? currently using 11th Gen Intel(R) Core(TM) i9-11900K @ 3.50GHz 3.50 GHz

@rom1v
Copy link
Collaborator

rom1v commented Sep 28, 2024

So after checking task manager my CPU is running at 100% while im running slots on the phones, 50 connected right now

If you decode 50 video streams, it is not surprising that it takes a lot of CPU.

@gdaviez
Copy link
Author

gdaviez commented Sep 28, 2024

So after checking task manager my CPU is running at 100% while im running slots on the phones, 50 connected right now

If you decode 50 video streams, it is not surprising that it takes a lot of CPU.

yea was hoping my processor would be strong enough tbh but i guess not, iv lowered the bit rates to 4000k now so hopefully that helps, if not ill need to upgrade my system, cheers for all your help

@rom1v
Copy link
Collaborator

rom1v commented Sep 28, 2024

You could encode with a lower complexity profile/level (so that it's "simpler" to decode). See the highlights at the end of https://github.com/Genymobile/scrcpy/releases/tag/v1.14 (the option is now named --video-codec-options=).

@rom1v
Copy link
Collaborator

rom1v commented Sep 28, 2024

You can also limit frame rate (--max-fps=15).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants