Launch the signer intent on the main thread (relay AUTH crash) #5
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/auth-crash"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reported against 0.11.1 on 2026-08-06: "I get a crash when trying to AUTH to a relay." The video shows Amber's prompt for
bread.nostrsms.com, the user accepting, and Stash simply gone.Mechanism
ActivityResultLauncher.launch()is main-thread-only. Callers do not all arrive on the main thread:viewModelScope— main, fineMeasured on device with a thread-recording signer against the auth relay:
So
AmberSigneranswers AUTH by touching the Activity Result API from a background thread. Every Amber user meeting an auth-demanding relay hits it.Why the existing test never caught it
AuthRelayE2ETestcovers AUTH and has always passed — it signs with a local key and never reaches the launcher at all. The launcher is the part that has the thread requirement.The fix
Marshal to main inside
ActivityResultSignerLauncher, which owns the Activity Result contract, rather than at each call site — a future signer path would otherwise have to remember the rule on its own.Testing
SignerLaunchThreadE2ETestdrives the realActivityResultSignerLauncherfromDispatchers.Default(the AUTH shape, asserted as a precondition) with a fake innerActivityResultLauncherthat records the thread.Red-first, with the fix removed as a verified-landed mutation (1+/1−):
I first wrote this test with a fake
SignerIntentLauncher— which replaced the very class being fixed and so could not see it. Retargeted at the production class.Not a regression from the 0.11.1 speed work
NIP-42 support landed in
b90b53f(2026-08-04) and shipped in 0.11.0;SignerIntentLauncheris byte-identical between 0.11.0 and 0.11.1. AUTH-with-Amber has been broken since the feature shipped — the speed changes did not cause it.What is NOT proven
I have not reproduced the user's crash with real Amber — no signer app on the emulator. What is measured is the off-main call and the main-thread requirement; the causal link to their specific stack trace is inference. Their logcat would confirm it, and they offered one.
Closed because it has landed, not because it was dropped:
fix/auth-crashis an ancestor ofmain(ff39aee) via #6. Verified withgit merge-base --is-ancestor.The branch is deliberately left in place. The relay-AUTH crash is live on the published 0.11.0/0.11.1, and
mainnow also carries three features that have not been through a phone. If a 0.11.2 hotfix carrying only the crash fix turns out to be the right move, this one commit (0955d3d) is what it is built from — branch from the pre-mergemain(5290607) and take it. Closing the PR does not remove that option; deleting the branch would.Pull request closed