Rework eglDisplay and eglContext construction/destruction#9412
Conversation
…. Rework lifecycle events. Postpone map initalisation.
|
The only issue I was able to identify is that we are losing the map state when you are stopping/starting the activity (eg. press home button and reopen the app from recent apps list). The reason for this is that onSaveInstanceState isn't triggered and thus there isn't any state to recover from (the map will be started with initial configuration). update is now fixed with introducing a saved state bundle as part of onStop. |
|
With current codebase, the approach of retaining the map but destroying the display and context, doesn't seem to be a viable option. Getting it to work seems to be a lift & with GLSurfaceView on the horizon, it seems better to punt on this and focus on other issues. |
This PR reworks the way we handle
eglDisplayandeglContextcreation and destruction.Main purpose of this change is to eliminate state and resolve edge case crashes.
Simplified egl state
Before this PR, a couple of code paths were possible related to egl state management.
This is now simplified and build around the
SurfaceViewcallbacks:This means that an application going into background will go through the same lifecycle as an Activity that is being recreated through rotation. We aren't retaining the map object, eglDisplay and eglContext anymore in the former use-case and this streamlines invoking above code blocks when a map is no longer visible on the screen.
Visibility state of MapView
We used to rely on View inflation to create the map object and trigger Surface creation. With this PR, we are relying on
OnVisibilityChangewhich allows to have finer grain control over when callbacks in above section occur and unblocks toggling the visibility of the MapView and having it hidden at Activity startup.Measured ViewHierarchy
Since we postpone creating the map object, we are slower in loading the style and thus slower in invoking the
OnMapReadycallback for the user. This has the benefit that view hierarchy has been measured and we can remove the workarounds we have in place for them.Additional test Activities
On top of the SDK changes, 2 test activities were added to facilitate testing of this PR.
cc @ivovandongen @mapbox/android @kkaefer