Skip to content

Use mach_absolute_time for HighResTimeStamp on Apple platforms#55977

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

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.

@meta-codesync
Copy link

meta-codesync bot commented Mar 9, 2026

This pull request has been merged in 6aa99ad.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Mar 9, 2026
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @rubennorte in 6aa99ad

When will my fix make it into a release? | How to file a pick request?

rubennorte added a commit to rubennorte/react-native that referenced this pull request Mar 10, 2026
Summary:
Changelog: [iOS][Added] Add privacy manifest to declare the use of mach_absolute_time() API in the
React-timing module

Add privacy manifest to declare the use of mach_absolute_time() API in the
React-timing module, as required by Apple's privacy manifest requirements.

This addresses problems with facebook#55977 about potential App Store rejections
when using mach_absolute_time() without declaring it in the privacy manifest.

Changes:
- Created PrivacyInfo.xcprivacy declaring NSPrivacyAccessedAPICategorySystemBootTime
  with reason code 35F9.1 (measuring elapsed time between events)
- Updated React-timing.podspec to include the privacy manifest via resource_bundles
- Updated reactPerformanceTimeline target to include the timing privacy manifest

Reviewed By: cipolleschi

Differential Revision: D96018599
meta-codesync bot pushed a commit that referenced this pull request Mar 10, 2026
…6046)

Summary:
Pull Request resolved: #56046

Changelog: [iOS][Added] Add privacy manifest to declare the use of mach_absolute_time() API in the
React-timing module

Add privacy manifest to declare the use of mach_absolute_time() API in the
React-timing module, as required by Apple's privacy manifest requirements.

This addresses problems with #55977 about potential App Store rejections
when using mach_absolute_time() without declaring it in the privacy manifest.

Changes:
- Created PrivacyInfo.xcprivacy declaring NSPrivacyAccessedAPICategorySystemBootTime
  with reason code 35F9.1 (measuring elapsed time between events)
- Updated React-timing.podspec to include the privacy manifest via resource_bundles
- Updated reactPerformanceTimeline target to include the timing privacy manifest

Reviewed By: cipolleschi

Differential Revision: D96018599

fbshipit-source-id: 36025538015ac7c039e97adf2a0204cb8040330c
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 Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants