Skip to content

Expo Router 58: navigation spans and TTID start after the destination screen has rendered #7086

Open

Description

@antonis

Problem

On Expo Router 58+, expoRouterIntegration starts the navigation span from Expo Router's internal actionDispatched event (expoRouterIntegration.ts, via expo-router/build/global-state/internalNavigationEvents). Expo Router 58 queues navigation actions, so that event fires late:

  1. router.push() / <Link> / tab press → the intent goes into a queue (setState)
  2. RoutingQueueDrainer drains it in a useEffect
  3. The navigation reducer runs and the new screen renders
  4. Only then, in a layout effect, actionDispatched fires → we start the span here

So the navigation span and its ui.load.initial_display (TTID) span leave out the queue wait and the whole JS render of the destination screen. Slow screens look fast.

Repro (iOS simulator, samples/expo, Expo SDK 58 / expo-router 58.0.23, debug build)

I added a probe that logs Expo Router's performance marks and the transaction timestamps, on the same clock Sentry uses. I also added a 200 ms synchronous busy-wait to app/modal.tsx to stand in for a heavy screen. Then I ran 3 rounds of tab switches and modal open/close with Maestro.

Navigation Enqueued → our span start Real duration (enqueued → focused) Reported span / TTID
/modal (200 ms render), run 1 239 ms 268 ms 33 ms
/modal, run 2 232 ms 264 ms 35 ms
/modal, run 3 232 ms 255 ms (txn ended on POP)
Tab → /two 53 ms 60 ms 14 ms
Other tab switches (no txn sent) 22–25 ms queue gap

Sample log for one modal open (seconds):

action-enqueued    172.4045  id=3
modal-render start 172.4327   ← destination render starts (200 ms)
action-dispatched  172.6425  id=3 NAVIGATE
txn /modal         start=172.6432 end=172.6758  ttidEnd=172.6758
page-focused       172.6724  /modal

The 200 ms render happens entirely before our span starts.

Proposal

Expo Router 58 has an experimental public API, unstable_PerformanceObserver with expo-router:* marks (docs). Use it to backdate the span start to the moment the action was enqueued:

  • Observe expo-router:action-enqueued and keep actionId → startTime.
  • When actionDispatched fires, read the matching expo-router:action-dispatched mark (emitted synchronously just before it) to get the actionId. Then start the span at the enqueue time.
  • Keep the internal actionDispatched event. The marks carry no payload, and we need the payload for the route name and the POP_TO check.
  • Fall back to today's behaviour when the marks are unavailable: Expo Router <58, or the integration not enabled.

This is how EAS Observe measures navigation TTR. expo/expo#51485 added action-enqueued for exactly this reason: measuring from dispatch "only measures the time between when the action was reduced to the render".

Open questions

  • Marks are opt-in through unstable_enablePerformanceIntegration(), which mounts a listener component on every route. Should expoRouterIntegration call it (behind an option?), or should we document it?
  • The API is unstable_ and may be renamed. Feature-detect it and fall back.
  • Our internal-event import is also at risk: internalNavigationEvents.ts has TODO(ENG-27842): Unify with the other Expo Router event listeners. Ask Expo to add the action payload, or at least the route name, to action-dispatched, so we could drop the deep import entirely.
  • Numbers above are from a debug build. Release builds will have smaller gaps, but the structure is the same: our span misses the destination render.

Activity

  1. linear-code commented on Nov 23, 2026

    @linear-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions