Commit 6aa99ad
Use mach_absolute_time for HighResTimeStamp on Apple platforms (facebook#55977)
Summary:
Pull Request resolved: facebook#55977
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
Reviewed By: hoxyq
Differential Revision: D95554947
fbshipit-source-id: 322331867b9ed36260bb8f35b8bbca2f4937a0ed1 parent 41a1941 commit 6aa99ad
File tree
3 files changed
+54
-10
lines changed- packages/react-native
- ReactCommon/react/timing
- __docs__
- React/Fabric
3 files changed
+54
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 30 | + | |
36 | 31 | | |
37 | 32 | | |
38 | 33 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
55 | 72 | | |
56 | 73 | | |
57 | 74 | | |
| |||
Lines changed: 33 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
312 | 316 | | |
313 | 317 | | |
314 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
315 | 336 | | |
316 | 337 | | |
317 | 338 | | |
| |||
322 | 343 | | |
323 | 344 | | |
324 | 345 | | |
325 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
326 | 354 | | |
327 | 355 | | |
328 | 356 | | |
329 | 357 | | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
330 | 361 | | |
| 362 | + | |
331 | 363 | | |
332 | 364 | | |
333 | 365 | | |
| |||
0 commit comments