Title: Permanent app freeze on foreground: main thread blocks in ReplayIntegration.start while replay executor hangs in MediaCodec.dequeueOutputBuffer holding the replay lock (HyperOS 3 / Android 16) · Issue #5870 · getsentry/sentry-java · GitHub
Open Graph Title: Permanent app freeze on foreground: main thread blocks in ReplayIntegration.start while replay executor hangs in MediaCodec.dequeueOutputBuffer holding the replay lock (HyperOS 3 / Android 16) · Issue #5870 · getsentry/sentry-java
X Title: Permanent app freeze on foreground: main thread blocks in ReplayIntegration.start while replay executor hangs in MediaCodec.dequeueOutputBuffer holding the replay lock (HyperOS 3 / Android 16) · Issue #5870 · getsentry/sentry-java
Description: Integration sentry-android (via sentry-flutter) Java Version N/A (Flutter app) Version sentry-android 8.49.0 (bundled by sentry_flutter 9.25.0) Steps to Reproduce Device: Xiaomi 14 (houji), HyperOS 3 / Android 16, build OS3.0.303.0.WNCCN...
Open Graph Description: Integration sentry-android (via sentry-flutter) Java Version N/A (Flutter app) Version sentry-android 8.49.0 (bundled by sentry_flutter 9.25.0) Steps to Reproduce Device: Xiaomi 14 (houji), HyperOS...
X Description: Integration sentry-android (via sentry-flutter) Java Version N/A (Flutter app) Version sentry-android 8.49.0 (bundled by sentry_flutter 9.25.0) Steps to Reproduce Device: Xiaomi 14 (houji), HyperOS...
Opengraph URL: https://github.com/getsentry/sentry-java/issues/5870
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Permanent app freeze on foreground: main thread blocks in ReplayIntegration.start while replay executor hangs in MediaCodec.dequeueOutputBuffer holding the replay lock (HyperOS 3 / Android 16)","articleBody":"### Integration\n\nsentry-android (via sentry-flutter)\n\n### Java Version\n\nN/A (Flutter app)\n\n### Version\n\nsentry-android 8.49.0 (bundled by sentry_flutter 9.25.0)\n\n### Steps to Reproduce\n\nDevice: Xiaomi 14 (houji), HyperOS 3 / Android 16, build `OS3.0.303.0.WNCCNXM` (latest stable).\n\nReplay config:\n\n```dart\noptions.replay.onErrorSampleRate = 1.0; // buffer mode for all sessions\noptions.replay.sessionSampleRate = 0.1;\n```\n\n1. Use the app normally, then send it to background (screen off or app switch).\n2. HyperOS 3 aggressively freezes the cached process (cgroup freezer). This appears to leave the in-flight `MediaCodec` session in a broken state.\n3. Return to the app.\n\n### Expected Result\n\nApp resumes normally. A hung replay video encoder must never block the main thread.\n\n### Actual Result\n\nThe app is **permanently frozen**: no touch, no back gesture, window never gains focus. The OS records an ANR with subject *\"Input dispatching timed out (Application does not have a focused window)\"*. Only force-stop recovers.\n\nIt is a classic lock-ordering hazard rather than a device quirk:\n\n**Thread 1 —** `SentryReplayIntegration-0` is stuck forever inside `MediaCodec.dequeueOutputBuffer` (native `ALooper::awaitResponse` never returns after the process was frozen mid-encode), while **holding the replay lock**:\n\n```\n\"SentryReplayIntegration-0\" daemon prio=5 tid=4 Native\n native: #03 pc 0001f2c8 libstagefright_foundation.so (android::ALooper::awaitResponse+284)\n native: #04 pc 0002432c libstagefright_foundation.so (android::AMessage::postAndAwaitResponse+452)\n native: #05 pc 001d6390 libstagefright.so (android::MediaCodec::dequeueOutputBuffer+436)\n at android.media.MediaCodec.native_dequeueOutputBuffer(Native method)\n at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:4308)\n at io.sentry.android.replay.video.SimpleVideoEncoder.drainCodec(SimpleVideoEncoder.kt:218)\n at io.sentry.android.replay.video.SimpleVideoEncoder.release(SimpleVideoEncoder.kt:288)\n at io.sentry.android.replay.ReplayCache.createVideoOf(ReplayCache.kt:212)\n at io.sentry.android.replay.capture.CaptureStrategy$Companion.createSegment(CaptureStrategy.kt:92)\n at io.sentry.android.replay.capture.BaseCaptureStrategy.createSegmentInternal(BaseCaptureStrategy.kt:142)\n at io.sentry.android.replay.capture.BufferCaptureStrategy.createCurrentSegment$lambda$5(BufferCaptureStrategy.kt:241)\n at io.sentry.android.replay.util.ReplayExecutorService.submit$lambda$0(ReplayExecutorService.kt:26)\n```\n\n**Thread 2 —** `main` then blocks forever acquiring that same lock during activity start, killing the whole app:\n\n```\n\"main\" prio=5 tid=1 Waiting\n at jdk.internal.misc.Unsafe.park(Native method)\n at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:322)\n at io.sentry.util.AutoClosableReentrantLock.acquire(AutoClosableReentrantLock.java:37)\n at io.sentry.android.replay.ReplayIntegration.start(ReplayIntegration.kt:171)\n at io.sentry.android.core.LifecycleWatcher.startSession(LifecycleWatcher.java:87)\n at io.sentry.android.core.LifecycleWatcher.onForeground(LifecycleWatcher.java:62)\n at io.sentry.android.core.AppState$LifecycleObserver.onStart(AppState.java:202)\n at androidx.lifecycle.ProcessLifecycleOwner.activityStarted$lifecycle_process_release(ProcessLifecycleOwner.kt:97)\n at android.app.Activity.performStart(Activity.java:9522)\n```\n\nA second full dump taken on another day shows the identical pair of stacks, so this is stable, not a one-off.\n\n### Impact\n\nOur analytics defined a \"frozen resume\" signature (app opened from background → zero further events → cold start within 120 s, i.e. user force-killed a dead app). Over 30 days:\n\n* Xiaomi devices on Android 16 (HyperOS 3): **6.3 %** of resumes (1785 sampled devices)\n* Xiaomi on Android ≤ 15: 0.3–0.6 %\n* Every other brand on Android 16: 0.3–0.8 %\n\nThe rate climbed week over week as the HyperOS 3 OTA rolled out, independent of our app releases. Battery-optimization whitelisting on the device does not prevent it. We had to disable Session Replay entirely to fix our users, confirmed by an affected user: freeze gone with a replay-disabled build.\n\n### Suggestions\n\n* `ReplayIntegration.start()` (and `stop`/`pause`/`resume`) run on the main thread via `LifecycleWatcher`; acquiring a lock there that can be held across a **blocking native** `MediaCodec` **call** turns any codec hang into a whole-app deadlock. Either move the work off the main thread, use `tryLock` with a short timeout, or never hold the replay lock across encoder drain/release.\n* `SimpleVideoEncoder.drainCodec` passes an infinite/long timeout to `dequeueOutputBuffer` in the `endOfStream`/release path; a bounded timeout with bail-out would make a dead codec merely drop a segment instead of hanging the executor while holding the lock.\n\nPossibly related: getsentry/sentry-java#5529 (encoder kept running while rate-limited).","author":{"url":"https://github.com/Adherentman","@type":"Person","name":"Adherentman"},"datePublished":"2026-07-30T05:32:21Z","url":"https://github.com/getsentry/sentry-java/issues/5870"}
| 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:41aa59fc-1f2a-6ce0-fe88-ffd45a4f25b5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA4E:DBD8D:624751:84EF32:6B04A86F |
| html-safe-nonce | 2a199ee0cd1827fb8c97db9199635ea808c65f0cb3b0e7764d9b0551f375777a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTRFOkRCRDhEOjYyNDc1MTo4NEVGMzI6NkIwNEE4NkYiLCJ2aXNpdG9yX2lkIjoiMzIwMDcxMTY5NjM3NzQ4OTUxOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | eabea0494fc4f21be3b85759b62faa02beaf5a7eb19cfd32c693469aecd8c66f |
| hovercard-subject-tag | issue:5016552359 |
| 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/5870/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2a014340067dd1e96d445f3649486228de885d39d510e4ef43bfe385bb721c22/getsentry/sentry-java/issues/5870 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2a014340067dd1e96d445f3649486228de885d39d510e4ef43bfe385bb721c22/getsentry/sentry-java/issues/5870 |
| og:image:alt | Integration sentry-android (via sentry-flutter) Java Version N/A (Flutter app) Version sentry-android 8.49.0 (bundled by sentry_flutter 9.25.0) Steps to Reproduce Device: Xiaomi 14 (houji), HyperOS... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Adherentman |
| hostname | github.com |
| expected-hostname | github.com |
| None | 188497a0f45a7aa8f7c866faa1950d1a7f8d82b59416adf549b222ad1d1dd19b |
| 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 | 557cfbac6cdb532730c95c90f2cefdc0c4128029 |
| 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