Commit 52fa3ed
feat: Optimise RCTKeyWindow() calls in RCTForceTouchAvailable method (facebook#41935)
Summary:
This PR optimises RCTKeyWindow() calls in `RCTForceTouchAvailable` method. This method was calling RCTKeyWindow hundreds of times while scrolling on the screen.
Before:
On the video you can see that this function is being called **350 times** just from simple list scrolling. RCTKeyWindow is looping over app windows so it's not a cheap operation.
https://github.com/facebook/react-native/assets/52801365/5b69cbd6-d148-4d06-b672-bd7b60472c13
After: the function is called only few times at the start of the app to get initial layout measurements.
Solution: I think we can check just once for the force touch capabilities as devices can't change it on the fly
bypass-github-export-checks
## Changelog:
[IOS] [FIXED] - Optimise RCTKeyWindow() calls in RCTForceTouchAvailable method
Pull Request resolved: facebook#41935
Test Plan: CI Green
Reviewed By: dmytrorykun
Differential Revision: D52172510
Pulled By: cipolleschi
fbshipit-source-id: 881a3125a2af4376ce65d785d8eee09c7d8f1f161 parent f7349c2 commit 52fa3ed
2 files changed
Lines changed: 3 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
634 | 634 | | |
635 | 635 | | |
636 | 636 | | |
637 | | - | |
638 | | - | |
| 637 | + | |
639 | 638 | | |
640 | 639 | | |
641 | | - | |
642 | | - | |
| 640 | + | |
643 | 641 | | |
644 | 642 | | |
645 | 643 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
0 commit comments