Save state on suspend on Android and iOS#5601
Merged
emilk merged 12 commits intoemilk:masterfrom Jan 27, 2025
Merged
Conversation
Same as in the wgpu integration
Just to make sure CI passes
1 task
When doing a self-review I noticed it was me who added it. I am sure it was not added when implementing the saving logic for Android, seems like it was a remnant of the debugging stage. Saving still works without it.
|
Preview available at https://egui-pr-preview.github.io/pr/5601-save-app-on-suspend-on-android |
emilk
approved these changes
Jan 13, 2025
Owner
emilk
left a comment
There was a problem hiding this comment.
Looks good! Maybe remove or lower some of the logging
Ask to save on suspend on all platforms, always save even if the window does not exist
Contributor
Author
|
Looked at the comments and implemented the requested things. |
It is now used on all platforms
Owner
|
Needs to resolve merge conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request fixes a subset of #5492 by saving the application state when the
suspendedevent is received on Android. This way, even if the user exits the app and closes it manually right after changing some state, it will be saved sincesuspendedgets fired when the app is exited. It does not fix theon_exitfunction not being fired - this seems to be a winit bug (theexitingfunction in the winit application handler trait is not called on exit). Once it gets fixed, it may be possible to remove logic introduced by this PR (however, I am not sure how it would handle the app being killed by the system when in the background, that would have to be tested).I've tested the logic by:
In all of these instances, the state was saved (the last one being a pleasant surprise). It was tested on the repository mentioned in #5492 with my forked repository as the source for eframe (I unfortunately am not able to test it in a larger project of mine due to dependence on "3rd party" egui libraries (like egui_notify) which do not compile along with the master branch of eframe (different versions of egui), but I believe it should work in the same manner in all scenarios). Tests were conducted on a Galaxy Tab S8 running Android 14, One UI 6.1.1.
CI passed on my fork.