on_exit
is not called when closing the app on Android when using eframe
#5492
Labels
bug
Something is broken
Describe the bug
On desktop, the
on_exit
function is called without issues when closing the app. But on Android, it is not called. This is an issue when using persistence, since thesave
function is also not called (this seems to be related assave
should be called just beforeon_exit
according to the docs) and therefore data is lost if for example some settings are changed and then the user closes the app before the next timedsave
function call.To Reproduce
Steps to reproduce the behavior:
cargo mobile init
, connect an Android device, allow USB debugging, and docargo mobile run
)adb logcat
to see the logs, you can either somehow filter for a specific app or just redirect it into a text file and search for the relevant logssaving!
being logged every 30 seconds (at least for me).saving!
log and close the app. Look for a newsaving!
log (this is why one should wait - to be certain if a given log is the timed one) and anexiting!
log. Neither of them exist, so the app was closed withoutsave
oron_exit
being called.Expected behavior
on_exit
andsave
are called fine when closing the app (ideallysave
would also be called when putting the app into background, i.e. "leaving it" as it may get killed by the OS later, but I am not sure if that would not emit theon_exit
-triggering event - this would require some testing)Smartphone (please complete the following information):
Additional context
When using winit, I was able to listen for an event that indicated that the app was being closed/put into the background, where I could call the
save
function manually. So I feel like it is not a general issue with Android emitting events weirdly or something and that if winit is able to handle it, then eframe should also be.The text was updated successfully, but these errors were encountered: