Android SDK crashes if map activity is open on screen, but untouched, for several hours
I left my app open to the map activity overnight and saw this crash ~16 hours later:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.mapboxsdk.views.NativeMapView.update()' on a null object reference
at com.mapbox.mapboxsdk.views.MapView.update(MapView.java:2179)
at com.mapbox.mapboxsdk.views.UserLocationView.updateOnNextFrame(UserLocationView.java:413)
at com.mapbox.mapboxsdk.views.UserLocationView$MarkerCoordinateAnimatorListener.onAnimationUpdate(UserLocationView.java:475)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1374)
at android.animation.ValueAnimator.animationFrame(ValueAnimator.java:1298)
at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1339)
at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:715)
at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:738)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
at android.view.Choreographer.doCallbacks(Choreographer.java:590)
at android.view.Choreographer.doFrame(Choreographer.java:559)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6862)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
I don't execute any code related to the map without user interaction. I believe this crash is due to the SDK doing some sort of work in the background. Has anyone else seen this?
I have setup a secondary device for testing with a map with location enabled.
Looking at the code of the update methode:
// Used by UserLocationView
void update() {
if (mNativeMapView != null) {
mNativeMapView.update();
}
}
This should never throw a NullPointerException..
@JordanHamel could you verify which scenario applies to this use-case:
- [ ] screen is turned off during overnight
- [x] having
always screen on- option enabled in developer options
@tobrun In my app, the screen timeout is set to 24 hours, so the screen was on when it crashed.
@JordanHamel Which version of the SDK are you using? I have setup a similar test with timeout on a Nexus 10 tablet.
I saw this crash using V2.2 of the SDK on a Samsung Galaxy Tab 4.
Would you be able to update you SDK to 3.0.0 and retest?
I'm going to close this issue based on:
- I'm unable to reproduce this locally with current SDK
- Stacktrace points to a line that is currently nullpointer safe on master
@JordanHamel reopen if you are able to reproduce
I have the same error:
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3429)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3469)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2732)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.mapboxsdk.maps.NativeMapView.update()' on a null object reference
at com.mapbox.mapboxsdk.maps.MapView.onResume(MapView.java:613)
at com.taksio.apps.client.fragments.HomeMapFragment.onResume(HomeMapFragment.java:230)
at android.support.v4.app.Fragment.performResume(Fragment.java:2230)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1343)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1523)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1585)
at android.support.v4.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:2842)
at android.support.v4.app.FragmentController.dispatchResume(FragmentController.java:223)
at android.support.v4.app.FragmentActivity.onResumeFragments(FragmentActivity.java:509)
at android.support.v4.app.FragmentActivity.onPostResume(FragmentActivity.java:498)
at android.support.v7.app.AppCompatActivity.onPostResume(AppCompatActivity.java:175)
at android.app.Activity.performResume(Activity.java:6807)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3406)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3469)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2732)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.1@aar') { transitive = true }
android 7.1.1 nexus 5X
Same issue is in my app I am using compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.0-beta.1@aar'){ transitive=true } compile ('com.mapbox.mapboxsdk:mapbox-android-services:1.2.1@aar'){ transitive=true }
still app crash and the error is java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.mapboxsdk.maps.NativeMapView.createSurface(android.view.Surface)' on a null object reference at com.mapbox.mapboxsdk.maps.MapView$SurfaceCallback.surfaceCreated(MapView.java:1410)
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.0-beta.1@aar'){ transitive=true } compile ('com.mapbox.mapboxsdk:mapbox-android-services:1.2.1@aar'){ transitive=true }
still app crash and the error is java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.mapboxsdk.maps.NativeMapView.createSurface(android.view.Surface)' on a null object reference at com.mapbox.mapboxsdk.maps.MapView$SurfaceCallback.surfaceCreated(MapView.java:1410)
@NancyAndroid could you please update the dependency to a more recent version? The latest is 5.1.3
@tobrun I have updated the code still it crashes when app is open and device is idle or app is in background we are using others app then device idle for 5-6 min then app crash .
Here is the log of that crash
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.mapboxsdk.maps.NativeMapView.createSurface(android.view.Surface)' on a null object reference at com.mapbox.mapboxsdk.maps.MapView$SurfaceCallback.surfaceCreated(MapView.java:426) at android.view.SurfaceView.updateWindow(SurfaceView.java:656) at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:266) at android.view.View.dispatchWindowVisibilityChanged(View.java:11139) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290)
@tobrun Here is the dependencies which I am using compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.3@aar'){ transitive=true }