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

scrcpy 2.1 uses main display's resolution for higher res secondary displays #4120

Closed
2 tasks done
kattjevfel opened this issue Jun 27, 2023 · 15 comments
Closed
2 tasks done

Comments

@kattjevfel
Copy link

kattjevfel commented Jun 27, 2023

  • I have read the FAQ.
  • I have searched in existing issues.

Environment

  • OS: Arch Linux
  • scrcpy version: 2.1
  • installation method: Arch Linux repositories
  • device model: Oneplus 5T (A5010)
  • Android version: 13

Describe the bug
When using --display for a display with a higher resolution, it is still displayed with the main display's resolution, cutting off parts of the display. Setting the secondary display to have a lower resolution works as intended.

scrcpy 2.0:

katt@main ~ » scrcpy --list-displays
scrcpy 2.0 <https://github.com/Genymobile/scrcpy>
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 589.7 MB/s (52867 bytes in 0.000s)
[server] INFO: List of displays:
    --display=0    (1080x2160)
    --display=4    (1440x2560)
katt@main ~ » scrcpy --display=4
scrcpy 2.0 <https://github.com/Genymobile/scrcpy>
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 605.6 MB/s (52867 bytes in 0.000s)
[server] INFO: Device: OnePlus ONEPLUS A5010 (Android 13)
[server] WARN: Display doesn't have FLAG_SUPPORTS_PROTECTED_BUFFERS flag, mirroring can be restricted
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 23.1.3
INFO: Trilinear filtering enabled
INFO: Initial texture: 1440x2560

scrcpy 2.1:

katt@main ~ » scrcpy --list-displays
scrcpy 2.1 <https://github.com/Genymobile/scrcpy>
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 511.5 MB/s (56955 bytes in 0.000s)
[server] INFO: List of displays:
    --display=0    (1080x2160)
    --display=4    (1440x2560)
katt@main ~ » scrcpy --display=4
scrcpy 2.1 <https://github.com/Genymobile/scrcpy>
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 553.7 MB/s (56955 bytes in 0.000s)
[server] INFO: Device: [OnePlus] OnePlus ONEPLUS A5010 (Android 13)
[server] WARN: Display doesn't have FLAG_SUPPORTS_PROTECTED_BUFFERS flag, mirroring can be restricted
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 23.1.3
INFO: Trilinear filtering enabled
INFO: Texture: 1080x2160
@kattjevfel kattjevfel changed the title scrcpy uses main display's resolution for higher res secondary displays scrcpy 2.1 uses main display's resolution for higher res secondary displays Jun 27, 2023
@rom1v
Copy link
Collaborator

rom1v commented Jun 27, 2023

So it works as expected in scrcpy v2.0, but not v2.1? I'm surprised, because there was no change related to device display between 2.0 and 2.1…

Could you please build the app from sources, and git bisect between tag v2.0 and tag v2.1 to find the offending commit?

@rom1v
Copy link
Collaborator

rom1v commented Jun 27, 2023

I can't reproduce with a simulated secondary display (enabled from developer options):

$ scrcpy --list-displays
scrcpy 2.1 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 178.5 MB/s (56955 bytes in 0.000s)
[server] INFO: List of displays:
    --display=0    (1440x3120)
    --display=1    (3840x2160)
$ scrcpy --display=1
scrcpy 2.1 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 154.6 MB/s (56955 bytes in 0.000s)
[server] INFO: Device: [OnePlus] OnePlus GM1913 (Android 11)
[server] WARN: Display doesn't have FLAG_SUPPORTS_PROTECTED_BUFFERS flag, mirroring can be restricted
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 23.1.2-1
INFO: Trilinear filtering enabled
INFO: Texture: 3840x2160

@kattjevfel
Copy link
Author

I set mine up with adb shell settings put global overlay_display_devices 1440x2560/120 if it matters, also working on setting up for bisecting.

@kattjevfel
Copy link
Author

I built it from source just now and can still reproduce it with git master, building 2.0 from source also fixes it. Will report back once I've bisected it.

@kattjevfel
Copy link
Author

24999d0d32daf50246168dde212f01cf109569f9 is the first bad commit
commit 24999d0d32daf50246168dde212f01cf109569f9
Author: Adonis Najimi <adopi.naj@gmail.com>
Date:   Sun May 7 22:09:21 2023 +0200

    Reset video capture on folding event
    
    Handle folding event the same way as rotation events.
    
    Fixes #3960 <https://github.com/Genymobile/scrcpy/issues/3960>
    PR #3979 <https://github.com/Genymobile/scrcpy/pull/3979>
    
    Signed-off-by: Romain Vimont <rom@rom1v.com>

 .../aidl/android/view/IDisplayFoldListener.aidl    | 26 +++++++++++++++++++
 .../main/java/com/genymobile/scrcpy/Device.java    | 30 ++++++++++++++++++++++
 .../java/com/genymobile/scrcpy/ScreenEncoder.java  |  9 ++++++-
 .../genymobile/scrcpy/wrappers/WindowManager.java  | 10 ++++++++
 4 files changed, 74 insertions(+), 1 deletion(-)
 create mode 100644 server/src/main/aidl/android/view/IDisplayFoldListener.aidl

@rom1v
Copy link
Collaborator

rom1v commented Jun 27, 2023

Yet, your device is not a foldable device, is it?

Is this listener called:

public void onDisplayFoldChanged(int displayId, boolean folded) {

You could add the following diff to check:

diff --git a/server/src/main/java/com/genymobile/scrcpy/Device.java b/server/src/main/java/com/genymobile/scrcpy/Device.java
index f817a3ce2..e9da67421 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) {

@rom1v
Copy link
Collaborator

rom1v commented Jun 27, 2023

cc @AdoPi (as the author of #3979)

@kattjevfel
Copy link
Author

No, my phone is not foldable, in fact I think it might just be old enough to be released before any folding phone was released to the public hehe...

Applying the above patch on top of master outputs this when ran:

katt@main build/scrcpy (master *) » ./run build --display=4
scrcpy 2.1 <https://github.com/Genymobile/scrcpy>
build/server/scrcpy-server: 1 file pushed, 0 skipped. 139.4 MB/s (57043 bytes in 0.000s)
[server] INFO: Device: [OnePlus] OnePlus ONEPLUS A5010 (Android 13)
[server] INFO: ==== onDisplayFoldChanged(0, false)
[server] WARN: Display doesn't have FLAG_SUPPORTS_PROTECTED_BUFFERS flag, mirroring can be restricted
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 23.1.3
INFO: Trilinear filtering enabled
INFO: Texture: 1080x2160

@rom1v
Copy link
Collaborator

rom1v commented Jun 27, 2023

OK, so I guess we should ignore any call to onDisplayFoldChanged() when the displayId is not the current one selected in scrcpy. Do you want to work on the fix?

@kattjevfel
Copy link
Author

I don't know any programming other than bash scripting, so I'll gladly leave it to someone who knows what they're doing.

@rom1v
Copy link
Collaborator

rom1v commented Jun 27, 2023

OK, will do (possibly this week).

Thank you very much for your tests and bisect 😉

rom1v added a commit that referenced this issue Jun 27, 2023
Scrcpy mirrors a specific display id, it must ignore events for other
display ids.

Fixes #4120 <#4120>
@rom1v
Copy link
Collaborator

rom1v commented Jun 27, 2023

Please test branch issue4120.

@kattjevfel
Copy link
Author

Tested the issue4120 branch and can confirm it works as intended for me.

@rom1v
Copy link
Collaborator

rom1v commented Jun 27, 2023

👍 Thank you.

Merged into dev: 808bd14

@rom1v rom1v closed this as completed Jun 27, 2023
@AdoPi
Copy link
Contributor

AdoPi commented Jun 27, 2023

Sorry, I didn't even see my PR was merged in 2.1, Thanks!

Edit: I've tested your fix and it seems to work well :)

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

3 participants