-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android P FileStore flush fix #319
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix makes sense. I have one concern about the test to ensure that the setup doesn't diverge from the what happens when real reports are captured.
val client = Bugsnag.getClient() | ||
val defaultLaunchThresholdMs = config.launchCrashThresholdMs | ||
config.launchCrashThresholdMs = Long.MAX_VALUE | ||
writeErrorToStore(client) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why force a manual write to the file cache rather than causing an error to happen via notify/crashing? It may mean requiring additional steps to prepare the scenario but seems closer to what would happen in the real world.
I've updated the mazerunner scenario to throw exceptions rather than writing errors to the store. I've also made a slight adjustment to the |
disableAllDelivery() | ||
|
||
if ("StartupCrash" == eventMetaData) { | ||
config.launchCrashThresholdMs = Long.MAX_VALUE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs some rethinking. I think you dont want to set config.launchCrashThresholdMs
in here. Also both of these crashes will count as launch crashes on subsequent boots.
Updated the docs to make it a bit clearer what this scenario is doing, and also updated mazerunner to disable delivery before Bugsnag is initialised. |
Reworked the test to better illustrate the user scenario here, and introduced a delay to separate the launch crash from a regular one. |
Internally FileStore retains a Collection of files which have previously been found for a request, to prevent duplicate reports being sent. This puts the onus on the calling code to cancel or delete the files once the request has been completed. This change ensures that the storedFiles are only requested once, then filtered for crashes on launch, and then all files are cancelled after a reasonable amount of time has passed regardless of delivery, which reset the internal FileStore state. flushAsync is then called which will flush any remaining reports that have not yet been delivered
59dbc09
to
eac2708
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works well 👍
changeset updated to address testing concerns
Build Windows test fixtures
Goal
Some unhandled error reports aren't being sent immediately on Android P and in situations with no connectivity.
Internally
FileStore
retains aCollection
of files which have previously been found for a request, to prevent duplicate reports being sent. This puts the onus on the calling code to cancel or delete the files once the request has been completed.This changeset ensures that these files are only requested once when calling
flushOnLaunch
, then cancels all files after delivery has taken place (successfully or not), which resets theFileStore
state.After this,
flushAsync
is then called, which will flush any remaining reports that have not yet been delivered.Changeset
Changed
FileStore
(see above description)Tests
Manual test on Android P simulator of unhandled crashes. Mazerunner scenario that fails prior to the applied fix.
Discussion
Alternative Approaches
The delivery/flushing code is fairly complex, it may be worth rethinking our implementation at some future point.
Linked issues
#318
Review
For the submitter, initial self-review:
For the pull request reviewer(s), this changeset has been reviewed for: