diff --git a/Libraries/Image/RCTImageLoaderProtocol.h b/Libraries/Image/RCTImageLoaderProtocol.h index 366fb7b57ceb6a..f1bb2689607e9d 100644 --- a/Libraries/Image/RCTImageLoaderProtocol.h +++ b/Libraries/Image/RCTImageLoaderProtocol.h @@ -14,6 +14,8 @@ #import #import +NS_ASSUME_NONNULL_BEGIN + /** * If available, RCTImageRedirectProtocol is invoked before loading an asset. * Implementation should return either a new URL or nil when redirection is @@ -132,3 +134,5 @@ typedef NS_ENUM(NSUInteger, RCTImageLoaderPriority) { - (void)setImageCache:(id)cache; @end + +NS_ASSUME_NONNULL_END diff --git a/Libraries/Image/RCTImageURLLoader.h b/Libraries/Image/RCTImageURLLoader.h index d950b46f745f70..866ae9ada61f09 100644 --- a/Libraries/Image/RCTImageURLLoader.h +++ b/Libraries/Image/RCTImageURLLoader.h @@ -10,9 +10,11 @@ #import #import +NS_ASSUME_NONNULL_BEGIN + typedef void (^RCTImageLoaderProgressBlock)(int64_t progress, int64_t total); typedef void (^RCTImageLoaderPartialLoadBlock)(UIImage *image); -typedef void (^RCTImageLoaderCompletionBlock)(NSError *error, UIImage *image); +typedef void (^RCTImageLoaderCompletionBlock)(NSError * _Nullable error, UIImage * _Nullable image); typedef dispatch_block_t RCTImageLoaderCancellationBlock; /** @@ -71,3 +73,5 @@ typedef dispatch_block_t RCTImageLoaderCancellationBlock; - (BOOL)shouldCacheLoadedImages; @end + +NS_ASSUME_NONNULL_END diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 4c5bc035c03165..8cca1a00b9d749 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -218,7 +218,24 @@ - (void)setRCTTurboModuleRegistry:(id)turboModuleRegistr - (void)didReceiveReloadCommand { - [self reloadWithReason:@"Command"]; +#if RCT_ENABLE_INSPECTOR + // Disable debugger to resume the JsVM & avoid thread locks while reloading + [RCTInspectorDevServerHelper disableDebugger]; +#endif + + [[NSNotificationCenter defaultCenter] postNotificationName:RCTBridgeWillReloadNotification object:self userInfo:nil]; + + /** + * Any thread + */ + dispatch_async(dispatch_get_main_queue(), ^{ + // WARNING: Invalidation is async, so it may not finish before re-setting up the bridge, + // causing some issues. TODO: revisit this post-Fabric/TurboModule. + [self invalidate]; + // Reload is a special case, do not preserve launchOptions and treat reload as a fresh start + self->_launchOptions = nil; + [self setUp]; + }); } - (NSArray *)moduleClasses @@ -269,7 +286,7 @@ - (BOOL)moduleIsInitialized:(Class)moduleClass */ - (void)reload { - [self reloadWithReason:@"Unknown from bridge"]; + RCTTriggerReloadCommandListeners(@"Unknown from bridge"); } /** @@ -277,24 +294,7 @@ - (void)reload */ - (void)reloadWithReason:(NSString *)reason { -#if RCT_ENABLE_INSPECTOR - // Disable debugger to resume the JsVM & avoid thread locks while reloading - [RCTInspectorDevServerHelper disableDebugger]; -#endif - - [[NSNotificationCenter defaultCenter] postNotificationName:RCTBridgeWillReloadNotification object:self userInfo:nil]; - - /** - * Any thread - */ - dispatch_async(dispatch_get_main_queue(), ^{ - // WARNING: Invalidation is async, so it may not finish before re-setting up the bridge, - // causing some issues. TODO: revisit this post-Fabric/TurboModule. - [self invalidate]; - // Reload is a special case, do not preserve launchOptions and treat reload as a fresh start - self->_launchOptions = nil; - [self setUp]; - }); + RCTTriggerReloadCommandListeners(reason); } - (void)onFastRefresh diff --git a/React/Base/RCTJSStackFrame.h b/React/Base/RCTJSStackFrame.h index 43592ec18d0c8e..1a66e29e58740e 100644 --- a/React/Base/RCTJSStackFrame.h +++ b/React/Base/RCTJSStackFrame.h @@ -13,13 +13,13 @@ @property (nonatomic, copy, readonly) NSString *file; @property (nonatomic, readonly) NSInteger lineNumber; @property (nonatomic, readonly) NSInteger column; -@property (nonatomic, readonly) NSInteger collapse; +@property (nonatomic, readonly) BOOL collapse; - (instancetype)initWithMethodName:(NSString *)methodName file:(NSString *)file lineNumber:(NSInteger)lineNumber column:(NSInteger)column - collapse:(NSInteger)collapse; + collapse:(BOOL)collapse; - (NSDictionary *)toDictionary; + (instancetype)stackFrameWithLine:(NSString *)line; diff --git a/React/Base/RCTJSStackFrame.m b/React/Base/RCTJSStackFrame.m index 2458626f349dd7..1e3d5498eaf777 100644 --- a/React/Base/RCTJSStackFrame.m +++ b/React/Base/RCTJSStackFrame.m @@ -57,7 +57,7 @@ - (instancetype)initWithMethodName:(NSString *)methodName file:(NSString *)file lineNumber:(NSInteger)lineNumber column:(NSInteger)column - collapse:(NSInteger)collapse + collapse:(BOOL)collapse { if (self = [super init]) { _methodName = methodName; @@ -100,7 +100,7 @@ + (instancetype)stackFrameWithLine:(NSString *)line file:file lineNumber:[lineNumber integerValue] column:[column integerValue] - collapse:@NO]; + collapse:NO]; } + (instancetype)stackFrameWithDictionary:(NSDictionary *)dict @@ -109,7 +109,7 @@ + (instancetype)stackFrameWithDictionary:(NSDictionary *)dict file:dict[@"file"] lineNumber:[RCTNilIfNull(dict[@"lineNumber"]) integerValue] column:[RCTNilIfNull(dict[@"column"]) integerValue] - collapse:[RCTNilIfNull(dict[@"collapse"]) integerValue]]; + collapse:[RCTNilIfNull(dict[@"collapse"]) boolValue]]; } + (NSArray *)stackFramesWithLines:(NSString *)lines diff --git a/React/Base/RCTKeyCommands.m b/React/Base/RCTKeyCommands.m index 220a8b321f09cf..7e4ccb2a6a153b 100644 --- a/React/Base/RCTKeyCommands.m +++ b/React/Base/RCTKeyCommands.m @@ -113,7 +113,7 @@ + (void)initialize - (void)handleKeyUIEventSwizzle:(UIEvent *)event { NSString *modifiedInput = nil; - UIKeyModifierFlags *modifierFlags = nil; + UIKeyModifierFlags modifierFlags = 0; BOOL isKeyDown = NO; if ([event respondsToSelector:@selector(_modifiedInput)]) { diff --git a/React/Base/RCTModuleData.h b/React/Base/RCTModuleData.h index 04d6271eeedd5b..5ff81532eb34b6 100644 --- a/React/Base/RCTModuleData.h +++ b/React/Base/RCTModuleData.h @@ -97,4 +97,4 @@ typedef id (^RCTBridgeModuleProvider)(void); @end RCT_EXTERN void RCTSetIsMainQueueExecutionOfConstantsToExportDisabled(BOOL val); -RCT_EXTERN BOOL RCTIsMainQueueExecutionOfConstantsToExportDisabled(); +RCT_EXTERN BOOL RCTIsMainQueueExecutionOfConstantsToExportDisabled(void); diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 171005a4f02cf8..594b1cbeec6536 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -1119,26 +1119,6 @@ - (void)setUp { } -- (void)reload -{ - if (!_valid) { - RCTLogWarn( - @"Attempting to reload bridge before it's valid: %@. Try restarting the development server if connected.", - self); - } - RCTTriggerReloadCommandListeners(@"Unknown from cxx bridge"); -} - -- (void)reloadWithReason:(NSString *)reason -{ - if (!_valid) { - RCTLogWarn( - @"Attempting to reload bridge before it's valid: %@. Try restarting the development server if connected.", - self); - } - RCTTriggerReloadCommandListeners(reason); -} - - (Class)executorClass { return _parentBridge.executorClass; diff --git a/React/Modules/RCTUIManagerUtils.m b/React/Modules/RCTUIManagerUtils.m index 54f77f67a6e4d2..7b19bf2cf3534f 100644 --- a/React/Modules/RCTUIManagerUtils.m +++ b/React/Modules/RCTUIManagerUtils.m @@ -7,7 +7,7 @@ #import "RCTUIManagerUtils.h" -#import +#import #import "RCTAssert.h" @@ -98,6 +98,6 @@ void RCTUnsafeExecuteOnUIManagerQueueSync(dispatch_block_t block) NSNumber *RCTAllocateRootViewTag() { // Numbering of these tags goes from 1, 11, 21, 31, ..., 100501, ... - static int64_t rootViewTagCounter = -1; - return @(OSAtomicIncrement64(&rootViewTagCounter) * 10 + 1); + static _Atomic int64_t rootViewTagCounter = 0; + return @(atomic_fetch_add_explicit(&rootViewTagCounter, 1, memory_order_relaxed) * 10 + 1); } diff --git a/React/Profiler/RCTProfile.m b/React/Profiler/RCTProfile.m index 12d42000e3cdf5..149451ad6bfeee 100644 --- a/React/Profiler/RCTProfile.m +++ b/React/Profiler/RCTProfile.m @@ -22,6 +22,7 @@ #import "RCTDefines.h" #import "RCTLog.h" #import "RCTModuleData.h" +#import "RCTReloadCommand.h" #import "RCTUIManager.h" #import "RCTUIManagerUtils.h" #import "RCTUtils.h" @@ -378,7 +379,7 @@ + (void)vsync:(CADisplayLink *)displayLink + (void)reload { - [RCTProfilingBridge() reloadWithReason:@"Profiling controls"]; + RCTTriggerReloadCommandListeners(@"Profiling controls"); } + (void)toggle:(UIButton *)target diff --git a/React/Views/RCTComponentData.h b/React/Views/RCTComponentData.h index b61dc4011e1f22..614ca5f0f94f4c 100644 --- a/React/Views/RCTComponentData.h +++ b/React/Views/RCTComponentData.h @@ -15,6 +15,8 @@ @class RCTShadowView; @class UIView; +NS_ASSUME_NONNULL_BEGIN + @interface RCTComponentData : NSObject @property (nonatomic, readonly) Class managerClass; @@ -23,7 +25,7 @@ - (instancetype)initWithManagerClass:(Class)managerClass bridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER; -- (UIView *)createViewWithTag:(NSNumber *)tag rootTag:(NSNumber *)rootTag; +- (UIView *)createViewWithTag:(nullable NSNumber *)tag rootTag:(nullable NSNumber *)rootTag; - (RCTShadowView *)createShadowViewWithTag:(NSNumber *)tag; - (void)setProps:(NSDictionary *)props forView:(id)view; - (void)setProps:(NSDictionary *)props forShadowView:(RCTShadowView *)shadowView; @@ -34,3 +36,5 @@ - (NSDictionary *)viewConfig; @end + +NS_ASSUME_NONNULL_END diff --git a/React/Views/RCTComponentData.m b/React/Views/RCTComponentData.m index f4ecbb1b042764..c8c893863e2b32 100644 --- a/React/Views/RCTComponentData.m +++ b/React/Views/RCTComponentData.m @@ -63,7 +63,7 @@ - (RCTViewManager *)manager RCT_NOT_IMPLEMENTED(-(instancetype)init) -- (UIView *)createViewWithTag:(NSNumber *)tag rootTag:(NSNumber *)rootTag +- (UIView *)createViewWithTag:(nullable NSNumber *)tag rootTag:(nullable NSNumber *)rootTag { RCTAssertMainQueue();