This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
Rework eglDisplay and eglContext construction/destruction #9412
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR reworks the way we handle
eglDisplay
andeglContext
creation 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
SurfaceView
callbacks: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
OnVisibilityChange
which 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
OnMapReady
callback 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