Title: AppStartExtension lock-ordering deadlock blocks the main thread during app start (ANR) · Issue #6008 · getsentry/sentry-java · GitHub
Open Graph Title: AppStartExtension lock-ordering deadlock blocks the main thread during app start (ANR) · Issue #6008 · getsentry/sentry-java
X Title: AppStartExtension lock-ordering deadlock blocks the main thread during app start (ANR) · Issue #6008 · getsentry/sentry-java
Description: AppStartExtension holds its own lock while calling finish() on the extended span (finishExtendedAppStart) and on the standalone app.start transaction (finishTransaction). Finishing captures the transaction synchronously — SentryTracer.fi...
Open Graph Description: AppStartExtension holds its own lock while calling finish() on the extended span (finishExtendedAppStart) and on the standalone app.start transaction (finishTransaction). Finishing captures the tra...
X Description: AppStartExtension holds its own lock while calling finish() on the extended span (finishExtendedAppStart) and on the standalone app.start transaction (finishTransaction). Finishing captures the tra...
Opengraph URL: https://github.com/getsentry/sentry-java/issues/6008
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AppStartExtension lock-ordering deadlock blocks the main thread during app start (ANR)","articleBody":"`AppStartExtension` holds its own lock while calling `finish()` on the extended span (`finishExtendedAppStart`) and on the standalone `app.start` transaction (`finishTransaction`).\n\nFinishing captures the transaction **synchronously** — `SentryTracer.finish()` calls `scopes.captureTransaction(...)` on the calling thread, which runs `PerformanceAndroidEventProcessor.process()`. That processor takes its own lock and then calls back into `AppStartExtension`. The two locks are therefore acquired in opposite orders:\n\n\u003c!-- linear:table-colwidths:200,200 -->\n| Side | Where, at `cc59f486da` |\n| -- | -- |\n| extension lock → processor lock | `AppStartExtension.finishExtendedAppStart():111` and `finishTransaction():148` hold the lock across `span.finish()` / `transaction.finish()`, which capture re-entrantly |\n| processor lock → extension lock | `PerformanceAndroidEventProcessor.process()` acquires its lock at :82, then calls `extension.isExtended()` at :112 and `getExtendedEndTime()` at :113 inside it |\n\n## Impact\n\n`sdk-crashes-java`, last 90 days — ANR events with `AppStartExtension` on the stack:\n\n\u003c!-- linear:table-colwidths:200,200,200 -->\n| Release | ANR events | Customer projects |\n| -- | -- | -- |\n| 8.48.0 | 13 | 4 |\n| 8.49.0 | 751 | 4 |\n| 8.50.0 / 8.50.1 | 4 | 3 |\n| 8.51.0 | 16 | 6 |\n\n**Blocked waiting for the lock** — SDK-CRASHES-JAVA-5MBP, main thread, foreground app start, SDK 8.49.0:\n\n```\nActivityLifecycleIntegration.onFirstFrameDrawn(:812)\n ActivityLifecycleIntegration.finishAppStartSpan(:992)\n AppStartExtension.finishTransaction(AppStartExtension.java:148)\n AutoClosableReentrantLock.acquire(:37)\n ReentrantLock.lock(:323) \u003c- parked\n```\n\nIn the `8.49.0` tag, `AppStartExtension.java:148` is the `lock.acquire()` at the top of `finishTransaction`.\n\n**Holding the lock** — SDK-CRASHES-JAVA-5MEQ, 87 occurrences:\n\n```\nAppStartMetrics.lambda$scheduleHeadlessAppStartCheckOnMain$0\n AppStartExtension.finishTransaction\n SentryTracer.finish -> SentryTracer.finish\n```\n\nThese events contain only the main thread, so the full cycle is not directly visible. What is confirmed is the mechanism: the extension lock held across `transaction.finish()`, with real users' main threads blocking on it until the OS files an ANR. Whether a given event is a permanent deadlock or contention that merely exceeded the ANR threshold cannot be distinguished from these traces — both are addressed by the same fix.\n\n## Introduced by\n\nPR #5604 (`feat(extend-app-start): App start extension API`), commit `cc59f486da`, merged 2026-07-07. Both halves of the cycle landed in that one commit. First released in **8.48.0**, which is exactly where the ANR series begins.\n\n## Fix\n\nPR #6007 reads the fields under the lock and performs the finish outside it, so the extension never holds its lock across a call that re-enters the SDK. Span and transaction finishing are idempotent (`Span.finish` guards with a CAS), so racing callers are safe.\n\nFollow-up worth considering: `extendAppStart()` still calls the listener (and a user-supplied logger) under the lock. That path does not capture, so it is not part of this cycle.","author":{"url":"https://github.com/runningcode","@type":"Person","name":"runningcode"},"datePublished":"2026-08-26T14:33:56Z","url":"https://github.com/getsentry/sentry-java/issues/6008"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c553dfbf-f1cd-9b80-bc56-0abdce93acc1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8CC0:2D0B15:3CCACA:538C79:6B046DB0 |
| html-safe-nonce | 57f6a63607560092324bd28c106c03aaa9aed82bfde736b37122cc6c2aab87be |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0MwOjJEMEIxNTozQ0NBQ0E6NTM4Qzc5OjZCMDQ2REIwIiwidmlzaXRvcl9pZCI6IjU4OTQxODQ1OTIyMDU5NjY3NjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4a66b7b6016fafa5f20aab6ee7656a7cc2f8d9b5f727168399e57ca743bd5a71 |
| hovercard-subject-tag | issue:5258266010 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-java/6008/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b6f7aefd264d313f067f23d5ca7fa4e0820af3136d2722fe414291963f87506f/getsentry/sentry-java/issues/6008 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b6f7aefd264d313f067f23d5ca7fa4e0820af3136d2722fe414291963f87506f/getsentry/sentry-java/issues/6008 |
| og:image:alt | AppStartExtension holds its own lock while calling finish() on the extended span (finishExtendedAppStart) and on the standalone app.start transaction (finishTransaction). Finishing captures the tra... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | runningcode |
| hostname | github.com |
| expected-hostname | github.com |
| None | ae8802492f12d3ba4f6b0d814054e617a2a5616b6327bf8555c10cd5b0dc2a6f |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-java git https://github.com/getsentry/sentry-java.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3368190 |
| octolytics-dimension-repository_nwo | getsentry/sentry-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3368190 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cfb5f24c6e01d85f70804652a5107e5cac03a161 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width