fix(android): keep Tor bootstrap alive after the unlock activity dies #116

Merged
sirius merged 1 commit from feat/android-bootstrap-survives-ui into main 2026-09-19 01:51:39 +00:00
Owner

Summary

Unlock showed the Publishing onion spinner, then the activity died and the lock screen came back idle. Tor never finished.

Cause: openWire ran on viewModelScope, and the keep-alive service refused to start until NodeHost.current() was set (only after publish). Closing the activity cancelled bootstrap. There was no FGS yet, so Android could also kill the process.

Fix

  • Run openWire on NodeHost's process-wide IO scope so a ViewModel cancel does not abort Tor.
  • keepAliveHasWork(nodeOpen, bootstrapInFlight) - in-flight bootstrap counts as work.
  • Start the foreground service on the Open tap (noteOpening first so the service does not stopSelf in the gap).
  • Re-attach: if bootstrap is still running, a new ViewModel shows Opening and awaitOpen().
  • IME Go/Done submits the same unlock path as the Open button (keyboard used to dismiss without calling unlock).

Tests

  • KeepAlivePolicyTest - bootstrap-in-flight is work; locked+idle is not.
  • UnlockSubmitTest - empty passphrase does not submit; remember flag is preserved.

:app:testDebugUnitTest was not run here because it rebuilds the cuprate-daemon NDK graph. Policy tests are pure JVM.

Device check

After Open: persistent notification OnionWire is starting, spinner survives leaving the activity. First publish still takes minutes. Lock still cancels bootstrap.

## Summary Unlock showed the Publishing onion spinner, then the activity died and the lock screen came back idle. Tor never finished. Cause: `openWire` ran on `viewModelScope`, and the keep-alive service refused to start until `NodeHost.current()` was set (only after publish). Closing the activity cancelled bootstrap. There was no FGS yet, so Android could also kill the process. ## Fix - Run `openWire` on NodeHost's process-wide IO scope so a ViewModel cancel does not abort Tor. - `keepAliveHasWork(nodeOpen, bootstrapInFlight)` - in-flight bootstrap counts as work. - Start the foreground service on the Open tap (`noteOpening` first so the service does not stopSelf in the gap). - Re-attach: if bootstrap is still running, a new ViewModel shows Opening and `awaitOpen()`. - IME Go/Done submits the same unlock path as the Open button (keyboard used to dismiss without calling unlock). ## Tests - `KeepAlivePolicyTest` - bootstrap-in-flight is work; locked+idle is not. - `UnlockSubmitTest` - empty passphrase does not submit; remember flag is preserved. `:app:testDebugUnitTest` was not run here because it rebuilds the cuprate-daemon NDK graph. Policy tests are pure JVM. ## Device check After Open: persistent notification **OnionWire is starting**, spinner survives leaving the activity. First publish still takes minutes. Lock still cancels bootstrap.
fix(android): keep Tor bootstrap alive after the unlock activity dies
Some checks failed
android-ci / android (pull_request) Has been cancelled
396e468f1a
Open set Phase.Opening then ran openWire on viewModelScope, and the
keep-alive refused to start until Wire existed. Closing the activity
cancelled bootstrap, so the spinner vanished and the lock screen came
back idle. Run openWire on NodeHost's process scope, start the FGS on
the Open tap, and treat in-flight bootstrap as keep-alive work. IME Go
also submits unlock the same way as the Open button.
sirius merged commit e3fb723a91 into main 2026-09-19 01:51:39 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!116
No description provided.