scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Support for automatically resizing between multiple displays

Open LuminarySage opened this issue 2 years ago • 22 comments

Environment

  • OS: Windows 11
  • scrcpy version: v2.1
  • installation method: Windows release
  • device model: Google Pixel Fold
  • Android version: 13

Describe the bug Right now if I switch between displays on something like a foldable phone, the screen capture won't scale to the correct aspect ratio at all

Transitioning from the outer display to the inner display scrcpy_47Mmbwv6nN

Transitioning from the inner display to the outer display ezgif com-optimize

LuminarySage avatar Jul 09 '23 05:07 LuminarySage

@AdoPi (as the author of #3979): could you reproduce?

rom1v avatar Jul 09 '23 09:07 rom1v

Sorry I can't reproduce. It works with the latest version available on master, on a Samsung Z Fold 4. Note that I'm testing on Linux, Currently I don't have Windows.

AdoPi avatar Jul 09 '23 11:07 AdoPi

@Jnss98b Could you please add this little patch to help debugging this issue?

diff --git a/server/src/main/java/com/genymobile/scrcpy/Device.java b/server/src/main/java/com/genymobile/scrcpy/Device.java
index f817a3ce..e9da6742 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Device.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Device.java
@@ -103,6 +103,7 @@ public final class Device {
             ServiceManager.getWindowManager().registerDisplayFoldListener(new IDisplayFoldListener.Stub() {
                 @Override
                 public void onDisplayFoldChanged(int displayId, boolean folded) {
+                    Ln.i("==== onDisplayFoldChanged(" + displayId + ", " + folded + ")");
                     synchronized (Device.this) {
                         DisplayInfo displayInfo = ServiceManager.getDisplayManager().getDisplayInfo(displayId);
                         if (displayInfo == null) {

Thanks!

AdoPi avatar Jul 09 '23 12:07 AdoPi

Will test it tomorrow when I get back. Currently out of town at the moment

LuminarySage avatar Jul 09 '23 13:07 LuminarySage

@AdoPi Could you do me a favor and build a 64-bit windows release with the patch please? I'm having trouble building from source with msys2

LuminarySage avatar Jul 10 '23 21:07 LuminarySage

@Jnss98b:

  • scrcpy-server SHA-256: 783d4b65f31eb3b7162c97de6d7b1aa11b154140540b5bf2b0aadf8b210e9d05

(to be replaced in your v2.1 release)

rom1v avatar Jul 11 '23 10:07 rom1v

Here's the log after I start scrcpy with the phone folded, unfolded it, and then folded it again

scrcpy 2.1 <https://github.com/Genymobile/scrcpy>
C:\Users\Anh Nguyen\Downloads\scrcpy-win64-v2.1\scrcpy-ser...file pushed, 0 skipped. 101.9 MB/s (91973 bytes in 0.001s)
[server] INFO: Device: [Google] google Pixel Fold (Android 13)
[server] INFO: ==== onDisplayFoldChanged(0, true)
INFO: Renderer: direct3d
INFO: Texture: 1080x2088
[server] INFO: ==== onDisplayFoldChanged(0, false)
[server] INFO: ==== onDisplayFoldChanged(0, true)
INFO: Texture: 2208x1840
WARN: Killing the server...

LuminarySage avatar Jul 11 '23 21:07 LuminarySage

Any update on this? @AdoPi

LuminarySage avatar Aug 11 '23 20:08 LuminarySage

Does your window size change when you fold your phone or not at all?

If possible for you, could you please try on Linux or Mac? I suspect it is an issue with the window and not with events sent from your device.

AdoPi avatar Aug 15 '23 08:08 AdoPi

Does your window size change when you fold your phone or not at all?

Yeah it doesn't at all. Both when folding and unfolding

If possible for you, could you please try on Linux or Mac? I suspect it is an issue with the window and not with events sent from your device.

I could try it on linux. Does it matter if I test it on a VM?

LuminarySage avatar Aug 15 '23 15:08 LuminarySage

I think you can use a VM yes!

AdoPi avatar Aug 16 '23 15:08 AdoPi

Set up a ubuntu vm just to find out afterward that the latest packaged version for ubuntu is 1.25 lol fml

LuminarySage avatar Aug 16 '23 18:08 LuminarySage

Just tested with scrcpy 2.1.1 on ubuntu 22.0.4.3 lts and I can still reproduce the issue

LuminarySage avatar Aug 16 '23 18:08 LuminarySage

Looks like the window does resize automatically...but not in an intended way https://github.com/Genymobile/scrcpy/assets/24306400/36c7a1e3-185d-4991-83b2-9c6d2ba7243c

LuminarySage avatar Aug 16 '23 19:08 LuminarySage

Thank you for your video! So it seems like your device sends the good fold event. @rom1v any idea of what's going on?

AdoPi avatar Aug 16 '23 19:08 AdoPi

I can also reproduce the exact same behavior on scrcpy 2.1.1 on windows 11 22h2 too (on 2.1 the scrcpy window didn't resize automatically)

https://github.com/Genymobile/scrcpy/assets/24306400/6ced4210-666e-4ea0-af38-11d86737712b

LuminarySage avatar Aug 16 '23 19:08 LuminarySage

I guess rotating your screen doesnt work too?

AdoPi avatar Aug 16 '23 21:08 AdoPi

Actually, that works well haha. I've never had any issue with that, even with previous devices

LuminarySage avatar Aug 16 '23 21:08 LuminarySage

Also, the demos I did today were on a different pc from the one I first discovered the issue on so I suppose it's reproducible on multiple hosts?

LuminarySage avatar Aug 16 '23 21:08 LuminarySage

Changing display will cause the issue again tho

Outer display

https://github.com/Genymobile/scrcpy/assets/24306400/c1194a09-f525-4f24-a2f3-f91089a00163

Inner display

https://github.com/Genymobile/scrcpy/assets/24306400/3c000bf1-1e88-4acd-a37c-591fc46ab8fd

LuminarySage avatar Aug 16 '23 21:08 LuminarySage

Not sure if anything changed but on v2.1.1 it seems to handle changing between displays a little bit better but still isn't really ideal. The inner display size will always be limited by the width of the outer display regardless of what display is in use when scrcpy was launched with folding events. The one time the inner display will be full size is if scrcpy was started with the inner display in use and the screen wasn't folded at all.

Starting scrcpy on the cover display:

https://github.com/Genymobile/scrcpy/assets/24306400/bd07f816-01a0-44d3-a999-be4dfa3a441f

Starting scrcpy from the inner display:

https://github.com/Genymobile/scrcpy/assets/24306400/7f37a763-e732-48b9-acea-4c28f29d67ae

LuminarySage avatar Nov 01 '23 01:11 LuminarySage

Any movement on this by chance? I can also confirm the same exact issue with a Pixel Fold on macOS.

j0hnm4r5 avatar May 17 '24 00:05 j0hnm4r5