Skip to content

Use mach_absolute_time for HighResTimeStamp on Apple platforms#55977

Open
rubennorte wants to merge 1 commit intofacebook:mainfrom
rubennorte:export-D95554947
Open

Use mach_absolute_time for HighResTimeStamp on Apple platforms#55977
rubennorte wants to merge 1 commit intofacebook:mainfrom
rubennorte:export-D95554947

Conversation

@rubennorte
Copy link
Contributor

Summary:
Changelog: [internal]

On iOS/macOS, std::chrono::steady_clock uses mach_continuous_time() which includes device sleep time. This causes compatibility issues with iOS system APIs like UITouch.timestamp and NSProcessInfo.processInfo.systemUptime which use mach_absolute_time() (excludes sleep time).

This diff modifies HighResTimeStamp to use mach_absolute_time() directly on Apple platforms, ensuring timestamps are compatible with iOS system APIs and native performance logging systems.

Changes:

  • Added mach_absolute_time() based clock for Apple platforms in primitives.h
  • Simplified RCTHighResTimeStampFromSeconds() since iOS timestamps now share the same clock domain
  • Updated documentation to explain platform-specific clock behavior

Differential Revision: D95554947

Summary:
Changelog: [internal]

On iOS/macOS, `std::chrono::steady_clock` uses `mach_continuous_time()` which includes device sleep time. This causes compatibility issues with iOS system APIs like `UITouch.timestamp` and `NSProcessInfo.processInfo.systemUptime` which use `mach_absolute_time()` (excludes sleep time).

This diff modifies `HighResTimeStamp` to use `mach_absolute_time()` directly on Apple platforms, ensuring timestamps are compatible with iOS system APIs and native performance logging systems.

Changes:
- Added `mach_absolute_time()` based clock for Apple platforms in `primitives.h`
- Simplified `RCTHighResTimeStampFromSeconds()` since iOS timestamps now share the same clock domain
- Updated documentation to explain platform-specific clock behavior

Differential Revision: D95554947
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 6, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 6, 2026

@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95554947.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants