rouse-context/app/src
Jason Monk ac57bbb829
fix(foss): run UnifiedPush wake off the main thread to stop ANR (#506) (#511)
The UnifiedPush connector's MessagingReceiver is a plain BroadcastReceiver
whose onReceive calls onMessage synchronously on the main thread with no
goAsync(). onMessage routes into WakeDispatcher.dispatch ->
ProviderRegistry.awaitReadyBlocking(2000), which is explicitly documented
"MUST NOT be called from the main thread". On a cold-start wake (registry
not yet ready) that blocks the main thread for up to 2s and ANRs the
receiver; the foreground notification is then left stuck on "Connecting…"
even though the relay socket actually establishes. The google/FCM path is
immune because FirebaseMessagingService.onMessageReceived already runs off
the main thread.

Override onReceive to goAsync() and run the connector's full receive
sequence (super.onReceive -> onMessage/onNewEndpoint + acknowledge) on
Dispatchers.Default, launched on the injected app scope. The broadcast's
PendingResult is finished only AFTER that work completes, so the process
keepalive AND the broadcast's temporary foreground-service-start exemption
survive across the startForegroundService call inside WakeDispatcher --
finishing early would drop both and make startForegroundService throw
ForegroundServiceStartNotAllowedException. The whole sequence stays well
within the broadcast ANR window (awaitReadyBlocking caps at 2s).

The residual "defensive reconcile so a live socket is never shown as
Connecting…" acceptance item is split to #510 to keep this PR on the ANR
root cause; the symptom's root cause (a starved state-collector) is fixed
here. No user-facing flow change, so no docs/ux-decisions.md entry.

Co-authored-by: monkopedia-coder <monkopedia+coder@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 16:05:52 -04:00
..
debug Keypair device identity for foss flavor (#462) (#468) 2026-06-13 15:17:12 -04:00
foss fix(foss): run UnifiedPush wake off the main thread to stop ANR (#506) (#511) 2026-06-23 16:05:52 -04:00
google feat(foss): "Ignore daily time limit" toggle runs the tunnel FGS as specialUse (#509) 2026-06-23 12:49:08 -04:00
main feat(foss): "Ignore daily time limit" toggle runs the tunnel FGS as specialUse (#509) 2026-06-23 12:49:08 -04:00
release/java/com/rousecontext/app/debug Fix batch of UI issues: em-dashes, picker UX, button text, dead screens, app bar colors, icon 2026-04-07 13:40:14 -04:00
test feat(foss): "Ignore daily time limit" toggle runs the tunnel FGS as specialUse (#509) 2026-06-23 12:49:08 -04:00
testFoss/java/com/rousecontext/app fix(foss): run UnifiedPush wake off the main thread to stop ANR (#506) (#511) 2026-06-23 16:05:52 -04:00
testGoogle/java/com/rousecontext/app feat(foss): "Ignore daily time limit" toggle runs the tunnel FGS as specialUse (#509) 2026-06-23 12:49:08 -04:00