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

Support for automatically resizing between multiple displays #4152

Closed
LuminarySage opened this issue Jul 9, 2023 · 22 comments
Closed

Support for automatically resizing between multiple displays #4152

LuminarySage opened this issue Jul 9, 2023 · 22 comments

Comments

@LuminarySage
Copy link

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

@rom1v
Copy link
Collaborator

rom1v commented Jul 9, 2023

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

@AdoPi
Copy link
Contributor

AdoPi commented Jul 9, 2023

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
Copy link
Contributor

AdoPi commented Jul 9, 2023

@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!

@LuminarySage
Copy link
Author

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

@LuminarySage
Copy link
Author

@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

@rom1v
Copy link
Collaborator

rom1v commented Jul 11, 2023

@Jnss98b:

  • scrcpy-server SHA-256: 783d4b65f31eb3b7162c97de6d7b1aa11b154140540b5bf2b0aadf8b210e9d05

(to be replaced in your v2.1 release)

@LuminarySage
Copy link
Author

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
Copy link
Author

Any update on this? @AdoPi

@AdoPi
Copy link
Contributor

AdoPi commented Aug 15, 2023

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.

@LuminarySage
Copy link
Author

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?

@AdoPi
Copy link
Contributor

AdoPi commented Aug 16, 2023

I think you can use a VM yes!

@LuminarySage
Copy link
Author

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

@LuminarySage
Copy link
Author

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

@LuminarySage
Copy link
Author

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

@AdoPi
Copy link
Contributor

AdoPi commented Aug 16, 2023

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

@LuminarySage
Copy link
Author

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)

MaeTwZjVpX.mp4

@AdoPi
Copy link
Contributor

AdoPi commented Aug 16, 2023

I guess rotating your screen doesnt work too?

@LuminarySage
Copy link
Author

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

@LuminarySage
Copy link
Author

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
Copy link
Author

LuminarySage commented Aug 16, 2023

Changing display will cause the issue again tho

Outer display

Xg95ZTk5xR.mp4

Inner display

edited.mp4

@LuminarySage
Copy link
Author

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:

Cover.mp4

Starting scrcpy from the inner display:

Inner.mp4

@j0hnm4r5
Copy link

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

rom1v added a commit that referenced this issue Oct 28, 2024
Replace RotationWatcher and DisplayFoldListener by a single
DisplayListener, which is notified whenever the display size or dpi
changes.

Still use the old mechanism specifically for Android 14, where
DisplayListener may be broken (it is fixed in recent Android 14
upgrades), until we receive the first DisplayListener event (which
proves that it works).

Fixes #161 <#161>
Fixes #1918 <#1918>
Fixes #4152 <#4152>
Refs #4469 <#4469>

Co-authored-by: Simon Chan <[email protected]>
rom1v added a commit that referenced this issue Oct 28, 2024
Replace RotationWatcher and DisplayFoldListener by a single
DisplayListener, which is notified whenever the display size or dpi
changes.

Still use the old mechanism specifically for Android 14, where
DisplayListener may be broken (it is fixed in recent Android 14
upgrades), until we receive the first DisplayListener event (which
proves that it works).

Fixes #161 <#161>
Fixes #1918 <#1918>
Fixes #4152 <#4152>
Fixes #5362 comment <#5362 (comment)>
Refs #4469 <#4469>

Co-authored-by: Simon Chan <[email protected]>
rom1v added a commit that referenced this issue Oct 30, 2024
Replace RotationWatcher and DisplayFoldListener by a single
DisplayListener, which is notified whenever the display size or dpi
changes.

However, the DisplayListener mechanism is broken in the first versions
of Android 14 (it is fixed in android-14.0.0_r29 by commit [1]), so
continue to use the old mechanism specifically for Android 14 (where
DisplayListener may be broken), until we receive the first
"display changed" event (which proves that it works).

[1]: <https://android.googlesource.com/platform/frameworks/base.git/+/5653c6b5875df599307c3e6bfae32fb2fc17ca1f%5E%21/>

Fixes #161 <#161>
Fixes #1918 <#1918>
Fixes #4152 <#4152>
Fixes #5362 comment <#5362 (comment)>
Refs #4469 <#4469>
PR #5415 <#5415>

Co-authored-by: Simon Chan <[email protected]>
@rom1v rom1v closed this as completed in e26bdb0 Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants