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

Preserve GLSurfaceView's EGL context on pause #12844

Merged
merged 1 commit into from
Sep 26, 2018

Conversation

LukasPaczos
Copy link
Member

Closes #12724.

The issue surfaced with the introduction of the GLSurfaceView - whenever activity containing a surface is paused, the surface releases the EGL context and forces the surface to be recreated upon coming back to the activity, which forces us to redraw the tiles.

This PR sets the PreserveEGLContextOnPause flag which tries to hold on to the EGL context when activity is paused, but only if the hardware allows for it. From documentation:

Whether the EGL context is actually preserved or not depends upon whether the Android device that the program is running on can support an arbitrary number of EGL contexts or not. Devices that can only support a limited number of EGL contexts must release the EGL context in order to allow multiple applications to share the GPU.

Before:
ezgif com-video-to-gif 7

After:
ezgif com-video-to-gif 8

@LukasPaczos LukasPaczos added the Android Mapbox Maps SDK for Android label Sep 7, 2018
@LukasPaczos LukasPaczos added this to the android-v6.6.0 milestone Sep 7, 2018
@LukasPaczos LukasPaczos force-pushed the 12724-preserve-egl-context-on-pause branch from 80ef0e0 to 9db982f Compare September 26, 2018 10:07
@ivovandongen ivovandongen requested review from tobrun and removed request for ivovandongen September 26, 2018 11:01
Copy link
Member

@tobrun tobrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on 5 different devices with different OS versions.
LGTM, :shipit:

@LukasPaczos LukasPaczos merged commit f1a0947 into master Sep 26, 2018
@LukasPaczos LukasPaczos deleted the 12724-preserve-egl-context-on-pause branch September 26, 2018 11:46
@saugs
Copy link

saugs commented May 19, 2019

Sorry to comment on an old subject, but is that merge effective on android SDK 7.5.0-beta.1 ?

Because I'm still experiencing issue : mapview's GLSurfaceView is being recreated after onResume.
For now I'm using TextureView (mapbox:mapbox_renderTextureMode).

@LukasPaczos
Copy link
Member Author

@SeboRax, since this has landed, we've made changes to the GLSurfaceView implementation to improve lifecycle and introduce recycler view support. Unfortunately, those changes required recreation of the context/surface which forces tiles to reload that is seen in the OP. This is working as intended now.

@saugs
Copy link

saugs commented May 20, 2019

Ok thanks for your answer, I'll stay using TextureView for now

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 this pull request may close these issues.

Reload map tiles every onResume.
3 participants