Skip to content

[Due for payment 2026-09-30] [Sentry: APP-JZ] Android OldDot crash — RxJava UndeliverableException from reactivelocation2 GoogleAPIConnectionSuspendedException #99852

Closed

Description

@mountiny

Sentry

https://expensify.sentry.io/issues/APP-JZ

Impact (snapshot at filing)

  • Users (total since first seen): 79
  • Events: 298
  • Users (last 14d): 18
  • First seen: 2025-11-04
  • Last seen: ongoing
  • Platform: Android HybridApp, OldDot side (org.me.mobiexpensifyg)
  • App version(s): 9.4.23-0, 9.4.52-11, 9.4.53-10, 9.4.57-3, 9.4.59-5, 9.4.60-2
  • Mechanism: UncaughtExceptionHandler
  • Level: fatal
  • Culprit: io.reactivex.plugins.RxJavaPlugins in onError

Error

UndeliverableException: The exception could not be delivered to the consumer because it has already
canceled/disposed the flow or the exception has nowhere to go to begin with.
| pl.charmas.android.reactivelocation2.observables.GoogleAPIConnectionSuspendedException

Stack trace (top frames)

io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
io.reactivex.internal.operators.observable.ObservableCreate$CreateEmitter.onError(ObservableCreate.java:73)
pl.charmas.android.reactivelocation2.observables.BaseObservableOnSubscribe$ApiClientConnectionCallbacks.onConnectionSuspended(BaseObservableOnSubscribe.java:105)
com.google.android.gms.common.internal.zan.zad(play-services-base@@18.9.0:8)
com.google.android.gms.common.api.internal.zaaz.zac(play-services-base@@18.9.0:11)
com.google.android.gms.common.api.internal.zaag.zah(play-services-base@@18.9.0:2)
com.google.android.gms.common.api.internal.zabd.onConnectionSuspended(play-services-base@@18.9.0:2)
android.os.Handler.dispatchMessage(Handler.java:132)
android.os.Looper.loop(Looper.java:392)
android.app.ActivityThread.main(ActivityThread.java:10343)

Caused by: pl.charmas.android.reactivelocation2.observables.GoogleAPIConnectionSuspendedException

Suspected cause

Play Services suspends the location API connection after the RxJava observable has already been
disposed. reactivelocation2 calls onError on a dead emitter, RxJava has nowhere to deliver it, so
it wraps the cause in UndeliverableException and rethrows it as fatal through the global
UncaughtExceptionHandler on the main looper. The app dies.

Event context shows in_foreground: false, so this kills the app while it sits in the background,
which the user then experiences as a silent restart.

Two things to fix:

  1. Install a global RxJavaPlugins.setErrorHandler that logs and swallows UndeliverableException
    instead of letting it reach the default handler. This is the standard remedy the RxJava wiki link
    in the message itself recommends.
  2. Dispose the location subscription when the hosting component stops, so a suspended connection has
    no dead emitter to signal in the first place.

Reproduction

Unknown — see the events linked from the Sentry issue. Losing Play Services connectivity while a
location observable is active and the app is backgrounded is the trigger. Affected devices are recent
and high end (Samsung SM-S948U on Android 16), so this is not a low-end device problem.

Related

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. Julesssss commented on Aug 31, 2026

    @Julesssss
    Contributor

    @MelvinBot investigate this

  2. MelvinBot commented on Aug 31, 2026

    @MelvinBot
    Contributor

    Issue Analysis

    This crash cannot be fixed in Expensify/App. The faulting code ships from Expensify/Mobile-Expensify (OldDot Android). App contains zero RxJava and zero ReactiveLocation — verified across all 144 Gradle files plus a full-tree grep for RxJavaPlugins, including node_modules. App's only location stack is expo-location → play-services-location:21.0.1 (FusedLocationProviderClient), which has no reactive layer. In HybridApp builds the Android sourceDir is the submodule, not android/ (rock.config.mjs:22). This needs an internal engineer with Mobile-Expensify access.

    Root cause: the ReactiveLocation library treats a temporary Play Services suspension as a terminal Rx error. onConnectionSuspended calls emitter.onError(GoogleAPIConnectionSuspendedException); the subscriber is already disposed (app backgrounded), so RxJava wraps it in UndeliverableException, finds no global error handler, and hands it to the thread's UncaughtExceptionHandler → process death.

    Three things worth adding to the plan in the description

    1. The :105 frame says you're on library version 2.0, not 2.1. In 2.1, line 105 is an isDisposed() guard and line 106 is the throw. In 2.0 line 105 is the unguarded emitter.onError. Check the resolved dependency version first (R8 line mapping can shift frames, so confirm against Gradle, not the trace alone).

    2. There is a one-line upstream fix the description misses. ReactiveLocationProviderConfiguration.setRetryOnConnectionSuspended(true) — added in 2.1 by PR #165 to close #154, defaults to false, and is absent from the README. It composes a .retry() on GoogleAPIConnectionSuspendedException so the stream resubscribes instead of dying. This fixes the root cause; the RxJavaPlugins.setErrorHandler in the description only suppresses the symptom.

    3. Suggestion 2 in the description ("dispose on stop") won't work alone — it is what creates the race. onConnectionSuspended arrives on the main looper while onStop() disposes on another thread. Even 2.1's guard is a non-atomic check-then-act, so disposal can land between the check and the emit. On 2.0 the guard doesn't exist at all.

    Recommended order: upgrade 2.0 → 2.1 and set setRetryOnConnectionSuspended(true), then add a filtering RxJavaPlugins.setErrorHandler (unwrap UndeliverableException, swallow only GoogleAPIConnectionSuspendedException, rethrow everything else) as a safety net. A blanket no-op handler would silently eat every undeliverable error process-wide, including NewDot's.

    Longer term, the library has been dead since 2017-12-20 (last commit, last Maven artifact, 27 open issues) and still uses the deprecated GoogleApiClient and pre-AndroidX android.support annotations. FusedLocationProviderClient has no ConnectionCallbacks at all, so migrating deletes this failure mode entirely. NewDot already runs a modern Fused stack in the same process.

    Supporting evidence

    Why the exception becomes fatal

    1. BaseObservableOnSubscribe wraps everything in Observable.create(...) and never calls emitter.serialize(), so the emitter is ObservableCreate.CreateEmitter.
    2. ObservableCreate.java:70-91 — tryOnError returns false when disposed, falling through to RxJavaPlugins.onError(t) at line 73. That matches the reported frame exactly.
    3. RxJavaPlugins.isBug() passes through only a fixed set (NullPointerException, IllegalStateException, …). GoogleAPIConnectionSuspendedException extends RuntimeException, so it gets wrapped in UndeliverableException.
    4. With errorHandler == null, uncaught() calls the thread's UncaughtExceptionHandler. The RxJava 2 wiki states this directly: "Android is more strict and terminates the application in such uncaught exception cases."

    Why it skews to background (in_foreground: false)

    GoogleApiClient holds a bound-service connection to the Play Services process. CAUSE_SERVICE_DISCONNECTED = 1 means that process was killed — LMK pressure, a Play Services self-update, or the system reclaiming the binding. Android 14 cached-process enforcement makes both halves more likely at once: the app is more likely to be cached/reclaimed, and it is simultaneously disposing subscriptions in onStop(). I found no Android 15/16 change that specifically raises suspension frequency, so treat the "recent Android version" framing as unconfirmed — the API 34 change is the documented driver. An API-level histogram on the Sentry events would settle it.

    Note that GoogleAPIConnectionSuspendedException carries no message and only exposes getErrorCause(), so the crash reports won't show whether the cause was CAUSE_SERVICE_DISCONNECTED (1) or CAUSE_NETWORK_LOST (2).

    Prior art — this exact trace, already reported upstream

    • #175 (closed) — byte-for-byte the same stack at BaseObservableOnSubscribe.java:105. Maintainer: "Should be fixed in 2.1." That claim is overstated; 2.1 only narrows the race.
    • #171, #169, #123 — same pattern, other subscribers / RxJava 1.
    • #173, #177, #179 — still open: migrate off GoogleApiClient, FusedLocationProviderApi deprecated, Oreo background limits.
    • #198 — "is this library still maintained?", open since 2018, unanswered by the author.

    Why an OldDot crash lands in an App Sentry project

    The Sentry Android SDK installs a process-wide UncaughtExceptionHandler, so a fatal thrown on an OldDot RxJava thread inside org.me.mobiexpensifyg reports into APP-JZ regardless of which repo shipped the code. Events are tagged build_type=hybrid at src/setup/telemetry/setupSentry.ts:88. Sentry attribution here is not evidence of App ownership. If any APP-JZ event shows build_type=standalone, that would contradict this analysis and is worth re-checking.

    Alternatives considered and ruled out

    • A NewDot/expo-location regression — ruled out: expo-location uses FusedLocationProviderClient, which has no ConnectionCallbacks and cannot produce this frame. App's own GpsTripService.kt only posts a foreground-service notification and calls no location API.
    • A transitive RxJava pull-in on the App side — ruled out by the exhaustive Gradle scan above.
    • An existing error handler misbehaving — ruled out for App (zero RxJavaPlugins occurrences). Unverified for Mobile-Expensify; if one is already installed there, these crashes are arriving via a different path and the analysis needs revisiting.

    Confidence: medium-high. The mechanism is confirmed against upstream library and RxJava source. Not verified (needs Mobile-Expensify access): the pinned library version, whether setRetryOnConnectionSuspended is already set, and whether any error handler is already installed.

    Related issues: only the parent tracker #91302, already linked. No duplicates found.


    Next Steps: This needs an internal engineer with Expensify/Mobile-Expensify access — I can't open a PR against it. Reply with @MelvinBot <your feedback> to refine this analysis.


    view run

  3. GCyganek commented on Sep 1, 2026

    @GCyganek
    Contributor

    @MelvinBot assign me

  4. MelvinBot commented on Sep 1, 2026

    @MelvinBot
    Contributor

    🤖 Assigned GCyganek to this issue.

    Heads up: the fix for this crash lives in Expensify/Mobile-Expensify (OldDot Android), not this repo — see the analysis above for the recommended order of changes.


    view run

  5. melvin-bot commented on Sep 4, 2026

    @melvin-bot

    @mkhutornyi Whoops! This issue is 2 days overdue. Let's get this updated quick!

  6. melvin-bot commented on Sep 5, 2026

    @melvin-bot

    @mkhutornyi Whoops! This issue is 2 days overdue. Let's get this updated quick!

  7. 13 remaining items

  8. mkhutornyi commented on Sep 30, 2026

    @mkhutornyi
    Contributor

    yes sorry it meant Awaiting Payment

  9. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed
    ReviewingHas a PR in review
    on Sep 30, 2026
  10. changed the title [-][Sentry: APP-JZ] Android OldDot crash — RxJava UndeliverableException from reactivelocation2 GoogleAPIConnectionSuspendedException[/-] [+][Due for payment 2026-09-30] [Sentry: APP-JZ] Android OldDot crash — RxJava UndeliverableException from reactivelocation2 GoogleAPIConnectionSuspendedException[/+] on Sep 30, 2026
  11. melvin-bot commented on Sep 30, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  12. melvin-bot commented on Oct 1, 2026

    @melvin-bot

    Payment Summary

    • Contributor: @GCyganek does not require payment (Contractor)
    • Reviewer: @mkhutornyi owed $175 via NewDot

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  13. mallenexpensify commented on Oct 3, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @mkhutornyi due $250 via NewDot

  14. trjExpensify commented on Oct 15, 2026

    @trjExpensify
    Contributor

    approved $250 for @mkhutornyi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2EngineeringImprovementItem broken or needs improvement.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions