Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

MapView in SupportMapFragment breaks after popping from backstack #13967

Closed
AlexGrafl opened this issue Feb 21, 2019 · 6 comments · Fixed by #14035
Closed

MapView in SupportMapFragment breaks after popping from backstack #13967

AlexGrafl opened this issue Feb 21, 2019 · 6 comments · Fixed by #14035
Labels
Android Mapbox Maps SDK for Android

Comments

@AlexGrafl
Copy link

When using the SupportMapFragment, replacing it with another fragment and popping the backstack, the map becomes unusable.
I created a sample application showcasing this issue, see https://github.com/AlexGrafl/mapbox-fragment-test

Steps to reproduce

  1. Add a SupportMapFragment as either part of the layout or a manual fragment transaction
  2. Replace the fragment with another
  3. Pop backstack

Expected behavior

The backstack is popped and the map view is displayed again and usable as it was before.

Actual behavior

The map is not usable anymore and error messages are thrown in the fashion of You're calling `setGestureInProgress` after the `MapView` was destroyed, were you invoking it after `onDestroy()`?

Note: In this demo application, the app is still responsive. In our real project where we encountered the problem we got segmentation faults and/or abort signals from native code and the app crashed. "Unfortunately" we could not reproduce this behavior in the demo (we used the SupportMapFragment inside another fragment, maybe that was the cause).

Configuration

Android versions: Android 8, Android 9
Device models: Xiaomi Mi A1, Google Pixel 3
Mapbox SDK versions: 7.1.2

@fabian-guerra fabian-guerra added the Android Mapbox Maps SDK for Android label Feb 21, 2019
@tobrun
Copy link
Member

tobrun commented Feb 22, 2019

@AlexGrafl thank you for reaching out, reporting an issue and using our SDK. Really thankful for you adding some example code. We are aware of this issue with fragments and are working on a changing the way we create/destroy the underlying surface and native map object. Will report back with an update asap.

@AlexGrafl
Copy link
Author

When could we expect an update on this? Is there a workaround? It is currently a major blocking issue in our project :/

@tobrun
Copy link
Member

tobrun commented Feb 22, 2019

The idea is that #13976 fixes your issue but I will have to verify with a test first. Will also port your code to catch future regressions.

@AlexGrafl
Copy link
Author

Alright, thank you for your fast replies :)

@tobrun
Copy link
Member

tobrun commented Feb 22, 2019

@AlexGrafl was able to reproduce your issue and while debugging I'm noticing that onResume and onStart aren't called for your setup. After searching for this online, it seems you shouldn't' swap out static declared fragments as mentioned by Jake Wharton here.

Note: When you add a fragment to an activity layout by defining the fragment in the layout XML file, you cannot remove the fragment at runtime. If you plan to swap your fragments in and out during user interaction, you must add the fragment to the activity when the activity first starts, as shown in Build a flexible UI.

@AlexGrafl
Copy link
Author

Interesting, but I even tested it when adding the fragment manually in the activities onCreate method, as I stated in my original issue report and in my demo project. The bevhiour does not change either way.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants