Repository navigation
Conversation
…conversion The monotonic clock behind performance.now() pauses while the device sleeps, so an offset cached at module load drifts from Date.now() for the rest of the session.
V3RON
left a comment
There was a problem hiding this comment.
Thanks, the diagnosis holds. In React Native, NativePerformance::now() on Apple uses mach_absolute_time(), which pauses during sleep, while timeOrigin() subtracts libc++'s steady_clock (CLOCK_MONOTONIC_RAW, which counts sleep). So timeOrigin + now() lags wall time by the device's total sleep since boot. Android uses CLOCK_MONOTONIC for both, so it doesn't have this particular mismatch.
I pushed one follow-up commit: the offset is now sampled on every conversion instead of once at module load. The monotonic clock pauses during sleep on both iOS and Android, so a cached offset drifts after the device locks mid-session. The commit also adds a regression test for that case and updates the stale timeOrigin comment in recorder.ts.
|
Thanks :) |
Description
Fix incorrect start times and excessively stretched timelines for Nitro HTTP and WebSocket traffic in Network Activity.
Calculate the timestamp origin using
Date.now() - performance.now()so Nitro events align with built-in network events.Related Issue
No related issue.
Context
On affected React Native iOS runtimes,
performance.timeOriginandperformance.now()can use different clock bases. The adapter previously trustedtimeOriginwhenever it was available, causing Nitro timestamps to shift relative to wall-clock time.The fix derives the offset from the clock Nitro actually uses. Event timestamps remain in epoch milliseconds, and elapsed durations are preserved.
Includes regression coverage for shifted, aligned, and missing
timeOriginvalues across HTTP requests, cancellations, and WebSocket events, plus a patch changeset.Testing
pnpm checks:affected— passed.pnpm test:affected— 268 tests passed.pnpm release:plan— passed.Manual: