Skip to content

Commit

Permalink
Rework the background task service shutdown procedure to give more he…
Browse files Browse the repository at this point in the history
…adroom against the 5s ANR timeout
  • Loading branch information
kstenerud committed Mar 15, 2022
1 parent 705e1f0 commit cdbc9f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Bug fixes

* Fixed an issue where an uncaught exeption on the main thread could in rare cases trigger an ANR.
[#1624](https://github.com/bugsnag/bugsnag-android/pull/1624)

* Fix inconsistencies in stack trace quality for C/C++ events. Resolves a few
cases where file and line number information was not resolving to the correct
locations. This change may result in grouping changes to more correctly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,13 @@ internal class BackgroundTaskService(
internalReportExecutor.shutdownNow()
defaultExecutor.shutdownNow()

// shutdown the error/session executors first, waiting for existing tasks to complete.
// If a request fails it may perform IO to persist the payload for delivery next launch,
// which would submit tasks to the IO executor - therefore it's critical to
// shutdown the IO executor last.
// Wait a little while for these ones to shut down
errorExecutor.shutdown()
sessionExecutor.shutdown()
ioExecutor.shutdown()

errorExecutor.awaitTerminationSafe()
sessionExecutor.awaitTerminationSafe()

// shutdown the IO executor last, waiting for any existing tasks to complete
ioExecutor.shutdown()
ioExecutor.awaitTerminationSafe()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class LaunchCrashDeliveryTest {
payload: EventPayload,
deliveryParams: DeliveryParams
): DeliveryStatus {
Thread.sleep(3000)
Thread.sleep(2000)
count.getAndIncrement()
return DeliveryStatus.DELIVERED
}
Expand Down

0 comments on commit cdbc9f6

Please sign in to comment.