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

Android) add mechanics to resume application from background #660

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hsdk123
Copy link
Contributor

@hsdk123 hsdk123 commented Jan 23, 2025

Currently, the application will crash if sent to the background and brought back to the foreground.
The following provides a mechanism to continue the application.

Copy link
Owner

@mosra mosra left a comment

Choose a reason for hiding this comment

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

If I understand correctly, this is about handling the case where GL context isn't lost and just the window surface is, right? So it's not like existing GL objects become invalid afterwards.

I'll have to think how to expose this in a way that makes sense with other apps. I can imagine that for example on desktop with SDL/GLFW one might want to attach to some focusEvent() / blurEvent() as well, when the window gets active or inactive.

Comment on lines +222 to +223
/* Pause the context current */
CORRADE_INTERNAL_ASSERT_OUTPUT(eglMakeCurrent(_display, nullptr, nullptr, nullptr));
Copy link
Owner

Choose a reason for hiding this comment

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

Would this work if you kept the context current and just made it bound to no surface at all?

Suggested change
/* Pause the context current */
CORRADE_INTERNAL_ASSERT_OUTPUT(eglMakeCurrent(_display, nullptr, nullptr, nullptr));
/* Keep the GL context current but without any surface */
CORRADE_INTERNAL_ASSERT_OUTPUT(eglMakeCurrent(_display, EGL_NO_SURFACE, EGL_NO_SURFACE, _glContext));

Because I'm wondering if it's guaranteed that no app code gets executed between APP_CMD_LOST_FOCUS and APP_CMD_INIT_WINDOW. And if it does, it'd be probably good to have the GL context current.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The suggested change, at least from my side, seems to work fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm wondering if it's guaranteed that no app code gets executed between APP_CMD_LOST_FOCUS and APP_CMD_INIT_WINDOW

I'm not sure about there being a guarantee, but it's one of the reasons I added _application_has_valid_surface - such that the user has some info to branch on.

@mosra mosra added this to the 2025.0a milestone Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants