-
Notifications
You must be signed in to change notification settings - Fork 919
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
Add Foreground and Background events for iOS #2144
Conversation
Hmm, how does this differ from Also, this is something touching the public API, and will need discussion to figure out if it's relevant for at the very least a few platforms (see also the issues on Android: rust-windowing/raw-window-handle#84). |
It should probably be sent at the The purpose is to allow the app to switch from and to a low power state, rather than for tracking the user's focus. For iOS in particular, an app may not use the GPU while in the background, or it will be killed by the OS. |
The implementation looks good, though I must admit I have a hard time grokking the different lifecycle events - maybe we should have some documentation that directly maps Anyhow, I think these events belong in
Use-cases like these would be useful to have documented! |
Sorry, I don't have Android set up right now, and I can't justify putting the time in to properly test it. For someone who has It would probably also be best to do Android support in a separate PR. |
I will voice support for this PR. I work for a company planning on releasing a production product using winit on iOS, and we need this functionality to be able to properly handle backgrounding/foregrounding. |
Just to join the dots, this recent issue also looks to try and get a clearer understanding of lifecycle event handling within winit: #2185 I've been poking at the Android backend recently, but based on an alternative glue layer than ndk-glue. One thing I'd note re: Android is that technically the current Android backend drives Suspended/Resumed events according to when the OS destroys/creates the application's native window. This is technically not following the lifecycle events and I'm not even sure if it's specified anywhere when Android will destroy and apps window in relation to paused/stop events (so I could imagine it e.g. varies for different versions of Android). Since winit doesn't have more fine grained lifecycle events, it makes some sense that the backend would trigger a suspend based on when the native window is destroyed / created because it's so important that applications react to that on Android. The trade off though is that we're slightly misleading applications about their real lifecycle state. The detailed semantics of these different lifecycle stages are notably somewhat OS specific and I wonder what the best way of taking that into account would be. E.g. with the iOS the backend apps will currently be 'suspended' based on Something I raised in #2185 that could be relevent here is the question of whether we could get desktop platforms to also report positive edges of these lifecycle states (i.e. |
Superseded by #2980 |
CHANGELOG.md
if knowledge of this change could be valuable to users