fix(browser): Use drift-corrected time origin for INP, replay and profiling - #23067
Conversation
…filing `timestampInSeconds` re-derives its time origin when it detects clock drift, but `browserPerformanceTimeOrigin` caches the origin resolved at SDK init and never revisits it. Consumers that convert a `PerformanceEntry`'s monotonic `startTime` to wall clock time therefore end up on a different timeline than span and event timestamps once a correction has happened. Exposes the corrected origin as `correctedPerformanceTimeOrigin` and uses it for the consumers that outlive a span timeout: INP (reports on pagehide) and replay (sessions run up to an hour). Profiling already compensated for the SDK changing its time origin, but computed the adjustment against the stale cached value. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 25c1b28. Configure here.
| // Since JS self profiling time origin is always initialized to performance.timeOrigin, we need to adjust for | ||
| // the drift between the SDK selected value and our profile time origin. | ||
| const perfOrigin = browserPerformanceTimeOrigin(); | ||
| const perfOrigin = correctedPerformanceTimeOrigin(); |
There was a problem hiding this comment.
Profile elapsed times shift after drift
High Severity
Switching convertJSSelfProfileToSampledFormat to correctedPerformanceTimeOrigin makes adjustForOriginChange non-zero after runtime clock drift. That delta is added into every elapsed_since_start_ns, so the first sample is no longer 0 and all relative sample times shift by the full drift (often negative after device sleep). Continuous profiling absolute timestamps are fine; this only breaks transaction/sampled profiles.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 25c1b28. Configure here.
size-limit report 📦
|


No description provided.