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

Only pause rendering if the Android activity is stopped #14211

Merged
merged 1 commit into from Jan 27, 2024

Conversation

grorp
Copy link
Member

@grorp grorp commented Jan 4, 2024

Depends on minetest/irrlicht#269.

Since #14058, rendering is paused on Android when the app is paused. However, it is also paused when the app is merely "unfocused" (e.g. a text input dialog is open). This is a problem because:

To do

This PR is a Ready for Review.

How to test

Verify that rendering still happens while the text input dialog is open.

Verify that the issue described in #13814 (review) is fixed.

@grorp grorp added Android Bugfix 🐛 PRs that fix a bug @ Client rendering Waiting (on dependency) Waiting on another PR or external circumstances (not for rebases/changes requested) labels Jan 4, 2024
@grorp
Copy link
Member Author

grorp commented Jan 18, 2024

I think this is still wrong. Apparently we shouldn't pause rendering when the activity is paused (onPause), but when the activity is stopped (onStop).

However, as mentioned in the section about onResume(), a Paused activity might still be fully visible if the app is in multi-window mode. Consider using onStop() instead of onPause() to fully release or adjust UI-related resources and operations to better support multi-window mode.
https://developer.android.com/guide/components/activities/activity-lifecycle#onpause

A GLSurfaceView must be notified when to pause and resume rendering. GLSurfaceView clients are required to call onPause() when the activity stops and onResume() when the activity starts. These calls allow GLSurfaceView to pause and resume the rendering thread, and also allow GLSurfaceView to release and recreate the OpenGL display.
https://developer.android.com/reference/android/opengl/GLSurfaceView#activity-life-cycle (emphasis mine)

So you're supposed to map Activity::onStop to GLSurfaceView::onPause and Activity::onStart to GLSurfaceView::onResume, if I understand this correctly. I'm not sure whether Irrlicht actually uses GLSurfaceView, but it's probably a good reference anyway.

This PR can stay as is, but I'll prepare another PR to Irrlicht.

@grorp grorp changed the title Only pause rendering if the Android app is actually paused Only pause rendering if the Android activity is stopped Jan 18, 2024
@grorp grorp removed the Waiting (on dependency) Waiting on another PR or external circumstances (not for rebases/changes requested) label Jan 19, 2024
@grorp
Copy link
Member Author

grorp commented Jan 19, 2024

This PR is now ready for review.

Pausing rendering in onStop instead of onPause has, in addition to being correct, another big benefit: If you now press "Share debug log" on the "About" tab, the clouds continue moving behind the dialog 😎

the_cool_video.mp4

Out of curiosity, I tested this with 5.8.0 from Google Play. The clouds don't continue moving there, although 5.8.0 doesn't have any "pause rendering" code 🤔

... and I tested again with a CI build of 5.8.0 (https://github.com/minetest/minetest/actions/runs/7090139065). The clouds do continue moving there. Maybe the Google Play build was made with an outdated Irrlicht version (before minetest/irrlicht#255)? I sometimes had to delete deps.zip and the deps folder manually to get it to update. @rubenwardy

@grorp grorp added this to the 5.9.0 milestone Jan 22, 2024
@grorp grorp merged commit fbec168 into minetest:master Jan 27, 2024
13 checks passed
@grorp grorp deleted the better-pause-rendering branch January 27, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants