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

Crash after close (terminatem, exit) navigation from notification bar #842

Closed
siavashabdoli opened this issue Apr 10, 2018 · 8 comments
Closed

Comments

@siavashabdoli
Copy link

**Android API:6
**Mapbox Navigation SDK version:13.0.0-snapshot

Steps to trigger behavior

  1. during the navigation (near to destination)
  2. close navigation from notification
  3. app sometime crashes!

Actual behavior

I have fabric but because I tested lots of different version with same versioning number the last part of stacktrace is not correct:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'com.mapbox.geojson.Point com.mapbox.services.android.navigation.v5.navigation.x.x.x(com.mapbox.services.android.navigation.v5.navigation.a.c)' on a null object reference at com.mapbox.services.android.navigation.ui.v5.camera.NavigationCamera.initialize(Unknown Source) at com.mapbox.services.android.navigation.ui.v5.camera.NavigationCamera.initialize(Unknown Source) at com.mapbox.services.android.navigation.ui.v5.camera.NavigationCamera$1.onProgressChange(Unknown Source) at com.mapbox.services.android.navigation.v5.navigation.NavigationEventDispatcher.addMilestoneEventListener(Unknown Source) at com.mapbox.services.android.navigation.v5.navigation.NavigationService.onNewRouteProgress(Unknown Source) at com.mapbox.services.android.navigation.v5.navigation.NavigationEngine$1.run(Unknown Source) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

so because of that wrong stack trace on initialize I try to find the real stack trace and seems the problem is with navigationCamera-animateCameraFromLocation method:
Point targetPoint = cameraEngine.target(routeInformation);

that make sense because of input and output part of method. btw seems the camera is null because of termination from notification bar but there is a running thread in background that should be canceled or put some check before every call to changing camera

@danesfeder
Copy link
Contributor

Hey @siavashabdoli, thanks for bringing this to us. Are you using the NavigationView or NavigationLauncher? I'm having trouble deciphering your stack trace (seems that parts of it are missing). Are you able to provide a complete one? Thanks!

@siavashabdoli
Copy link
Author

siavashabdoli commented Apr 10, 2018

Hi @danesfeder actually that's all from fabric I'll try to reproduce it from a debuggable device or add a correct versioning and add mapping file to fabric to check if I can get a better stacktrace.
I'm using NavigationView inside of my customized NavigationActivity

@siavashabdoli
Copy link
Author

siavashabdoli commented Apr 10, 2018

@danesfeder ok I reproduce that with the Mapbox NavigationActivity in simulate mode :)

04-10 18:17:41.997 12876-12876/com.mapbox.services.android.navigation.testapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.mapbox.services.android.navigation.testapp, PID: 12876 java.lang.NullPointerException: Attempt to invoke virtual method 'com.mapbox.geojson.Point com.mapbox.services.android.navigation.v5.navigation.camera.Camera.target(com.mapbox.services.android.navigation.v5.navigation.camera.RouteInformation)' on a null object reference at com.mapbox.services.android.navigation.ui.v5.camera.NavigationCamera.animateCameraFromLocation(NavigationCamera.java:245) at com.mapbox.services.android.navigation.ui.v5.camera.NavigationCamera.onProgressChange(NavigationCamera.java:102) at com.mapbox.services.android.navigation.v5.navigation.NavigationEventDispatcher.onProgressChange(NavigationEventDispatcher.java:156) at com.mapbox.services.android.navigation.v5.navigation.NavigationService.onNewRouteProgress(NavigationService.java:115) at com.mapbox.services.android.navigation.v5.navigation.NavigationEngine$1.run(NavigationEngine.java:123) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

at some specific time this would be happened if you quit navigation from notification bar.
seems we have to somehow cancel that handler or unsubscribe from it as a better solution or put some if for that :D

@danesfeder
Copy link
Contributor

@siavashabdoli Can you share your code for NavigationView in your NavigationActivity? Specifically the lifecycle methods mirroring https://www.mapbox.com/android-docs/navigation/overview/navigation-ui/#navigationview-activity-example

@siavashabdoli
Copy link
Author

@danesfeder sorry for delay. there is no difference between all method that exist in the link and my NavigationActivity.I checked it again.did you get the scenario? as fabric reported and as I see the application is in the foreground and maybe onPuase is not invoked and it's correct. the application is in foreground I swipe down the notifications ( it does not lead to invoke onPause) and terminate the navigation from that notification. where is the mechanism to unsubscribe that handler? I can't find anything. why you think maybe it's related to lifecycle?

@danesfeder
Copy link
Contributor

@siavashabdoli I haven't been able to reproduce this on my side with the SDK NavigationActivity which you've just explained you're mirroring as far as lifecycle. Can you post a video link or gif showing you reproducing this? The obvious fix here is a null check on the engine, but I want to see if it's something deeper related to our shutdown processes of the service / view. Thanks!

@siavashabdoli
Copy link
Author

@vladgheorghe
Copy link

vladgheorghe commented May 10, 2018

I'm getting a few of these reports as well and I have a fully custom implementation. It maybe some sort of race condition that we are missing

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