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

fix(android) fix app crash on restart due to Android context not released #860

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

Baiker000
Copy link
Contributor

This PR fixes a bug that causes the app to crash when it is restarted after any exit that triggers the onDestroy callback.

To reproduce this bug:

  • Build the latest tauri alpha android app using npm run tauri android build
  • Install and open the app
  • Press the back button to close the app
  • Reopen the app
  • The app will crash with RustStdoutStderr: assertion failed: previous.is_none()

The bug occurs because the Android context is not released when the app is destroyed, and the ndk-context crate asserts that the context is initialized only once.

This PR adds a call to release_android_context when the app is destroyed. This ensures that the Android context is freed and can be reinitialized on the next launch.

This PR is based on this commit from the ndk-glue repository.

@Baiker000 Baiker000 requested a review from a team as a code owner January 14, 2024 17:07
@wusyong wusyong merged commit 25a8836 into tauri-apps:dev Jan 15, 2024
9 checks passed
@github-actions github-actions bot mentioned this pull request Jan 10, 2024
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.

2 participants