Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
109.23k stars 10.5k forks source link

Cancelling recording disables screen off for all SCRCPY instances #2305

Open qbalsdon opened 3 years ago

qbalsdon commented 3 years ago

Environment

Describe the bug In one terminal Window, run

scrcpy -Sw

In a second terminal window, run

scrcpy -r "recording.mp4" & ID=$! && sleep 2 && kill $ID #starts recording, waits 2 seconds and kills the recording process

Expected behaviour:

Actual behaviour:

Terminal 1 output:

2021-05-08 18:07:26.681 scrcpy[34989:350937] INFO: scrcpy 1.17 https://github.com/Genymobile/scrcpy
/usr/local/Cellar/scrcpy/1.17_1/share/...ped. 83.8 MB/s (34930 bytes in 0.000s)
[server] INFO: Device: Google Pixel 5 (Android 11)
2021-05-08 18:07:27.177 scrcpy[34989:350937] INFO: Renderer: metal
2021-05-08 18:07:27.182 scrcpy[34989:350937] INFO: Initial texture: 1080x2336
[server] INFO: Device screen turned off

Terminal 2 output:

[1] 34994
2021-05-08 18:07:31.186 scrcpy[34994:351141] INFO: scrcpy 1.17 https://github.com/Genymobile/scrcpy
/usr/local/Cellar/scrcpy/1.17_1/share/...ped. 73.0 MB/s (34930 bytes in 0.000s)
bind: Address already in use
2021-05-08 18:07:31.226 scrcpy[34994:351141] WARN: Could not listen on port 27183, retrying on 27184
[server] INFO: Device: Google Pixel 5 (Android 11)
2021-05-08 18:07:31.652 scrcpy[34994:351275] INFO: Recording started to mp4 file: recording.mp4
2021-05-08 18:07:31.703 scrcpy[34994:351141] INFO: Renderer: metal
2021-05-08 18:07:31.707 scrcpy[34994:351141] INFO: Initial texture: 1080x2336
... % 2021-05-08 18:07:33.163 scrcpy[34994:351275] INFO: Finishing recording...
2021-05-08 18:07:33.164 scrcpy[34994:351275] INFO: Recording complete to mp4 file: recording.mp4
2021-05-08 18:07:34.164 scrcpy[34994:351141] WARN: Killing the server...

[1] + done scrcpy -r "recording.mp4"

rom1v commented 3 years ago

The power mode (used for "turn screen off") is always restored to normal on exit, because the user may have change its state at any time (using Alt+o and Alt+Shift+o, or by pressing POWER directly on the device).

This cause unexpected behaviors if several instance of scrcpy are started for the same device, but I have no other solution.

This also impacts other features: several settings ("stay awake", "show touches"…) are captured on scrcpy start and restored on scrcpy exit, regardless of any other instance.

qbalsdon commented 3 years ago

Would it be possible to give users the ability to modify a specific instance then? Like a process id in order to interact with it?