-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Android device soft reboots when I use mouse input over scrcpy #962
Comments
It seems injecting a mouse event cause a segfault or something in a system process. Open Maybe it will have time to print more details about the crash. |
here is adb log from the start of the crash :
|
Arf, the code in your system assumes that the Could you test with this change, please: diffdiff --git a/server/src/main/java/com/genymobile/scrcpy/Controller.java b/server/src/main/java/com/genymobile/scrcpy/Controller.java
index ce02e33..28b7eaf 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Controller.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Controller.java
@@ -177,7 +177,7 @@ public class Controller {
}
MotionEvent event = MotionEvent.obtain(lastTouchDown, now, action, pointerCount, pointerProperties,
- pointerCoords, 0, buttons, 1f, 1f, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0);
+ pointerCoords, 0, buttons, 1f, 1f, -1, 0, InputDevice.SOURCE_TOUCHSCREEN, 0);
return injectEvent(event);
}
@@ -199,7 +199,7 @@ public class Controller {
coords.setAxisValue(MotionEvent.AXIS_VSCROLL, vScroll);
MotionEvent event = MotionEvent.obtain(lastTouchDown, now, MotionEvent.ACTION_SCROLL, 1, pointerProperties,
- pointerCoords, 0, 0, 1f, 1f, 0, 0, InputDevice.SOURCE_MOUSE, 0);
+ pointerCoords, 0, 0, 1f, 1f, -1, 0, InputDevice.SOURCE_MOUSE, 0);
return injectEvent(event);
}
(replace it in your v1.11 release) |
Yes it worked ! I saw that non-null stuff on the net while looking for a solution too , but since I am not a coder didn't know what to do, guess it was that easy. Now , there is another problem with this tvbox, I can't see ANY KIND of VIDEO playing from the box on my pc screen, I know about drm and protected stuff but I can at least play youtube or play movies etc from the device memory with the mx player on MY PHONE. Of course netflix is dark there. BUT on the tvbox every video output is dark, menus etc can be seen over the video but video is dark. From every source , youtube, web videos or tv box's satellite tuner, all shows as dark on pc. Is this all about drm or maybe codec stuff ? |
Inject mouse events using id -1 (virtual device) instead of 0 which does not exist (and causes the InputDevice to be null). Fixes <#962>
Cool, thank you for your report and feedback. Fixed by 26529d3 on
I guess it's basically when the video is totally rendered by hardware (for DRM or performance reasons). |
Can we render the video on our pc the same way how browsers render DRM content? @rom1v |
Thank you @patientx and @rom1v, this thread helped me find leads to resolve my issue of why keyboard and mouse input was not working for me when using scrcpy either over usb or wifi. MIUI's USB debugging (security) permissions were unchecked (they require me to sign up for an MIUI account to tick that checkbox 🤷🏽 ). Once that was done, keyboard and mouse work perfectly. Your application is amazing! :) |
It seems that the fix/workaround causes other problems: #2125 @patientx Could you please try to reproduce your problem with v1.17 + this file: #2125 (comment) ?
So the correct value should be 0 I guess. |
Virtual device is only for keyboard sources, not mouse or touchscreen sources. Here is the value of InputDevice.getDevice(-1).toString(): Input Device -1: Virtual Descriptor: ... Generation: 2 Location: built-in Keyboard Type: alphabetic Has Vibrator: false Has mic: false Sources: 0x301 ( keyboard dpad ) InputDevice.getDeviceId() documentation says: > An id of zero indicates that the event didn't come from a physical > device and maps to the default keymap. <https://developer.android.com/reference/android/view/InputEvent#getDeviceId()> However, injecting events with a device id of 0 causes event.getDevice() to be null on the client-side. Commit 26529d3 used -1 as a workaround to avoid a NPE on a specific Android TV device. But this is a bug in the device system, which wrongly assumes that input device may not be null. A similar issue was present in Flutter, but it is now fixed: - <flutter/flutter#30665> - <flutter/engine#7986> On the other hand, using an id of -1 for touchscreen events (which is invalid) causes issues for some apps: <#2125 (comment)> Therefore, use a device id of 0. An alternative could be to find an existing device matching the source, like "adb shell input" does. See getInputDeviceId(): <https://android.googlesource.com/platform/frameworks/base.git/+/master/cmds/input/src/com/android/commands/input/Input.java> But it seems better to indicate that the event didn't come from a physical device, and it would not solve #962 anyway, because an Android TV has no touchscreen. Refs #962 <#962> Fixes #2125 <#2125>
Virtual device is only for keyboard sources, not mouse or touchscreen sources. Here is the value of InputDevice.getDevice(-1).toString(): Input Device -1: Virtual Descriptor: ... Generation: 2 Location: built-in Keyboard Type: alphabetic Has Vibrator: false Has mic: false Sources: 0x301 ( keyboard dpad ) InputDevice.getDeviceId() documentation says: > An id of zero indicates that the event didn't come from a physical > device and maps to the default keymap. <https://developer.android.com/reference/android/view/InputEvent#getDeviceId()> However, injecting events with a device id of 0 causes event.getDevice() to be null on the client-side. Commit 26529d3 used -1 as a workaround to avoid a NPE on a specific Android TV device. But this is a bug in the device system, which wrongly assumes that input device may not be null. A similar issue was present in Flutter, but it is now fixed: - <flutter/flutter#30665> - <flutter/engine#7986> On the other hand, using an id of -1 for touchscreen events (which is invalid) causes issues for some apps: <#2125 (comment)> Therefore, use a device id of 0. An alternative could be to find an existing device matching the source, like "adb shell input" does. See getInputDeviceId(): <https://android.googlesource.com/platform/frameworks/base.git/+/master/cmds/input/src/com/android/commands/input/Input.java> But it seems better to indicate that the event didn't come from a physical device, and it would not solve #962 anyway, because an Android TV has no touchscreen. Refs #962 <#962> Fixes #2125 <#2125>
I have a android tv box with android 7.1 and wanted to try to control it with scrcpy. I don't have the means to connect it to pc so I enabled adb over tcp ip via :
in termux in the android device.
After this I am using a batch file to connect to this box over the wifi:
And this works great, no need to ever re-enable to adb over usb since I would never use adb over usb with that box , even if I needed to I can disable wifi and re-enable adb over usb with :
So far so good , except ... When I click on anything with my mouse on the open scrcpy window the tvbox reboots -soft reboots- and I can even see the company logo animating in the beginning for a while too :) BUT keyboard input is all right somehow ...
Yes I enabled usb-debugging and yes scrcpy works with my phone etc over the standart usb cable method and it works with the phone over THE WIFI METHOD as well. -which is an android 6 leeco device and rooted-
Here is the windows command screen when the error happens :
Edit : Tvbox uses standard android 7.1 and leeco uses miui, I had to enable both "USB debugging (Security settings) and normal USB debugging" on leeco but on standard android there is only normal usb debugging option which is enabled, anyways isn't it weird that keyboard input works but only mouse input causes this ?
The text was updated successfully, but these errors were encountered: