-
Notifications
You must be signed in to change notification settings - Fork 920
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
Cross-platform consistency for ApplicationHandler::suspended/resumed()
#3779
Comments
@daxpedda just in case; you want context after #3765, i.e. knowing that we moved surface lifetime away from the From the look and sound of it you'll want Note that there are are differences between these and These lifecycle events are already available in winit/src/platform_impl/android/mod.rs Lines 223 to 243 in 39a7d5b
|
From the documentation I can't seem to be able to definitely say that all code execution is halted after
Seems similar to iOS's
Would you like to make a PR implementing those events? |
Android doesn't have a concept of this "code stop" that other platforms seem to have. As we have a separate thread where we create our own looper, and configure how often it should wake via - for example - These lifecycle events more so tell you what is going on with the visible portion and user interaction of your app. However, I won't be surprised if Android has mechanisms in place to kill or throttle long-running app processes if no
Android also has (un)focused events to make things extra complicated :/ These don't seem to be keyed off of the native surface though, confusingly. Opened a PR at #3786 but my time is pretty much up so I'll leave documentation for some other time. What's worse, we seem to be having some weird hypothetical |
If the application is simple hidden, but still running the |
This is where Android recommends you to save/restore state like the other platforms, though, but you're right that it seems weird. |
Unfortunately the behavior between Android, iOS and Web doesn't match exactly, so this will require some research and figuring out exactly how we want to expose this to the user.
Web
Web currently implements this via
pagehide
andpageshow
. Which forsuspended()
means the application is being navigated away from and is being stored in the B/F Cache and forresumed()
means that the page has been restored.Its important to note that between
suspended()
andrestored()
no user code can be executed and gettingrestored()
isn't actually promised.There is also the Page Lifecycle API, currently only implemented in Chrome, which lets us also detect if the application was frozen by the browser.
iOS
@madsmtm please feel free to work out this section and correct me.
applicationDidEnterBackground
could be used to detect when iOS is telling the application to stop doing anything. This doesn't mean that any code execution will be suspended immediately but "probably soon".This however is currently not implemented correctly and instead iOS will call
ApplicationHandler::suspended()
when the application is running in the background viaapplicationWillResignActive
, which should probably beWindowEvent::Focused(false)
instead.Presumably its also guaranteed that the application will be woken up before being actually closed (?).
Android
@MarijnS95 your input would be greatly appreciated here.
Android does currently not implement
ApplicationHandler::suspended/resumed()
The text was updated successfully, but these errors were encountered: