Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move map lifecycle callbacks to onStart / onStop #5265

Merged
merged 1 commit into from
Sep 26, 2023
Merged

Move map lifecycle callbacks to onStart / onStop #5265

merged 1 commit into from
Sep 26, 2023

Conversation

tapetis
Copy link
Contributor

@tapetis tapetis commented Sep 23, 2023

This PR changes the lifecycle callbacks so that the tangram map is resumed in onStart and paused in onStop instead of in onResume and onPause. This causes the callbacks to be executed a little earlier or later, respectively.

This prevents the map from being completely black during the back gesture animation (when enabled) on Android 14 (see the screenshots below). This is also the recommended behavior on devices supporting multi-window but not multi-resume (see here), where an activity could be visible to the user in its paused state.

Old New

I have been using the app with these changes for some time now and have not experienced any related issues.

@westnordost
Copy link
Member

Hm well, but still com.mapzen.tangram.MapView.onResume is called. I digged into that and in the end, it calls android.opengl.GLSurfaceView.onResume. Unless it is specifically documented (that it is fine) otherwise, I would not like to break GLSurfaceViews expectation that this method is called on onResume.

@tapetis
Copy link
Contributor Author

tapetis commented Sep 25, 2023

At least the documentation for GlSurfaceView.onPause and GlSurfaceView.onResume directly mentions Activity.onStop respectively Activity.onStart as typical points in time when these functions should be called. However, resuming the map already in onStart makes it more likely that the onResume function is called before a renderer is set on the GLSurfaceView. Setting this renderer is asynchronously triggered by the following line:

As I said, I haven't had any problems with it so far. But I will take a closer look at it again.

@westnordost
Copy link
Member

Oh wow, that shall suffice. I wouldn't have thought that exactly the thing I mentioned would directly be mentioned in the documentation for that very function, lol.

Thank you!

@westnordost westnordost merged commit 237c178 into streetcomplete:master Sep 26, 2023
@tapetis tapetis deleted the onstart-map-resume branch September 26, 2023 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants