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
Android RecreationAttempt
on Activity reopen
#3325
Comments
See #2344 (comment), which points out how this can happen on Android. But generally speaking this is the intended behavior by Winit, you just have to figure out how to avoid having to recreate the event loop. Let us know if this solves your problem! |
I read that conversation and it doesn't really say how to solve the issue, I've tried various approaches but haven't yet had success. Is there any example Android app that has this bug solved? Here are my attempts:
I think that the "best" approach would be to augment the second point, spawn a new common thread that manages the event loop and manually create a looper out of it. But it involves nasty low-level JNI calls and I'm not even sure if it would really work. TL;DR: I tried, but I have no idea on how to get it working without recreating the event loop or calling JNI stuff. |
Per the linked comment, after previously muddling along with these issues in Blindly recreating the loop when a new activity is created seems appalling. Consider activities to be analogous to Fwiw I think exiting the loop and returning out of We'll need to be more thoughtful how to handle that across the Then, we'll likely need a "New Window Created" event in This means that creating a new window in |
https://developer.android.com/guide/topics/manifest/activity-element#lmode may also be relevant here. |
I'm experiencing this issue with OpenXR on the Meta Quest. Your thread explains well why Meta discourages exit by the application and asks to systematically use the "Meta" button which pauses and allows Resume or Quit. |
When an android app calls
event_loop.exit()
the application exits, but if the application is opened again without closing it in the "recent apps" the EventLoop creation will fail with aRecreationAttempt
error.Steps to reproduce
Reported error
called `Result::unwrap()` on an `Err` value: RecreationAttempt
Repo explaination
The repo linked in the "Steps to reproduce" section is a modified version of the one linked in the README android section.
I just updated the dependencies and linked
BrowserBack
toevent_loop.exit()
(that sems to be the logical key invoked when the android back button is pressed).Comment
The general problem seems to be that
android_main
can be called more than once without unloading and reloading the native library (ex. if we use an application with two interacting activities, say LoginActivity and GameActivity).The text was updated successfully, but these errors were encountered: