mirror of
https://github.com/Monkopedia/rouse-context.git
synced 2026-11-01 04:00:24 +00:00
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> |
||
|---|---|---|
| .. | ||
| debug | ||
| foss | ||
| main | ||
| release/java/com/rousecontext/app/debug | ||
| test | ||
| testFoss/java/com/rousecontext/app | ||
| testGoogle/java/com/rousecontext/app | ||