Repository navigation
[No QA] [iOS] Mirror app hang context in standalone NewDot and add the NewDot screen to native events - #106989
Conversation
…n to native events Same App Hang tags and idle fingerprint as Mobile-Expensify, plus a NewDot Screen Sentry context set on every navigation.
|
@MelvinBot review |
Review findings[P2] Lifecycle classification misses interruptions near the start of a hang. For example, a 2.4-second hang processed one second later shifts CI blocker: Spellcheck failed on Static review only; iOS hang capture and native context persistence were not runtime-verified. |
Good catch, I tried this, but it ended up making the tags less accurate. The duration Sentry reports already includes the time it takes to notice that the hang has ended, so moving the start back an extra second puts it before the hang actually began. Then a hang that starts right after the app comes back to the foreground gets tagged as |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppios.mp4iOS: mWeb SafariMacOS: Chrome / Safari |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9f265f54d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // Classification is on `frame.package` (the image path, e.g. ".../UIKitCore"), never on `frame.function`: | ||
| // SentryCrashReportConverter fills only instructionAddress, imageAddress, package and inApp, and symbolication | ||
| // happens server-side after beforeSend returns, so `function` is always nil. | ||
| static NSString *frameImageName(SentryFrame *_Nullable frame) { |
There was a problem hiding this comment.
Give the new native helpers verb-led names
The new helpers such as frameImageName, appHangMinimumDuration, and appHangException have noun-led names that read as values rather than operations. .claude/skills/app-coding-standards/rules/consistency-20-function-names.md, required by AGENTS.md, explicitly requires new function names to start with a verb. These are internal static functions, so no external interface dictates their names. Rename them to forms such as getFrameImageName and getAppHangException, and use verb-led names for the new predicates as well.
AGENTS.md reference: AGENTS.md:L7-L10
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This file mirrors SentryNativeSDKManager.m in Mobile-Expensify, where frameImageName and frameIsInImage already exist next to helpers like victimFrame and truncatedTagValue. I kept the new helpers in the same style so both copies stay identical and consistent with that file.
| return @"idle"; | ||
| } | ||
|
|
||
| // "App hanging between 2.4 and 3.2 seconds." -> 2.4, the lower bound. NAN for any other wording. |
There was a problem hiding this comment.
Replace the prose arrow in the duration comment
The -> here describes a relationship outside the quoted Sentry message; it is not part of the external string being documented. .claude/skills/app-coding-standards/rules/consistency-15-plain-comment-style.md, required by AGENTS.md, explicitly prohibits using arrows for relationships in comment prose. Reword the example as a sentence explaining that its lower bound is 2.4.
AGENTS.md reference: AGENTS.md:L7-L10
Useful? React with 👍 / 👎.
| CFAbsoluteTime now = CFAbsoluteTimeGetCurrent(); | ||
| CFAbsoluteTime start = now - minimumDuration; |
There was a problem hiding this comment.
Classify lifecycle changes against the actual hang interval
If the app becomes inactive or backgrounds after a non-fatal hang ends but before beforeSend runs, using the callback time here makes that later lifecycle change count as an interruption of the hang. The acknowledged callback delay also shifts start forward and drops interruptions near the beginning: a 2.4-second hang from 100.0 to 102.4, with beforeSend at 103.4, computes start = 101.0 and ignores a resignation at 100.25. This misclassifies the new triage tags. Base the lifecycle checks on the hang's recorded interval, bounded at hang end, rather than send-processing time.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Base the lifecycle checks on the hang's recorded interval, bounded at hang end, rather than send-processing time.
Sentry's duration runs until it sees frames again, so the start lands near the real one, not a second late. And during a blocking hang the lifecycle observers can't run until it ends, so leaving mid-hang gets recorded right after the end. Bounding there would drop exactly those cases
dylanexpensify
left a comment
There was a problem hiding this comment.
Product input not required for this PR.
| static void recordRunLoopActivity(CFRunLoopActivity activity) { | ||
| CFAbsoluteTime now = CFAbsoluteTimeGetCurrent(); | ||
| os_unfair_lock_lock(&appLifecycleLock); | ||
| if (!lastRunLoopActivityWasSleep && lastRunLoopActivityTime > 0) { | ||
| addBusyTimeLocked(lastRunLoopActivityTime, now); | ||
| } | ||
| lastRunLoopActivityTime = now; | ||
| lastRunLoopActivityWasSleep = activity == kCFRunLoopBeforeWaiting; | ||
| os_unfair_lock_unlock(&appLifecycleLock); |
There was a problem hiding this comment.
Hang windows mix wall-clock and monotonic time
Sentry measures the hang duration with CLOCK_UPTIME_RAW, but start = now - minimumDuration and the busy history use CFAbsoluteTimeGetCurrent(), which shifts when the system clock is adjusted.
A clock change near a hang moves the window and tags the hang wrongly.
App/ios/SentryNativeSDKManager.m
Lines 190 to 193 in a9f265f
Use clock_gettime_nsec_np(CLOCK_UPTIME_RAW) (or CACurrentMediaTime()) here and in the Mobile-Expensify copy (iOS/Expensify/SentryNativeSDKManager.m at lines 251 and 358).
There was a problem hiding this comment.
Good catch, switched to CACurrentMediaTime() in both repos and retested the launch and resume cases on a simulator. Since uptime can be shorter than a bogus hang duration right after a reboot, the busy history lookup is now clamped at 0
|
@arekm213 can you address all the ai comments please? and conflicts |
| lastRunLoopActivityTime = CACurrentMediaTime(); | ||
| lastRunLoopActivityWasSleep = NO; | ||
| os_unfair_lock_unlock(&appLifecycleLock); | ||
| CFRunLoopObserverRef runLoopObserver = CFRunLoopObserverCreateWithHandler(kCFAllocatorDefault, kCFRunLoopAllActivities, true, LONG_MAX, ^(CFRunLoopObserverRef observer, CFRunLoopActivity activity) { |
There was a problem hiding this comment.
There was a problem hiding this comment.
|
🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.43-0 🚀
|
|
No help site update needed — this PR only changes internal Sentry diagnostics for app hangs and screen context, without changing user-facing features, workflows, or documented behavior. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.47-0 🚀
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.51-0 🚀
|
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.5.51-1 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
Companion to the Mobile-Expensify PR linked below, which splits APP-77W and tags app hang false positives in the HybridApp.
ios/SentryNativeSDKManager.m: the same app hang section as Mobile-Expensify (app_hang.main_thread,app_hang.blocked,app_hang.interrupted,app_hang.sinceand the idle fingerprint), so standalone NewDot reports hangs the same way. Standalone NewDot has noodot.foregroundtag, so every idle hang is grouped as NewDot. The existing JS duplicate filter moved into aprocessEventBeforeSendfunction to match the Mobile-Expensify structure. Its behaviour is unchanged.src/libs/Navigation/NavigationRoot.tsx: sets aNewDot ScreenSentry context (route name and time) on every navigation and on ready. JS contexts sync to the native scope, so native events such as app hangs, including fatal ones sent on the next launch, show which NewDot screen the user was on. It is a context and not a tag, so it does not change grouping or add high cardinality tags.This section is temporary and is marked to be removed together with App Hang tracking in sentry-cocoa 10.
Fixed Issues
$ #106340
PROPOSAL:
MOBILE-EXPENSIFY: https://github.com/Expensify/Mobile-Expensify/pull/14235
Tests
ENABLE_SENTRY_ON_DEV=true), run it on a simulator and sign in.app_hang.*tags described in the Mobile-Expensify PR.Offline tests
Not applicable, this only changes crash reporting metadata.
QA Steps
[No QA] No user facing change. A sanity pass is enough: run the app, sign in and navigate around.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Not applicable, no UI change.
Android: mWeb Chrome
Not applicable, no UI change.
iOS: Native
The "NewDot Screen" context on an app hang event in Sentry: event (screen
Settings_Troubleshoot).iOS: mWeb Safari
Not applicable, no UI change.
MacOS: Chrome / Safari
Not applicable, no UI change.