Skip to content

android: exit event loop on MainEvent::Destroy - #4711

Open
jihaohaaaa wants to merge 1 commit into
rust-windowing:masterfrom
jihaohaaaa:fix/android-destroy-exit
Open

jihaohaaaa wants to merge 1 commit into
rust-windowing:masterfrom
jihaohaaaa:fix/android-destroy-exit

Conversation

@jihaohaaaa

Copy link
Copy Markdown

When an Android Activity is destroyed, Android dispatches an onDestroy lifecycle event. In the underlying glue layer (such as android-activity), this translates into MainEvent::Destroy.

Previously, winit only logged a TODO warning on MainEvent::Destroy without exiting the event loop. In environments where the host Activity or glue layer expects the native event loop to finish upon destruction (such as GameActivity's android_app_free(), which synchronously waits on pthread_cond_wait for the native thread to exit), this prevented run_app() from terminating and led to a deadlock in onDestroy.

This PR calls self.window_target.exit() and marks self.running = false on MainEvent::Destroy, allowing the event loop to exit cleanly and native resources to be dropped.

Supersedes #4697.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant