-
Notifications
You must be signed in to change notification settings - Fork 4k
Upgrade reanimated to 3.1.0 #18073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
roryabraham
merged 15 commits into
Expensify:main
from
margelo:@terrysahaidak/upgrade-reanimated
May 18, 2023
Merged
Upgrade reanimated to 3.1.0 #18073
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
084904f
Upgrade reanimated to 3.1.0
terrysahaidak 249ef57
Fix recursive crash on Android
terrysahaidak 6422ca5
Refactor ReportActionList to use more common Reanimated API
terrysahaidak 020667b
Podfile changes after upgrade
terrysahaidak a3485a7
Fix another props usage inside useAnimatedStyle
terrysahaidak 97bd3f0
Add iOS crash patch
terrysahaidak c7e44a5
Address review feedback
terrysahaidak 644b850
Merge remote-tracking branch 'upstream/main' into @terrysahaidak/upgr…
terrysahaidak 5d82281
Fix setImmediate being undefined in jest
terrysahaidak f536009
Merge remote-tracking branch 'upstream/main' into @terrysahaidak/upgr…
terrysahaidak aa85d02
Add patch for missing isConfigured to reanimated mock to pass tests
terrysahaidak a3eb8e6
move setimmediate to dev dependencies since it's used only by jest
terrysahaidak 8c96f37
Merge remote-tracking branch 'upstream/main' into @terrysahaidak/upgr…
terrysahaidak c47f847
Merge remote-tracking branch 'upstream/main' into @terrysahaidak/upgr…
terrysahaidak 5f8ff9c
prettify code
terrysahaidak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| diff --git a/node_modules/react-native-reanimated/ios/REANodesManager.mm b/node_modules/react-native-reanimated/ios/REANodesManager.mm | ||
| index 26bb253..4108293 100644 | ||
| --- a/node_modules/react-native-reanimated/ios/REANodesManager.mm | ||
| +++ b/node_modules/react-native-reanimated/ios/REANodesManager.mm | ||
| @@ -85,19 +85,77 @@ - (void)runSyncUIUpdatesWithObserver:(id<RCTUIManagerObserver>)observer | ||
|
|
||
| @end | ||
|
|
||
| -@interface REANodesManager () <RCTUIManagerObserver> | ||
| +#ifndef RCT_NEW_ARCH_ENABLED | ||
|
|
||
| +@interface REASyncUpdateObserver : NSObject <RCTUIManagerObserver> | ||
| @end | ||
|
|
||
| +@implementation REASyncUpdateObserver { | ||
| + volatile void (^_mounting)(void); | ||
| + volatile BOOL _waitTimedOut; | ||
| + dispatch_semaphore_t _semaphore; | ||
| +} | ||
| + | ||
| +- (instancetype)init | ||
| +{ | ||
| + self = [super init]; | ||
| + if (self) { | ||
| + _mounting = nil; | ||
| + _waitTimedOut = NO; | ||
| + _semaphore = dispatch_semaphore_create(0); | ||
| + } | ||
| + return self; | ||
| +} | ||
| + | ||
| +- (void)dealloc | ||
| +{ | ||
| + RCTAssert(_mounting == nil, @"Mouting block was set but never executed. This may lead to UI inconsistencies"); | ||
| +} | ||
| + | ||
| +- (void)unblockUIThread | ||
| +{ | ||
| + RCTAssertUIManagerQueue(); | ||
| + dispatch_semaphore_signal(_semaphore); | ||
| +} | ||
| + | ||
| +- (void)waitAndMountWithTimeout:(NSTimeInterval)timeout | ||
| +{ | ||
| + RCTAssertMainQueue(); | ||
| + long result = dispatch_semaphore_wait(_semaphore, dispatch_time(DISPATCH_TIME_NOW, timeout * NSEC_PER_SEC)); | ||
| + if (result != 0) { | ||
| + @synchronized(self) { | ||
| + _waitTimedOut = YES; | ||
| + } | ||
| + } | ||
| + if (_mounting) { | ||
| + _mounting(); | ||
| + _mounting = nil; | ||
| + } | ||
| +} | ||
| + | ||
| +- (BOOL)uiManager:(RCTUIManager *)manager performMountingWithBlock:(RCTUIManagerMountingBlock)block | ||
| +{ | ||
| + RCTAssertUIManagerQueue(); | ||
| + @synchronized(self) { | ||
| + if (_waitTimedOut) { | ||
| + return NO; | ||
| + } else { | ||
| + _mounting = block; | ||
| + return YES; | ||
| + } | ||
| + } | ||
| +} | ||
| + | ||
| +@end | ||
| + | ||
| +#endif | ||
| + | ||
| @implementation REANodesManager { | ||
| CADisplayLink *_displayLink; | ||
| BOOL _wantRunUpdates; | ||
| NSMutableArray<REAOnAnimationCallback> *_onAnimationCallbacks; | ||
| BOOL _tryRunBatchUpdatesSynchronously; | ||
| REAEventHandler _eventHandler; | ||
| - volatile void (^_mounting)(void); | ||
| - NSObject *_syncLayoutUpdatesWaitLock; | ||
| - volatile BOOL _syncLayoutUpdatesWaitTimedOut; | ||
| NSMutableDictionary<NSNumber *, ComponentUpdate *> *_componentUpdateBuffer; | ||
| NSMutableDictionary<NSNumber *, UIView *> *_viewRegistry; | ||
| #ifdef RCT_NEW_ARCH_ENABLED | ||
| @@ -125,7 +183,6 @@ - (nonnull instancetype)initWithModule:(REAModule *)reanimatedModule | ||
| _operationsInBatch = [NSMutableDictionary new]; | ||
| _componentUpdateBuffer = [NSMutableDictionary new]; | ||
| _viewRegistry = [_uiManager valueForKey:@"_viewRegistry"]; | ||
| - _syncLayoutUpdatesWaitLock = [NSObject new]; | ||
| } | ||
|
|
||
| _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(onAnimationFrame:)]; | ||
| @@ -241,19 +298,6 @@ - (void)onAnimationFrame:(CADisplayLink *)displayLink | ||
| } | ||
| } | ||
|
|
||
| -- (BOOL)uiManager:(RCTUIManager *)manager performMountingWithBlock:(RCTUIManagerMountingBlock)block | ||
| -{ | ||
| - RCTAssert(_mounting == nil, @"Mouting block is expected to not be set"); | ||
| - @synchronized(_syncLayoutUpdatesWaitLock) { | ||
| - if (_syncLayoutUpdatesWaitTimedOut) { | ||
| - return NO; | ||
| - } else { | ||
| - _mounting = block; | ||
| - return YES; | ||
| - } | ||
| - } | ||
| -} | ||
| - | ||
| - (void)performOperations | ||
| { | ||
| #ifdef RCT_NEW_ARCH_ENABLED | ||
| @@ -268,8 +312,7 @@ - (void)performOperations | ||
| _tryRunBatchUpdatesSynchronously = NO; | ||
|
|
||
| __weak __typeof__(self) weakSelf = self; | ||
| - dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); | ||
| - _syncLayoutUpdatesWaitTimedOut = NO; | ||
| + REASyncUpdateObserver *syncUpdateObserver = [REASyncUpdateObserver new]; | ||
| RCTExecuteOnUIManagerQueue(^{ | ||
| __typeof__(self) strongSelf = weakSelf; | ||
| if (strongSelf == nil) { | ||
| @@ -278,7 +321,7 @@ - (void)performOperations | ||
| BOOL canUpdateSynchronously = trySynchronously && ![strongSelf.uiManager hasEnqueuedUICommands]; | ||
|
|
||
| if (!canUpdateSynchronously) { | ||
| - dispatch_semaphore_signal(semaphore); | ||
| + [syncUpdateObserver unblockUIThread]; | ||
| } | ||
|
|
||
| for (int i = 0; i < copiedOperationsQueue.count; i++) { | ||
| @@ -286,8 +329,8 @@ - (void)performOperations | ||
| } | ||
|
|
||
| if (canUpdateSynchronously) { | ||
| - [strongSelf.uiManager runSyncUIUpdatesWithObserver:strongSelf]; | ||
| - dispatch_semaphore_signal(semaphore); | ||
| + [strongSelf.uiManager runSyncUIUpdatesWithObserver:syncUpdateObserver]; | ||
| + [syncUpdateObserver unblockUIThread]; | ||
| } | ||
| // In case canUpdateSynchronously=true we still have to send uiManagerWillPerformMounting event | ||
| // to observers because some components (e.g. TextInput) update their UIViews only on that event. | ||
| @@ -298,17 +341,7 @@ - (void)performOperations | ||
| // from CADisplayLink but it is easier to hardcode it for the time being. | ||
| // The reason why we use frame duration here is that if takes longer than one frame to complete layout tasks | ||
| // there is no point of synchronizing layout with the UI interaction as we get that one frame delay anyways. | ||
| - long result = dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, 16 * NSEC_PER_MSEC)); | ||
| - if (result != 0) { | ||
| - @synchronized(_syncLayoutUpdatesWaitLock) { | ||
| - _syncLayoutUpdatesWaitTimedOut = YES; | ||
| - } | ||
| - } | ||
| - } | ||
| - | ||
| - if (_mounting) { | ||
| - _mounting(); | ||
| - _mounting = nil; | ||
| + [syncUpdateObserver waitAndMountWithTimeout:0.016]; | ||
| } | ||
| } | ||
| _wantRunUpdates = NO; | ||
| diff --git a/node_modules/react-native-reanimated/mock.js b/node_modules/react-native-reanimated/mock.js | ||
| index 68b20d2..b088001 100644 | ||
| --- a/node_modules/react-native-reanimated/mock.js | ||
| +++ b/node_modules/react-native-reanimated/mock.js | ||
| @@ -41,6 +41,9 @@ const Reanimated = { | ||
| createAnimatedComponent: (Component) => Component, | ||
| addWhitelistedUIProps: NOOP, | ||
| addWhitelistedNativeProps: NOOP, | ||
| + | ||
| + // used by react-navigation fork | ||
| + isConfigured: () => true, | ||
| }; | ||
|
|
||
| module.exports = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.