Conversation
App Hang Tracking V2 misreported non-rendering intervals, e.g. a CarPlay scene keeping the app alive while the phone is locked, as fully blocking app hangs. Verify main thread responsiveness with a V1-style heartbeat before trusting the delay of the ongoing, not yet rendered frame, and exclude time without frame delay data or with the app suspended from reported hang durations. Fixes getsentry#8317
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
V2 infers a blocked main thread purely from missing frames, so any interval where the app is
.activebut not rendering (CarPlay with the phone locked, a proximity-blanked screen during a call, a missedwillResignActive) gets reported as a fully-blocking hang. That's all four fingerprints in #8317, each with idle main-thread stacks.The fix adds the signal V1 already has: a main-queue heartbeat with an atomic tick counter. Only the synthesized ongoing-frame delay is gated on it... if the main thread is draining its queue and the frame gap exceeds the tracker's sleep interval, the run loop is turning but the display link isn't, so the app isn't rendering and that gap is ignored (for detection and the hang-stop check, via one shared helper). Recorded delayed frames stay fully trusted since they actually rendered, so genuine non-fully-blocking detection is unaffected.
Durations get the same treatment as the existing background exclusion: time without frame delay data (frames tracker paused) and oversleep from OS suspension no longer count toward the reported duration.
Two notes:
CAMetalLayer nextDrawable... 1 of our 22 original events) still reports, because it really is blocked.@_spi(Private)surface changed (SentryFramesDelayResultSPI.ongoingFrameDelayDuration), which isn't in the committedsdk_api*.json... no regen diff.💡 Motivation and Context
Fixes #8317: thousands of false
App Hang Fully Blockedevents across four independent fingerprints, durations up to ~24 min matching the non-rendering interval, with no workaround short of disabling hang tracking.💚 How did you test it?
Unit tests in
SentryANRTrackerV2Testsusing the existing display link / date provider / dispatch queue doubles (blockBeforeMainBlock, same pattern as the V1 tests). New: the no-rendering repro (responsive main thread + stalled display link → no report), the mixed slow-frame-then-gap variant, hang-stop when the main thread recovers without rendering, and duration exclusion for both no-frame-delay-data and suspension oversleep. Existing genuine-hang tests now block the main thread explicitly; the non-fully-blocking test keeps the heartbeat responsive to guard the jank path. Each new test was run against the unfixed path first and failed for the expected reason.27/27 in the class, plus V1, FramesTracker, HangTrackingIntegration, Span, and TimeToDisplay (187 tests).
make analyze,build-ios,build-macosclean. Our CarPlay fingerprint reproduces on every drive, so we can pin this branch in production and confirm within a day or two.📝 Checklist
You have to check all boxes before merging:
sendDefaultPIIis enabled.