Repository navigation
Add non-panicking try_* variants of the context functions - #8
Open
LucaCappelletti94 wants to merge 8 commits into
Open
LucaCappelletti94 wants to merge 8 commits into
LucaCappelletti94 wants to merge 8 commits into
Conversation
LucaCappelletti94
marked this pull request as draft
September 27, 2026 19:42
LucaCappelletti94
force-pushed
the
upstream/ndk-context-non-panicking
branch
from
September 27, 2026 19:45
18bc6a2 to
9698d16
Compare
try_ variants of the context functions
LucaCappelletti94
marked this pull request as ready for review
September 27, 2026 19:54
This was referenced Sep 27, 2026
try_ variants of the context functionstry_* variants of the context functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #6, so only the last commit belongs here.
Adds
try_android_context(),try_initialize_android_context()andtry_release_android_context(), as asked in #3, #4, #5 and rust-mobile/ndk#517. Crates currently probe the context withcatch_unwind(rama, netdev, tauri-plugin-blec) or wrap the initialisation in it (iotzio, jni-min-helper), which cannot catch anything underpanic = "abort". Dioxus guards its call with aOncebecause a second initialisation aborts.A second initialisation keeps the first context and returns it. The existing functions keep their signatures and now wrap these, so a second
initialize_android_context()keeps the first context and panics withandroid context was already initialized.I am unsure whether it could be desirable to entirely remove the panicking function.