Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
109.08k stars 10.49k forks source link

Doesn't sync correctly after use adb shell wm size. #1918

Open Sodium-Aluminate opened 3 years ago

Sodium-Aluminate commented 3 years ago

Environment

Describe the bug

  1. start scrcpy
  2. run adb shell wm size 1080x2336 or adb shell wm size 1080x1920
  3. scrcpy stdout nothing and the copied screen was not fully displayed.

terminal 1(scrcpy):

sodiumaluminate@AlsPad:~$ scrcpy
INFO: scrcpy 1.14 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server:...shed. 5.7 MB/s (33142 bytes in 0.006s)
[server] INFO: Device: Xiaomi Redmi Note 8 Pro (Android 10)
INFO: OpenGL shaders: ENABLED
INFO: Created renderer: opengl
INFO: Renderer: opengl
INFO: OpenGL version: 4.6.0 NVIDIA 450.80.02
INFO: Trilinear filtering enabled
INFO: Initial texture: 1080x2336
^CWARN: Device disconnected
sodiumaluminate@AlsPad:~$ 

terminal 2(adb wm):

sodiumaluminate@AlsPad:~$ adb shell 
begonia:/ $ wm 
Window manager (window) commands:
  help
      Print this help text.
  size [reset|WxH|WdpxHdp] [-d DISPLAY_ID]
    Return or override display size.
    width and height in pixels unless suffixed with 'dp'.
  density [reset|DENSITY] [-d DISPLAY_ID]
    Return or override display density.
  folded-area [reset|LEFT,TOP,RIGHT,BOTTOM]
    Return or override folded area.
  overscan [reset|LEFT,TOP,RIGHT,BOTTOM] [-d DISPLAY ID]
    Set overscan area for display.
  scaling [off|auto] [-d DISPLAY_ID]
    Set display scaling mode.
  dismiss-keyguard
    Dismiss the keyguard, prompting user for auth if necessary.
  set-user-rotation [free|lock] [-d DISPLAY_ID] [rotation]
    Set user rotation mode and user rotation.
  set-fix-to-user-rotation [-d DISPLAY_ID] [enabled|disabled]
    Enable or disable rotating display for app requested orientation.
255|begonia:/ $ wm size 1080x1920                                                                                                                    
begonia:/ $ wm size reset                                                                                                                            
begonia:/ $ wm size 1080x1920                                                                                                                        
begonia:/ $ wm size reset                                                
begonia:/ $ 
rom1v commented 3 years ago

But if you restart scrcpy, does it have the correct size?

AFAIK there is no way to be notified of window size changes.

Sodium-Aluminate commented 3 years ago

But if you restart scrcpy, does it have the correct size?

yes, it can be corrected by restart scrcpy.

AFAIK there is no way to be notified of window size changes.

but maybe we can check it evey few seconds?

rom1v commented 3 years ago

but maybe we can check it evey few seconds?

Polling is ugly, it's not worth it for a thing which almost never happens in practice.

If there is a proper way to be notified by a callback, I'll add it, but no polling.

Sodium-Aluminate commented 3 years ago

but maybe we can check it evey few seconds?

Polling is ugly, it's not worth it for a thing which almost never happens in practice.

If there is a proper way to be notified by a callback, I'll add it, but no polling.

well… you are right, unless we hook the wm or adb, or create an Android activity in front end, there may be no way to watch it.

rom1v commented 3 years ago

Refs:

EDIT: no, this method is related to picture-in-picture, it is not triggered when the device resolution changes.