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

Added display-id option to mirror displays that are not displayId=0 #1223

Closed
wants to merge 4 commits into from

Conversation

rickychow-google
Copy link

Added display-id option so devices with multiple displays can be mirrored.

rickychow-google and others added 4 commits January 31, 2020 09:08
This allows the correct geometry to be grabbed and the layout stack to be derived from the display info itself.
Replace layout stack option with better device id option.
@rickychow-google
Copy link
Author

Just realised that there's a very similar PR happening that's doing pretty much exactly the same thing as this one. If there's still ongoing work on that PR I'll just shelve this for now.

@rom1v
Copy link
Collaborator

rom1v commented Mar 19, 2020

Just realised that there's a very similar PR happening that's doing pretty much exactly the same thing as this one. If there's still ongoing work on that PR I'll just shelve this for now.

Yes, and there is work to correctly handle input events with another display-id.

Could you review/test #1177, please? (I have no device with several ids, I can only review the code without testing)

Copy link

@mmbossoni mmbossoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get it to work on a device I have here unfortunately.

./run x --display 1
java.lang.AssertionError: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
        at com.genymobile.scrcpy.wrappers.DisplayManager.getDisplayInfo(DisplayManager.java:26)
        at com.genymobile.scrcpy.Device.computeScreenInfo(Device.java:52)
        at com.genymobile.scrcpy.Device.<init>(Device.java:31)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:19)
        at com.genymobile.scrcpy.Server.main(Server.java:166)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:338)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
        at com.genymobile.scrcpy.wrappers.DisplayManager.getDisplayInfo(DisplayManager.java:18)
        ... 6 more

@rickychow-google
Copy link
Author

I believe this PR, similar to the other PR, needs the display to have the FLAG_SUPPORTS_PROTECTED_BUFFERS flag. You'll have to look at dumpsys display to see which display-id has it and use that. Maybe an improvement on this is for scrcpy to identify which display-id are valid and either run scrcpy for all of them, or display a useful error message when an invalid display-id is used.

@rom1v
Copy link
Collaborator

rom1v commented Mar 19, 2020

Is it possible to "simulate" is some way a secondary display-id?

@mmbossoni
Copy link

mmbossoni commented Mar 20, 2020

I believe this PR, similar to the other PR, needs the display to have the FLAG_SUPPORTS_PROTECTED_BUFFERS flag. You'll have to look at dumpsys display to see which display-id has it and use that. Maybe an improvement on this is for scrcpy to identify which display-id are valid and either run scrcpy for all of them, or display a useful error message when an invalid display-id is used.

Both Displays have the FLAG_SUPPORTS_PROTECTED_BUFFERS :(
Any way I can help debugging this? Are there any logs/dump from server?

@peanutwolf
Copy link
Contributor

I believe this PR, similar to the other PR, needs the display to have the FLAG_SUPPORTS_PROTECTED_BUFFERS flag. You'll have to look at dumpsys display to see which display-id has it and use that. Maybe an improvement on this is for scrcpy to identify which display-id are valid and either run scrcpy for all of them, or display a useful error message when an invalid display-id is used.

Both Displays have the FLAG_SUPPORTS_PROTECTED_BUFFERS :(
Any way I can help debugging this? Are there any logs/dump from server?

Hello @mmbossoni . What API level do you have on your device? If it is 29, then could you please test #1177 for input events on primary and secondary display?

@mmbossoni
Copy link

mmbossoni commented Mar 21, 2020

@peanutwolf
API Level is 29
Thing is: I can't get neither PRs working on display 1 :(. So... I can't tell if input is working because I can't see the screen...

EDIT: Although my device has 2 screens, only one is being listed on the android API. Bad luck. :(

@peanutwolf
Copy link
Contributor

@mmbossoni thank you for your test.
Could you please provide the console output of scrcpy when you launch it with display 1
And could you please provide the output from your device(enter in console):
$ adb shell dumpsys display | grep DisplayInfo

@mmbossoni
Copy link

mmbossoni commented Mar 23, 2020

@peanutwolf, when I run it with display 1 scrcpy give me the AssertionError (NPE) and suggest the use of display 0. (For this PR #1223 (review))

I made a small android app that just list the displays, but DisplayManager only return 1 display, so that must be the problem.

Display info:

    mDisplayInfos=
      PhysicalDisplayInfo{336 x 960, 60.000004 fps, density 2.25, 254.0 x 256.673 dpi, secure true, appVsyncOffset 1000000, bufferDeadline 16666666}
    mDisplayInfos=
      PhysicalDisplayInfo{800 x 600, 60.000004 fps, density 2.25, 369.454 x 371.707 dpi, secure true, appVsyncOffset 1000000, bufferDeadline 16666666}
    mBaseDisplayInfo=DisplayInfo{"Built-in Screen, displayId 0", uniqueId "local:19260200449928065", app 336 x 960, real 336 x 960, largest app 336 x 960, smallest app 336 x 960, mode 1, defaultMode 1, modes [{id=1, width=336, height=960, fps=60.000004}], colorMode 0, supportedColorModes [0], hdrCapabilities android.view.Display$HdrCapabilities@413e3a39, rotation 0, density 360 (254.0 x 256.673) dpi, layerStack 0, appVsyncOff 1000000, presDeadline 16666666, type BUILT_IN, address {port=129, model=0x446d0cde1eeb}, state OFF, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS, removeMode 0}
    mOverrideDisplayInfo=DisplayInfo{"Built-in Screen, displayId 0", uniqueId "local:19260200449928065", app 672 x 1620, real 672 x 1920, largest app 1620 x 1620, smallest app 672 x 618, mode 1, defaultMode 1, modes [{id=1, width=336, height=960, fps=60.000004}], colorMode 0, supportedColorModes [0], hdrCapabilities android.view.Display$HdrCapabilities@413e3a39, rotation 0, density 360 (254.0 x 256.673) dpi, layerStack 0, appVsyncOff 1000000, presDeadline 16666666, type BUILT_IN, address {port=129, model=0x446d0cde1eeb}, state OFF, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS, removeMode 0}
    mBaseDisplayInfo=DisplayInfo{"HDMI Screen, displayId 1", uniqueId "local:19261025351113858", app 800 x 600, real 800 x 600, largest app 800 x 600, smallest app 800 x 600, mode 2, defaultMode 2, modes [{id=2, width=800, height=600, fps=60.000004}], colorMode 0, supportedColorModes [0, 7, 9], hdrCapabilities android.view.Display$HdrCapabilities@413e3a39, rotation 0, density 360 (369.454 x 371.707) dpi, layerStack 1, appVsyncOff 1000000, presDeadline 16666666, type HDMI, address {port=130, model=0x446dccee101c}, state OFF, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS, FLAG_PRESENTATION, removeMode 0}
    mOverrideDisplayInfo=DisplayInfo{"HDMI Screen, displayId 1", uniqueId "local:19261025351113858", app 800 x 546, real 800 x 600, largest app 800 x 614, smallest app 600 x 492, mode 2, defaultMode 2, modes [{id=2, width=800, height=600, fps=60.000004}], colorMode 0, supportedColorModes [0, 7, 9], hdrCapabilities android.view.Display$HdrCapabilities@413e3a39, rotation 0, density 360 (369.454 x 371.707) dpi, layerStack 1, appVsyncOff 1000000, presDeadline 16666666, type HDMI, address {port=130, model=0x446dccee101c}, state OFF, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS, FLAG_PRESENTATION, removeMode 0}

@mmbossoni
Copy link

Hey @peanutwolf, just passing by to tell that after restarting my adb as root I got both, screen and input working on display 1.
My device seems to have some issue with regular users accessing the secondary display...
Anyway, it is working.

@rom1v
Copy link
Collaborator

rom1v commented Apr 2, 2020

#1238 has been merged.

@rom1v rom1v closed this Apr 2, 2020
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

Successfully merging this pull request may close these issues.

5 participants