Expo Router 58: navigation spans and TTID start after the destination screen has rendered
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 28/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- react-native, typescript
研究方向
Start in expoRouterIntegration.ts where the navigation span is opened from the internal actionDispatched event, and read the import from expo-router/build/global-state/internalNavigationEvents. Verify the ordering claim by running the repro in samples/expo with the added probe and busy-wait in app/modal.tsx, then experiment with unstable_PerformanceObserver marks (expo-router:action-enqueued / action-dispatched) to map actionId to enqueue times. Done means the span starts at enqueue time when the marks exist, the payload-based route name and POP_TO logic still work, and the old behaviour remains as the fallback for Expo Router <58. Open questions about auto-enabling the opt-in integration are unresolved, so expect discussion before a patch lands.
由索引模型根據 Issue 內容生成。
描述
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:
router.push()/<Link>/ tab press → the intent goes into a queue (setState)RoutingQueueDrainerdrains it in auseEffect- The navigation reducer runs and the new screen renders
- Only then, in a layout effect,
actionDispatchedfires → 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-enqueuedand keepactionId → startTime. - When
actionDispatchedfires, read the matchingexpo-router:action-dispatchedmark (emitted synchronously just before it) to get theactionId. Then start the span at the enqueue time. - Keep the internal
actionDispatchedevent. The marks carry nopayload, and we need the payload for the route name and thePOP_TOcheck. - 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. ShouldexpoRouterIntegrationcall 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.tshasTODO(ENG-27842): Unify with the other Expo Router event listeners. Ask Expo to add the action payload, or at least the route name, toaction-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.
- 主要語言
- TypeScript
- 星號
- 1.8k
- 分支
- 371
- 平均合併
- 22 小時 3 分鐘
- 30 天內合併 PR
- 106
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
getsentry/sentry-react-native 的其他 Issue
-
React-Native
難度 2/5 1-3 小時 新手友好度 78/100
getsentry/sentry-react-native#7073 · 1 則留言 ·
維護者通常 1 天內回覆
-
Improvement React-Native
難度 2/5 1-3 小時 新手友好度 80/100
getsentry/sentry-react-native#7055 · 1 則留言 ·
維護者通常 1 天內回覆
-
React-Native Replays Task
難度 2/5 1-3 小時 新手友好度 88/100
getsentry/sentry-react-native#6680 · 1 則留言 ·
維護者通常 1 天內回覆
-
Improvement React-Native
難度 2/5 1-3 小時 新手友好度 68/100
getsentry/sentry-react-native#6143 · 2 則留言 ·
維護者通常 1 天內回覆
-
React-Native Task User Feedbacks
難度 2/5 1-3 小時 新手友好度 84/100
getsentry/sentry-react-native#5932 · 2 則留言 ·
維護者通常 1 天內回覆
查看 getsentry/sentry-react-native 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
danielmiessler/LifeOS#3028 ·
維護者通常 5 天內回覆
-
難度 2/5 1-3 小時 新手友好度 88/100
-
iOS: last line of a long UITextView text is sometimes not drawn (frame a fraction of a point short)未關閉
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 90/100
Koenkk/zigbee2mqtt#33855 ·
維護者通常 1 天內回覆