flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.38k stars 27.56k forks source link

NPE when calling android.view.InputDevice.getMotionRange(int) from FlutterView.java #27641

Closed ScottS2017 closed 5 years ago

ScottS2017 commented 5 years ago

scrcpy ( https://github.com/Genymobile/scrcpy ) is an app that mirrors your physical device on your desktop and allows you to control the device via the mirror. When clicking on the mirror with the mouse, I'm getting an NPE when calling android.view.InputDevice.getMotionRange(int) from FlutterView.java.

https://github.com/flutter/engine/blob/master/shell/platform/android/io/flutter/view/FlutterView.java#L475

https://developer.android.com/reference/android/view/InputEvent.html#getDevice%28%29

Steps to Reproduce

  1. Create an app with a simple DropdownButton( )
  2. Connect an actual device via USB
  3. Run scrcpy
  4. Run your app on the device
  5. Test the DropdownButton( ) by physically tapping the button on the device. Ensure this test passes.
  6. Repeat this test by using the mouse to click the DropdownButton( ) on the mirror that is on your desktop.

Logs

E/InputEventReceiver(22756): Exception dispatching input event.
E/MessageQueue-JNI(22756): Exception in MessageQueue callback: handleReceiveCallback
E/MessageQueue-JNI(22756): java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.InputDevice$MotionRange android.view.InputDevice.getMotionRange(int)' on a null object reference
E/MessageQueue-JNI(22756):  at io.flutter.view.FlutterView.addPointerForIndex(FlutterView.java:477)
E/MessageQueue-JNI(22756):  at io.flutter.view.FlutterView.onTouchEvent(FlutterView.java:537)
E/MessageQueue-JNI(22756):  at android.view.View.dispatchTouchEvent(View.java:9945)
E/MessageQueue-JNI(22756):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
E/MessageQueue-JNI(22756):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2301)
G:\Flutter\myprojects\mtg_upkeep>flutter analyze
Analyzing mtg_upkeep...
No issues found! (ran in 6.3s)
G:\Flutter\myprojects\mtg_upkeep>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, v1.2.1-pre.89, on Microsoft Windows [Version 10.0.17134.523], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 3.3)
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
[√] IntelliJ IDEA Community Edition (version 2018.1)
[√] VS Code (version 1.27.2)
[√] Connected device (1 available)

! Doctor found issues in 2 categories.

(Flutter doctor flags that AS doesn't have the plugin but I use IntelliJ for Flutter, so we can ignore it.)

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.