Repository navigation
fix(trace): set the Bugsnag user off the main thread - #1787
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Creating an account froze the UI in two Bugsnag ANRs on 4804 (6acec70a, 6acfc33f).
UserManagersets the trace user id on the main thread, andTraceInitializer's listener passed it straight toBugsnag.setUser. That call waits on the NDK plugin's state lock, which the "Bugsnag Worker" thread held inNativeBridge.synchronizeStatewhile it waited onDeviceDataCollector.calculateFreeDisk.The listener now hands each id to
ForwardUserId, which callsBugsnag.setUserfrom 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.ForwardUserIdTestcovers the ordering and that the forward runs off the calling thread.