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

Missing null check in MoveGestureDetector updateMoveDistancesObjects #99

Open
felix-ht opened this issue Mar 28, 2022 · 1 comment
Open

Comments

@felix-ht
Copy link

In rare cases the MoveGestureDetector causes and error while gestures are processed.

This seems to be related to using Flutters Hybrid Composition

more details:
flutter-mapbox-gl/maps#975

The suggestion would be to add a null check to the offending function.

Crash Log:

E/MethodChannel#flutter/platform_views: Failed to handle method call
    java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.android.gestures.MoveDistancesObject.addNewPosition(float, float)' on a null object reference
        at com.mapbox.android.gestures.MoveGestureDetector.updateMoveDistancesObjects(MoveGestureDetector.java:172)
        at com.mapbox.android.gestures.MoveGestureDetector.analyzeMovement(MoveGestureDetector.java:147)
        at com.mapbox.android.gestures.MultiFingerGesture.analyzeEvent(MultiFingerGesture.java:106)
        at com.mapbox.android.gestures.ProgressiveGesture.analyzeEvent(ProgressiveGesture.java:55)
        at com.mapbox.android.gestures.MoveGestureDetector.analyzeEvent(MoveGestureDetector.java:141)
        at com.mapbox.android.gestures.BaseGesture.analyze(BaseGesture.java:61)
        at com.mapbox.android.gestures.BaseGesture.onTouchEvent(BaseGesture.java:39)
        at com.mapbox.android.gestures.AndroidGesturesManager.onTouchEvent(AndroidGesturesManager.java:193)
        at com.mapbox.mapboxgl.MapboxMapController$1.onTouch(MapboxMapController.java:199)
        at android.view.View.dispatchTouchEvent(View.java:13479)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3082)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2767)
        at io.flutter.plugin.platform.PlatformViewsController$1.onTouch(PlatformViewsController.java:313)
        at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.touch(PlatformViewsChannel.java:176)
        at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:68)
        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
        at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
        at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320)
        at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:224)
        at android.app.ActivityThread.main(ActivityThread.java:7562)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'void com.mapbox.android.gestures.MoveDistancesObject.addNewPosition(float, float)' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.android.gestures.MoveDistancesObject.addNewPosition(float, float)' on a null object reference
        at com.mapbox.android.gestures.MoveGestureDetector.updateMoveDistancesObjects(MoveGestureDetector.java:172)
        at com.mapbox.android.gestures.MoveGestureDetector.analyzeMovement(MoveGestureDetector.java:147)
        at com.mapbox.android.gestures.MultiFingerGesture.analyzeEvent(MultiFingerGesture.java:106)
        at com.mapbox.android.gestures.ProgressiveGesture.analyzeEvent(ProgressiveGesture.java:55)
        at com.mapbox.android.gestures.MoveGestureDetector.analyzeEvent(MoveGestureDetector.java:141)
        at com.mapbox.android.gestures.BaseGesture.analyze(BaseGesture.java:61)
        at com.mapbox.android.gestures.BaseGesture.onTouchEvent(BaseGesture.java:39)
        at com.mapbox.android.gestures.AndroidGesturesManager.onTouchEvent(AndroidGesturesManager.java:193)
        at com.mapbox.mapboxgl.MapboxMapController$1.onTouch(MapboxMapController.java:199)
        at android.view.View.dispatchTouchEvent(View.java:13479)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3082)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2767)
        at io.flutter.plugin.platform.PlatformViewsController$1.onTouch(PlatformViewsController.java:313)
        at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.touch(PlatformViewsChannel.java:176)
        at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:68)
        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
        at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
        at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320)
        at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:224)
        at android.app.ActivityThread.main(ActivityThread.java:7562)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
    )
    #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
    #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:177:18)
    <asynchronous suspension>
    #2      AndroidViewController.sendMotionEvent (package:flutter/src/services/platform_views.dart:803:5)
    <asynchronous suspension>
    #3      AndroidViewController.dispatchPointerEvent (package:flutter/src/services/platform_views.dart:895:7)
    <asynchronous suspension>

@lantah-1
Copy link

lantah-1 commented Feb 6, 2023

+1

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

2 participants