Open felixkrautschuk opened 2 years ago
@felixkrautschuk can you please provide us with the code for this app? From the information you provided above, it looks like the instance may not have bee properly destroyed/garbage collected when leaving the fragment, but having the code would help us definitively conclude that that is the issue.
@ZiZasaurus thanks for your feedback. I need to mention that it is not a native Android app. We use the NativeScript framework to build our apps for Android and iOS. I know you do not have any official support for that framework, so it is hard to provide specific code that you can work with.
Basically we follow this guide: https://docs.mapbox.com/android/maps/examples/simple-map-view/ But as we are not able to add the Android Mapbox Map directly in the XML UI Layout, we need to programmatically create the Mapbox map and add it to a Framelayout.
public createNativeView(): Object {
return new android.widget.FrameLayout(Utils.android.getApplicationContext());
}
public initNativeView() {
//lifecycle event handlers
Application.android.on(AndroidApplication.activityStartedEvent, (args: AndroidActivityEventData) => {
this.nativeMapView.onStart();
});
Application.android.on(AndroidApplication.activityStoppedEvent, (args: AndroidActivityEventData) => {
this.nativeMapView.onStop();
});
Application.android.on(AndroidApplication.activityDestroyedEvent, (args: AndroidActivityEventData) => {
this.nativeMapView.onDestroy();
});
super.initNativeView();
}
public onLoaded() {
super.onLoaded();
if(!this.isInitialized) {
com.mapbox.maps.ResourceOptionsManager.Companion.getDefault(
Application.android.foregroundActivity,
this.accessToken
);
this.nativeMapView = new com.mapbox.maps.MapView(Application.android.foregroundActivity);
this.nativeView.addView(this.nativeMapView);
this.isInitialized = true;
}
}
I am not able to provide any code about navigating between the Fragments, as NativeScript is caring about all that. But when just switching back to Mapbox 9.7.2 (without changing any NativeScript dependency etc), everything works as expected.
I temporary removed all the logic logic about adding sources, layers etc... this issue already occurs with a basic map.
Would you be able to test our v10.0.0-beta.1, we recently made some patches around lifecycle management.
@tobrun thanks for your feedback, but unfortunately this did not help, still the same behaviour with 10.6.0-beta.1
@tobrun thanks for your feedback, but unfortunately this did not help, still the same behaviour with 10.6.0-beta.1
Later on today we will release v10.7.0-beta.1 - could you please check with it? Not v10.6.0-beta.1 😄
@kiryldz @tobrun still the same behaviour with v10.7.0-beta.1
@kiryldz @tobrun still the same behaviour with v10.7.0-beta.1
Thanks for confirming, that was worth trying. Will need to look deeper in detail then.
As a temporary fix, you can exclude the 'maps-lifecycle' plugin from the com.mapbox.maps dependency (Documentation states that this plugin was added into the com.mapbox.maps dependency from v10.0.0-rc.5). While this does remove the automatic lifecycle handling from the application - it allows for navigation back to a map fragment.
Tested and working with com.mapbox.maps:android:10.8.0-rc.1
@caustin13 thank you, this is working! Indeed I don't want all of this automatic lifecycle handling. When the user goes back to the map fragment, I want to keep the whole state of the map (position, zoom-level, visible layers, etc ...).
I experience the same problem. I have a tab navigation and if I go to a different tab (while the mapbox is already loaded/shown) and then come back the app will crash on android. I use v10.0.0-beta.33
As a temporary fix, you can exclude the 'maps-lifecycle' plugin from the com.mapbox.maps dependency (Documentation states that this plugin was added into the com.mapbox.maps dependency from v10.0.0-rc.5). While this does remove the automatic lifecycle handling from the application - it allows for navigation back to a map fragment.
Tested and working with com.mapbox.maps:android:10.8.0-rc.1
i used the lastest version com.mapbox.maps:android:10.10.0,and test, they didnot repair. I just exclude as you said ,and worked!
I just got the same problem on a specific device (not a mobile phone), with a very old Android version. It worked on all other devices but on this one, after turning off the screen (I used a broadcast receiver to detect screen on/off and tried to invalidate the map), after some other activity was loaded and unloaded over the map activity, the map turns all black.
Even after excluding maps-lifecycle
as @caustin13 said, I still get a RenderThread : surface destroyed
followed by a Failed looking up window
and Requested window android.os.BinderProxy@156ae7b6 does not exist
. This can be related? I'm just using the com.mapbox.navigation:android:2.10.0
dependency.
Environment
Observed behavior and steps to reproduce
Navigating forwards to a Fragment with Mapbox map works as expected (also multiple times back and forth), but when navigating back to a Fragment with a Mapbox map from a different Fragment, the app does not respond anymore.
https://user-images.githubusercontent.com/6443021/175537861-1586d6f4-cf74-4215-9378-d07b65307c66.mov
When navigating away (forwards) from the Mapbox map Fragment, I see the following log in Logcat:
When attempting to navigate back to that Mapbox Map Fragment:
Please note, that this was working as expected when using Mapbox Android SDK 9.7.2.
Expected behavior
When navigating back to a Fragment with Mapbox map, the app should not hang up and ideally the map should not loose its state (as it was working until Mapbox SDK 9.7.2)
Notes / preliminary analysis
-
Additional links and references
-