Skip to content

Commit

Permalink
Remove didMountComponentsWithRootTag on the new arch (#2687)
Browse files Browse the repository at this point in the history
## Description

Removes usage of `didMountComponentsWithRootTag` on the new
architecture. It was doing exactly the same thing as `flushOperations`
but was executed on a different thread, which could cause crashes.
Removing this method shouldn't change any behavior as `flushOperations`
is scheduled after every operation.

Closes
#2658
 
## Test plan

See
#2658
  • Loading branch information
j-piasecki authored Jan 10, 2024
1 parent 7a13ef5 commit 44499f2
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions apple/RNGestureHandlerModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTBridge+Private.h>
#import <React/RCTBridge.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTUtils.h>
#import <ReactCommon/CallInvoker.h>
#import <ReactCommon/RCTTurboModule.h>
Expand All @@ -34,7 +33,7 @@
#endif // RCT_NEW_ARCH_ENABLED

#ifdef RCT_NEW_ARCH_ENABLED
@interface RNGestureHandlerModule () <RCTSurfacePresenterObserver, RNGestureHandlerStateManager>
@interface RNGestureHandlerModule () <RNGestureHandlerStateManager>

@end
#else
Expand Down Expand Up @@ -68,9 +67,7 @@ - (void)invalidate

_manager = nil;

#ifdef RCT_NEW_ARCH_ENABLED
[self.bridge.surfacePresenter removeObserver:self];
#else
#ifndef RCT_NEW_ARCH_ENABLED
[self.bridge.uiManager.observerCoordinator removeObserver:self];
#endif // RCT_NEW_ARCH_ENABLED
}
Expand Down Expand Up @@ -115,9 +112,7 @@ - (void)setBridge:(RCTBridge *)bridge
eventDispatcher:bridge.eventDispatcher];
_operations = [NSMutableArray new];

#ifdef RCT_NEW_ARCH_ENABLED
[bridge.surfacePresenter addObserver:self];
#else
#ifndef RCT_NEW_ARCH_ENABLED
[bridge.uiManager.observerCoordinator addObserver:self];
#endif // RCT_NEW_ARCH_ENABLED
}
Expand Down Expand Up @@ -243,27 +238,7 @@ - (void)addOperationBlock:(GestureHandlerOperation)operation
[_operations addObject:operation];
}

#pragma mark - RCTSurfacePresenterObserver

#ifdef RCT_NEW_ARCH_ENABLED

- (void)didMountComponentsWithRootTag:(NSInteger)rootTag
{
RCTAssertMainQueue();

if (_operations.count == 0) {
return;
}

NSArray<GestureHandlerOperation> *operations = _operations;
_operations = [NSMutableArray new];

for (GestureHandlerOperation operation in operations) {
operation(self->_manager);
}
}

#else
#ifndef RCT_NEW_ARCH_ENABLED

#pragma mark - RCTUIManagerObserver

Expand Down

0 comments on commit 44499f2

Please sign in to comment.