Repository navigation
Description
Desrciption
Part of
What Is TTID?
TTID measures the time from when a new screen begins loading until the screen draws its first frame. It gives a more accurate picture of screen creation time than raw transaction timing.
- Span op:
ui.load.initial_display - Measurement key:
time_to_initial_display(milliseconds) - The span is a child of the
ui.loadtransaction (not a separate transaction, so it doesn't count against quota) - Status must be
okfor the measurement to be recorded — if the span finishes with any other status the measurement is omitted - The span starts when the screen begins loading. During app startup this is adjusted back to the native app start timestamp (same alignment as App Starts)
- The span ends automatically when the first frame is drawn — no manual intervention needed
References
- Initial PR from Allan Ritchie (old - needs review)
- TTID spec
- Mobile Vitals product docs
- sentry-dotnet tracking issue
How React Native Implements TTID on iOS
Like Android, RN has two parallel native paths plus a JS fallback. All paths store a timestamp in a shared static map (RNSentryTimeToDisplay) keyed by span ID. The JS layer reads this map after the transaction ends and constructs the TTID span.
The iOS implementation delegates entirely to the Cocoa SDK's SentryFramesTracker (backed by CADisplayLink) rather than implementing its own frame detection.
Path A — View-based (RNSentryOnDrawReporter)
A special view component (<RNSentryOnDrawReporter initialDisplay parentSpanId={...} />) is embedded in the screen's component tree. When rendered with initialDisplay=true:
- A
RNSentryFramesTrackerListeneris attached toSentryFramesTrackerfrom the Cocoa SDK SentryFramesTrackeruses aCADisplayLinkinternally. On the next frame callback it callsframesTrackerHasNewFrame:(NSDate *)newFrameDate- The listener removes itself immediately (one-shot), then stores
[newFrameDate timeIntervalSince1970]in the map under"ttid-{parentSpanId}"
Path B — Navigation integration (swizzleViewDidAppear + RNSentryFramesTrackerListener)
Activated when enableTimeToInitialDisplay=true in the React Navigation integration:
- At init time,
[RNSentryRNSScreen swizzleViewDidAppear]is called on the main thread — this swizzlesviewDidAppearonreact-native-screensscreen classes - A
RNSentryFramesTrackerListeneris created with a callback that calls[RNSentryTimeToDisplay putTimeToInitialDisplayForActiveSpan:timestamp] - JS calls
NATIVE.setActiveSpanId(spanId)to register the current span - On
viewDidAppear, the listener starts listening onSentryFramesTracker - On the next frame, the timestamp is stored under
"ttid-navigation-{activeSpanId}"
Fallback — CADisplayLink bridge (getNewScreenTimeToDisplay)
If neither native path produces a timestamp in time:
- Creates a one-shot
CADisplayLinktargeting ahandleDisplayLink:selector - Added to
NSRunLoop.mainRunLoopwithNSRunLoopCommonModes - On the next display link callback, captures
[NSDate date] timeIntervalSince1970and resolves the promise, then invalidates theCADisplayLink - Only available on
TARGET_OS_IOS— returns empty on macOS / Catalyst
JS-Side Span Construction
Identical to Android — after the transaction ends, processEvent calls NATIVE.popTimeToDisplayFor(...), constructs the span, and sets the time_to_initial_display measurement. See the Android notes for the shared JS flow.
App Start Timestamp Alignment
Same as Android — both the transaction's start_timestamp and the TTID span's start_timestamp are overwritten with the native app start timestamp, and the measurement is recalculated.
Key iOS API: SentryFramesTracker / CADisplayLink
The Cocoa SDK's SentryFramesTracker is the frame detection mechanism on iOS. It runs a CADisplayLink that fires on every rendered frame. RN taps into this via PrivateSentrySDKOnly — the same internal API used for slow/frozen frames and App Start data.
SentryFramesTracker must be running for any of this to work. In the Cocoa SDK this is controlled by enableAutoPerformanceTracing.
Quirks and Limitations
SentryFramesTrackermust be active — ifenableAutoPerformanceTracingis not set in the Cocoa SDK, all paths fail silently and no TTID is reported- The
CADisplayLinkfallback is iOS-only (TARGET_OS_IOS) — it returns empty on Mac Catalyst swizzleViewDidAppearrequiresreact-native-screens— without it the navigation integration path is unavailableactiveSpanIdis a single global — same potential span ID mismatch risk as Android (mitigated by keyed map)- A 30-second timeout in the JS layer bounds how long it waits for a native timestamp
Implications for .NET/MAUI (iOS)
- The core mechanism is
SentryFramesTracker/CADisplayLinkviaPrivateSentrySDKOnly. The Cocoa bindings need to expose the relevant API — specificallySentryFramesTrackeror a listener protocol (SentryFramesTrackerListener) PrivateSentrySDKOnly.isFramesTrackingRunningandcurrentScreenFramesalready appear inApiDefinitions.cs(used for slow/frozen frames), but the listener protocol for one-shot frame callbacks likely needs adding- The equivalent of
viewDidAppearin MAUI is a page'sOnAppearinglifecycle event — this is a natural hook point for starting the frame listener - The Cocoa binding additions would need to go through
scripts/patch-cocoa-bindings.cssinceApiDefinitions.csis auto-generated enableAutoPerformanceTracingmust be set on the Cocoa SDK options forSentryFramesTrackerto run
Activity
linear-code commentedon Apr 1, 2026
NET-643