Make getNewScreenTimeToDisplay race-free by moving it to the native store/pull model
Maintainers usually reply within 1 day
@antonis is already working on this.
Since Sep 14, 2026.
Assessment
This issue has not been assessed yet.
Description
Background
#6722 fixes the fatal JavaCallback was already settled crash from getNewScreenTimeToDisplay under rapid navigation on Android (#6709). That fix makes losing the race survivable (crash → dropped measurement) but does not close the race window itself.
Why the window is intrinsic to the current design
RNSentryTimeToDisplay.getTimeToDisplay schedules a deferred Choreographer frame callback that resolves a live Promise after the frame renders. The producer (native frame callback) and consumer (JS promise / backing JavaCallback) have independent lifetimes:
- Native gets no teardown signal when a navigation is superseded, so it can't cancel the pending frame callback.
com.facebook.react.bridge.Promiseexposes no validity query, and even a check would be TOCTOU.- The deferred settle is the measurement (time to first frame after navigation), so we can't resolve early to dodge the race.
The only atomic option at that layer is attempt-and-catch — which is what #6722 does.
Proposed race-free design
Move getNewScreenTimeToDisplay to the store/pull model that the other TTID paths already use: the frame callback writes the timestamp into the native screenIdToRenderDuration map (via putTimeToDisplayFor), and JS pops it later via popTimeToDisplayFor — same pattern as ttid-, ttfd-, and ttid-navigation- (see timeToDisplayIntegration.ts). A stored value has no long-lived bridge callback, so there is no "already settled" failure mode at all.
Scope / considerations
- Bridge spec change (
NativeRNSentry.ts) → breaking, needs a@deprecatedmigration path. - Must be implemented on both platforms (Android + iOS — the iOS variant of the settle-after-teardown risk was deferred in #6722).
- Changes the fallback contract in
sentryeventemitterfallback.ts, which currently races the native promise againstrequestAnimationFrame; a pull model changes that timing and needs care.
Acceptance criteria
-
getNewScreenTimeToDisplay's deferred measurement no longer relies on resolving a long-lived promise from a frame callback. - No behavioral regression in TTID measurements on either architecture (New + Old) or platform (iOS + Android).
- Deprecation path for the bridge API change.
- Dominant language
- TypeScript
- Stars
- 1.8k
- Forks
- 369
- Avg merge
- 20h 55m
- Merged PRs (30d)
- 105
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from getsentry/sentry-react-native
-
Bug React-Native
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
getsentry/sentry-react-native#6821 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
React-Native Replays Task
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
getsentry/sentry-react-native#6680 · 1 comment ·
Maintainers usually reply within 1 day
-
Improvement React-Native
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getsentry/sentry-react-native#6143 · 2 comments ·
Maintainers usually reply within 1 day
-
React-Native Task User Feedbacks
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
getsentry/sentry-react-native#5932 · 2 comments ·
Maintainers usually reply within 1 day
-
React-Native Replays Task
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
getsentry/sentry-react-native#5882 · 1 comment ·
Maintainers usually reply within 1 day
All issues in getsentry/sentry-react-native
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Doist/todoist-cli#576 ·
Maintainers usually reply within 1 day
-
feature
Difficulty 1/5 Under an hour Newbie friendliness 72/100
vercel-labs/skills#2370 ·
Maintainers usually reply within 1 day
-
🐛 Bug supabase/cli
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CopilotKit/aimock#491 ·
Maintainers usually reply within 1 day