Skip to content

Commit

Permalink
fix(launch): change the launch timeout calculation for synchronous de…
Browse files Browse the repository at this point in the history
…livery to handle cases where the app start has completed before Bugsnag.start is called
  • Loading branch information
lemnik committed Sep 27, 2024
1 parent c5a1689 commit 971af4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

* Sending startup crashes synchronously now uses a flexible timeout so that apps with slower startups don't ANR
[#2075](https://github.com/bugsnag/bugsnag-android/pull/2075)
[#2080](https://github.com/bugsnag/bugsnag-android/pull/2080)

## 6.7.0 (2024-08-08)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ internal class EventStore(
// have blocked the main thread before this code is reached.
val currentStartupDuration =
SystemClock.elapsedRealtime() - ForegroundDetector.startupTime
val timeout = LAUNCH_CRASH_TIMEOUT_MS - currentStartupDuration
var timeout = LAUNCH_CRASH_TIMEOUT_MS - currentStartupDuration

if (timeout > 0) {
future.get(timeout, TimeUnit.MILLISECONDS)
} else {
logger.d(
"Startup delivery timeout has been exceeded, " +
"launch crashes will be delivered asynchronously"
)
if (timeout <= 0) {
// if Bugsnag.start is called too long after Application.onCreate is expected to
// have returned, we use a full LAUNCH_CRASH_TIMEOUT_MS instead of a calculated one
// assuming that the app is already fully started
timeout = LAUNCH_CRASH_TIMEOUT_MS
}

future.get(timeout, TimeUnit.MILLISECONDS)
} catch (exc: InterruptedException) {
logger.d("Failed to send launch crash reports within timeout, continuing.", exc)
} catch (exc: ExecutionException) {
Expand Down

0 comments on commit 971af4f

Please sign in to comment.