You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
In my case I have a fragment that shows the user a map of where they are. On Android Api 23 or higher I have to ask the user for permission to get their location. In that scenario I don't load the map until they give me permission and I get the location. I'm running across a race condition when the user agrees to the permission I load the fragment with the map, while it in the middle of loading, I replace the fragment with another one triggered by a location update callback. OnStop() gets called on the first fragment and MapView which throws a null pointer because it hasn't finished with the async map setup.
public void onStop() {
mapboxMap.onStop();
ConnectivityReceiver.instance(getContext()).deactivate();
}
In my case mapboxMap was null.
I called onStop() from within a try catch to silence the error.
After doing that and replicating the scenario I got a crash inside of onDetachedFromWindow()
I went ahead a extended MapView in which I override onDetachedFromWindow() and call the super from within a try catch.
After that, initialiseDrawingSurface() inside of MapView throws this exception:
java.lang.IllegalStateException: setRenderer has already been called for this instance.
at android.opengl.GLSurfaceView.checkRenderThreadState(GLSurfaceView.java:1934)
at android.opengl.GLSurfaceView.setEGLContextClientVersion(GLSurfaceView.java:578)
at com.mapbox.mapboxsdk.maps.MapView.initialiseDrawingSurface(MapView.java:291)
at com.mapbox.mapboxsdk.maps.MapView.access$100(MapView.java:68)
at com.mapbox.mapboxsdk.maps.MapView$1.onGlobalLayout(MapView.java:141)
at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:982)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2461)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1488)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7451)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920)
at android.view.Choreographer.doCallbacks(Choreographer.java:695)
at android.view.Choreographer.doFrame(Choreographer.java:631)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Steps to trigger behavior
Navigate to an activity with a fragment that has a map
Shortly after adding the fragment replace it with another fragment with a map
Crash
The text was updated successfully, but these errors were encountered:
simon1867
changed the title
Crash Inside MapView When Stopping Activity Before Map is Fully Initialized
Crash Inside MapView When Calling OnStop() Before Map is Fully Initialized
Oct 20, 2017
I ended up preventing the crash by throttling my callback so that I don't replace my fragment before the map on the previous fragment is already loaded.
@simon-the-canadian thank you for the report: will look into hardening the onStop invocaton, the mapZoomButton controller has recently been fixed with:
@Override@CallSuperprotectedvoidonDetachedFromWindow() {
super.onDetachedFromWindow();
if (isZoomButtonControllerInitialized()) {
mapZoomButtonController.setVisible(false);
}
}
Platform: Android
Mapbox SDK version: 5.2.0 beta 1
In my case I have a fragment that shows the user a map of where they are. On Android Api 23 or higher I have to ask the user for permission to get their location. In that scenario I don't load the map until they give me permission and I get the location. I'm running across a race condition when the user agrees to the permission I load the fragment with the map, while it in the middle of loading, I replace the fragment with another one triggered by a location update callback. OnStop() gets called on the first fragment and MapView which throws a null pointer because it hasn't finished with the async map setup.
In my case
mapboxMap
was null.I called onStop() from within a try catch to silence the error.
After doing that and replicating the scenario I got a crash inside of onDetachedFromWindow()
mapZoomButtonController
was null.I went ahead a extended MapView in which I override onDetachedFromWindow() and call the super from within a try catch.
After that, initialiseDrawingSurface() inside of MapView throws this exception:
Steps to trigger behavior
The text was updated successfully, but these errors were encountered: