Reverted to pre-init of queues to fix UIExplorer tests.
This commit is contained in:
parent
e21fb91786
commit
b82ac9bf07
|
@ -154,7 +154,6 @@ id<RCTJavaScriptExecutor> RCTGetLatestExecutor(void)
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
dispatch_group_notify(setupJSExecutorAndModuleConfig, bridgeQueue, ^{
|
||||
[weakSelf injectJSONConfiguration:config onComplete:^(__unused NSError *error) {}];
|
||||
|
||||
|
@ -278,13 +277,17 @@ id<RCTJavaScriptExecutor> RCTGetLatestExecutor(void)
|
|||
RCTLatestExecutor = _javaScriptExecutor;
|
||||
|
||||
for (id<RCTBridgeModule> module in _modulesByName.allValues) {
|
||||
|
||||
// Bridge must be set before moduleData is set up, as methodQueue
|
||||
// initialization requires it (View Managers get their queue by calling
|
||||
// self.bridge.uiManager.methodQueue)
|
||||
if ([module respondsToSelector:@selector(setBridge:)]) {
|
||||
module.bridge = self;
|
||||
}
|
||||
|
||||
RCTModuleData *moduleData = [[RCTModuleData alloc] initWithExecutor:_javaScriptExecutor
|
||||
uid:@(_moduleDataByID.count)
|
||||
instance:module];
|
||||
moduleID:@(_moduleDataByID.count)
|
||||
instance:module];
|
||||
[_moduleDataByID addObject:moduleData];
|
||||
}
|
||||
|
||||
|
@ -305,10 +308,6 @@ id<RCTJavaScriptExecutor> RCTGetLatestExecutor(void)
|
|||
for (RCTModuleData *moduleData in _moduleDataByID) {
|
||||
config[moduleData.name] = moduleData.config;
|
||||
|
||||
|
||||
// HACK(tadeu): Ensure the queue has been loaded, make it lazy later inside RCTModuleMap
|
||||
(void)[moduleData queue];
|
||||
|
||||
if ([moduleData.instance conformsToProtocol:@protocol(RCTFrameUpdateObserver)]) {
|
||||
[_frameUpdateObservers addObject:moduleData];
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
@interface RCTModuleData : NSObject
|
||||
|
||||
@property (nonatomic, weak, readonly) id<RCTJavaScriptExecutor> javaScriptExecutor;
|
||||
@property (nonatomic, strong, readonly) NSNumber *uid;
|
||||
@property (nonatomic, strong, readonly) NSNumber *moduleID;
|
||||
@property (nonatomic, strong, readonly) id<RCTBridgeModule> instance;
|
||||
|
||||
@property (nonatomic, strong, readonly) Class moduleClass;
|
||||
|
@ -25,7 +25,7 @@
|
|||
@property (nonatomic, strong) dispatch_queue_t queue;
|
||||
|
||||
- (instancetype)initWithExecutor:(id<RCTJavaScriptExecutor>)javaScriptExecutor
|
||||
uid:(NSNumber *)uid
|
||||
moduleID:(NSNumber *)moduleID
|
||||
instance:(id<RCTBridgeModule>)instance NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (void)dispatchBlock:(dispatch_block_t)block;
|
||||
|
|
|
@ -15,27 +15,31 @@
|
|||
|
||||
@implementation RCTModuleData
|
||||
{
|
||||
id _consts;
|
||||
|
||||
NSDictionary *_config;
|
||||
NSDictionary *_constants;
|
||||
NSArray *_methods;
|
||||
NSString *_queueName;
|
||||
}
|
||||
|
||||
- (instancetype)initWithExecutor:(id<RCTJavaScriptExecutor>)javaScriptExecutor
|
||||
uid:(NSNumber *)uid
|
||||
moduleID:(NSNumber *)moduleID
|
||||
instance:(id<RCTBridgeModule>)instance
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_javaScriptExecutor = javaScriptExecutor;
|
||||
_uid = uid;
|
||||
_moduleID = moduleID;
|
||||
_instance = instance;
|
||||
_moduleClass = [instance class];
|
||||
_name = RCTBridgeModuleNameForClass(_moduleClass);
|
||||
|
||||
// Must be done at init time to ensure it's called on main thread
|
||||
RCTAssertMainThread();
|
||||
if ([_instance respondsToSelector:@selector(constantsToExport)]) {
|
||||
_consts = [_instance constantsToExport];
|
||||
_constants = [_instance constantsToExport];
|
||||
}
|
||||
|
||||
// Must be done at init time due to race conditions
|
||||
// Also, the queue setup isn't thread safe due ti static name cache
|
||||
[self queue];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -68,32 +72,28 @@ RCT_NOT_IMPLEMENTED(-init);
|
|||
|
||||
_methods = [moduleMethods copy];
|
||||
}
|
||||
|
||||
return _methods;
|
||||
}
|
||||
|
||||
- (NSDictionary *)config
|
||||
{
|
||||
if (!_config) {
|
||||
NSMutableDictionary *config = [[NSMutableDictionary alloc] init];
|
||||
config[@"moduleID"] = _uid;
|
||||
config[@"methods"] = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *config = [[NSMutableDictionary alloc] init];
|
||||
config[@"moduleID"] = _moduleID;
|
||||
|
||||
if (_consts) {
|
||||
config[@"constants"] = _consts;
|
||||
}
|
||||
|
||||
[self.methods enumerateObjectsUsingBlock:^(RCTModuleMethod *method, NSUInteger idx, __unused BOOL *stop) {
|
||||
config[@"methods"][method.JSMethodName] = @{
|
||||
@"methodID": @(idx),
|
||||
@"type": method.functionKind == RCTJavaScriptFunctionKindAsync ? @"remoteAsync" : @"remote",
|
||||
};
|
||||
}];
|
||||
|
||||
_config = [config copy];
|
||||
if (_constants) {
|
||||
config[@"constants"] = _constants;
|
||||
}
|
||||
|
||||
return _config;
|
||||
NSMutableDictionary *methodconfig = [[NSMutableDictionary alloc] init];
|
||||
[self.methods enumerateObjectsUsingBlock:^(RCTModuleMethod *method, NSUInteger idx, __unused BOOL *stop) {
|
||||
methodconfig[method.JSMethodName] = @{
|
||||
@"methodID": @(idx),
|
||||
@"type": method.functionKind == RCTJavaScriptFunctionKindAsync ? @"remoteAsync" : @"remote",
|
||||
};
|
||||
}];
|
||||
config[@"methods"] = [methodconfig copy];
|
||||
|
||||
return [config copy];
|
||||
}
|
||||
|
||||
- (dispatch_queue_t)queue
|
||||
|
@ -105,19 +105,9 @@ RCT_NOT_IMPLEMENTED(-init);
|
|||
}
|
||||
if (!_queue) {
|
||||
|
||||
// Need to cache queueNames because they aren't retained by dispatch_queue
|
||||
static NSMutableDictionary *queueNames;
|
||||
if (!queueNames) {
|
||||
queueNames = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
NSString *queueName = queueNames[_name];
|
||||
if (!queueName) {
|
||||
queueName = [NSString stringWithFormat:@"com.facebook.React.%@Queue", _name];
|
||||
queueNames[_name] = queueName;
|
||||
}
|
||||
|
||||
// Create new queue
|
||||
_queue = dispatch_queue_create(queueName.UTF8String, DISPATCH_QUEUE_SERIAL);
|
||||
// Create new queue (store queueName, as it isn't retained by dispatch_queue)
|
||||
_queueName = [NSString stringWithFormat:@"com.facebook.React.%@Queue", _name];
|
||||
_queue = dispatch_queue_create(_queueName.UTF8String, DISPATCH_QUEUE_SERIAL);
|
||||
|
||||
// assign it to the module
|
||||
if (implementsMethodQueue) {
|
||||
|
@ -133,7 +123,6 @@ RCT_NOT_IMPLEMENTED(-init);
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _queue;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,18 +23,18 @@
|
|||
@implementation RCTTouchHandler
|
||||
{
|
||||
__weak RCTBridge *_bridge;
|
||||
BOOL _dispatchedInitialTouches;
|
||||
|
||||
/**
|
||||
* Arrays managed in parallel tracking native touch object along with the
|
||||
* native view that was touched, and the React touch data dictionary.
|
||||
* This must be kept track of because `UIKit` destroys the touch targets
|
||||
* if touches are canceled and we have no other way to recover this information.
|
||||
* These must be kept track of because `UIKit` destroys the touch targets
|
||||
* if touches are canceled, and we have no other way to recover this info.
|
||||
*/
|
||||
NSMutableOrderedSet *_nativeTouches;
|
||||
NSMutableArray *_reactTouches;
|
||||
NSMutableArray *_touchViews;
|
||||
|
||||
BOOL _dispatchedInitialTouches;
|
||||
BOOL _recordingInteractionTiming;
|
||||
CFTimeInterval _mostRecentEnqueueJS;
|
||||
}
|
||||
|
@ -218,22 +218,29 @@ static BOOL RCTAnyTouchesChanged(NSSet *touches)
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (void)handleGestureUpdate:(UIGestureRecognizer *)gesture {
|
||||
// If the gesture just recognized, send all the touches over to JS as if they just began
|
||||
- (void)handleGestureUpdate:(__unused UIGestureRecognizer *)gesture
|
||||
{
|
||||
// If gesture just recognized, send all touches to JS as if they just began.
|
||||
if (self.state == UIGestureRecognizerStateBegan) {
|
||||
[self _updateAndDispatchTouches:[_nativeTouches set] eventName:@"topTouchStart" originatingTime:0];
|
||||
|
||||
// We store this flag separately from `state` because after a gesture is recognized, its `state` changes immediately but its action (that is, this method) isn't fired until dependent gesture recognizers have failed. We only want to send move/end/cancel touch updates if we've sent the touchStart events.
|
||||
// We store this flag separately from `state` because after a gesture is
|
||||
// recognized, its `state` changes immediately but its action (this
|
||||
// method) isn't fired until dependent gesture recognizers have failed. We
|
||||
// only want to send move/end/cancel touches if we've sent the touchStart.
|
||||
_dispatchedInitialTouches = YES;
|
||||
}
|
||||
// For the other states, we could dispatch the updates here but since we specifically send info about which touches changed, it's simpler to dispatch the updates from the raw touch methods below.
|
||||
|
||||
// For the other states, we could dispatch the updates here but since we
|
||||
// specifically send info about which touches changed, it's simpler to
|
||||
// dispatch the updates from the raw touch methods below.
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesBegan:touches withEvent:event];
|
||||
|
||||
// "start" has to record new touches before extracting the event.
|
||||
// "start" has to record new touches beforeckirjiuhucekbebjditeucultigvijfe extracting the event.
|
||||
// "end"/"cancel" needs to remove the touch *after* extracting the event.
|
||||
[self _recordNewTouches:touches];
|
||||
if (_dispatchedInitialTouches) {
|
||||
|
@ -296,7 +303,8 @@ static BOOL RCTAnyTouchesChanged(NSSet *touches)
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (void)reset {
|
||||
- (void)reset
|
||||
{
|
||||
_dispatchedInitialTouches = NO;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue