Skip to content

fix(trace): set the Bugsnag user off the main thread - #1787

Merged
bmc08gt merged 1 commit into
code/cashfrom
fix/bugsnag-set-user-off-main
Oct 15, 2026
Merged

bmc08gt merged 1 commit into
code/cashfrom
fix/bugsnag-set-user-off-main

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Creating an account froze the UI in two Bugsnag ANRs on 4804 (6acec70a, 6acfc33f). UserManager sets the trace user id on the main thread, and TraceInitializer's listener passed it straight to Bugsnag.setUser. That call waits on the NDK plugin's state lock, which the "Bugsnag Worker" thread held in NativeBridge.synchronizeState while it waited on DeviceDataCollector.calculateFreeDisk.

The listener now hands each id to ForwardUserId, which calls Bugsnag.setUser from a background dispatcher limited to one task at a time, so a sign-out followed by a sign-in still reaches Bugsnag in that order. A slow Bugsnag lock can still delay the user id, but it no longer blocks the UI.

ForwardUserIdTest covers the ordering and that the forward runs off the calling thread.

Account creation sets the trace user id on the main thread, and the
listener called Bugsnag.setUser there. That call waits on the NDK
plugin's state lock, which Bugsnag's worker can hold in
synchronizeState while it waits on calculateFreeDisk, so the UI froze
until the worker let go (Bugsnag 6acec70adbd69358a81f2824, 6acfc33f,
both on 4804).

User id changes now go to Bugsnag one at a time on a background
dispatcher, in the order they were made.
@bmc08gt bmc08gt self-assigned this Oct 15, 2026
@github-actions github-actions Bot added the type: fix Bug fix label Oct 15, 2026
@bmc08gt
bmc08gt merged commit 114f7b6 into code/cash Oct 15, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant