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

Save state on suspend on Android #5599

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Conversation

Pandicon
Copy link

This pull request fixes a subset of #5492 by saving the application state when the suspended event is received on Android. This way even if the user exist the app and closes it manually right after changing some state, it will be saved since suspended gets fired when the app is exited. It does not fix the on_exit function not being fired - this seems to be a winit bug (the exiting function 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:

  • Leaving from the app to the home screen, then killing it from the "recent apps" menu
  • Leaving from the app to the "recent apps" menu and killing it
  • Restarting the device while the app was running

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.

  • I have followed the instructions in the PR template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant