diff --git a/.buckconfig b/.buckconfig index 0740647479601e..3d98e74d71e06a 100644 --- a/.buckconfig +++ b/.buckconfig @@ -1,6 +1,6 @@ [android] - target = android-29 + target = android-30 [download] max_number_of_retries = 3 diff --git a/.circleci/Dockerfiles/Dockerfile.android b/.circleci/Dockerfiles/Dockerfile.android index 5b313b53bfa679..92bf645af1d260 100644 --- a/.circleci/Dockerfiles/Dockerfile.android +++ b/.circleci/Dockerfiles/Dockerfile.android @@ -14,7 +14,7 @@ # and build a Android application that can be used to run the # tests specified in the scripts/ directory. # -FROM reactnativecommunity/react-native-android:2.1 +FROM reactnativecommunity/react-native-android:3.2 LABEL Description="React Native Android Test Image" LABEL maintainer="Héctor Ramos " diff --git a/.circleci/config.yml b/.circleci/config.yml index ca3e88fc57bad4..dc1337a2e107e0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -35,7 +35,7 @@ executors: reactnativeandroid: <<: *defaults docker: - - image: reactnativecommunity/react-native-android:2.1 + - image: reactnativecommunity/react-native-android:3.2 resource_class: "large" environment: - TERM: "dumb" @@ -617,7 +617,7 @@ jobs: environment: - ANDROID_HOME: "C:\\Android\\android-sdk" - ANDROID_NDK: "C:\\Android\\android-sdk\\ndk\\20.1.5948944" - - ANDROID_BUILD_VERSION: 28 + - ANDROID_BUILD_VERSION: 30 - ANDROID_TOOLS_VERSION: 29.0.3 - GRADLE_OPTS: -Dorg.gradle.daemon=false - NDK_VERSION: 20.1.5948944 diff --git a/.github/label-actions.yml b/.github/respond-to-issue-based-on-label.yml similarity index 96% rename from .github/label-actions.yml rename to .github/respond-to-issue-based-on-label.yml index 8cef0647e0068c..65131ff0840db0 100644 --- a/.github/label-actions.yml +++ b/.github/respond-to-issue-based-on-label.yml @@ -1,4 +1,4 @@ -# Configuration for Label Actions - https://github.com/marketplace/actions/label-actions +# Configuration for Respond To Issue Based on Label https://github.com/marketplace/actions/respond-to-issue-based-on-label "Type: Invalid": close: true diff --git a/.github/workflows/process-label-actions.yml b/.github/workflows/on-issue-labeled.yml similarity index 54% rename from .github/workflows/process-label-actions.yml rename to .github/workflows/on-issue-labeled.yml index 2c63100f6e8392..e68682b2ecb71b 100644 --- a/.github/workflows/process-label-actions.yml +++ b/.github/workflows/on-issue-labeled.yml @@ -1,16 +1,16 @@ -name: Label Actions +name: On Issue Labeled # This workflow is triggered when a label is added to an issue. on: issues: types: labeled jobs: - processLabelAction: - name: Process Label Action + respondToIssueBasedOnLabel: + name: Respond to Issue Based on Label runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Process Label Action - uses: hramos/label-actions@v1 + - name: Respond to Issue Based on Label + uses: hramos/respond-to-issue-based-on-label@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Libraries/Animated/createAnimatedComponent.js b/Libraries/Animated/createAnimatedComponent.js index 8e8638edb63d58..fda18f0af80744 100644 --- a/Libraries/Animated/createAnimatedComponent.js +++ b/Libraries/Animated/createAnimatedComponent.js @@ -87,6 +87,8 @@ function createAnimatedComponent( // When called during the first render, `_component` is always null. // Therefore, even if a component is rendered in Fabric, we can't detect // that until ref is set, which happens sometime after the first render. + // In cases where this value switching between "false" and "true" on Fabric + // causes issues, add an additional check for _component nullity. if (this._component == null) { return false; } @@ -221,10 +223,24 @@ function createAnimatedComponent( const {style: passthruStyle = {}, ...passthruProps} = this.props.passthroughAnimatedPropExplicitValues || {}; const mergedStyle = {...style, ...passthruStyle}; + + // On Fabric, we always want to ensure the container Animated View is *not* + // flattened. + // Because we do not get a host component ref immediately and thus cannot + // do a proper Fabric vs non-Fabric detection immediately, we default to assuming + // that Fabric *is* enabled until we know otherwise. + // Thus, in Fabric, this view will never be flattened. In non-Fabric, the view will + // not be flattened during the initial render but may be flattened in the second render + // and onwards. + const forceNativeIdFabric = + (this._component == null && + (options?.collapsable === false || props.collapsable !== true)) || + this._isFabric(); + const forceNativeId = props.collapsable ?? (this._propsAnimated.__isNative || - this._isFabric() || + forceNativeIdFabric || options?.collapsable === false); // The native driver updates views directly through the UI thread so we // have to make sure the view doesn't get optimized away because it cannot @@ -283,6 +299,8 @@ function createAnimatedComponent( this._propsAnimated && this._propsAnimated.__detach(); this._detachNativeEvents(); this._markUpdateComplete(); + this._component = null; + this._prevComponent = null; } } diff --git a/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js b/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js index 4c542bddfacc9e..71210f989d7e20 100644 --- a/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js +++ b/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js @@ -4,22 +4,20 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow strict-local * @format + * @flow strict-local */ -import {type HostComponent} from '../../Renderer/shims/ReactNativeTypes'; -import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; -import {type ViewProps as Props} from '../View/ViewPropTypes'; +import codegenNativeComponent from '../../Utilities/codegenNativeComponent'; +import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import type {ViewProps} from '../View/ViewPropTypes'; -const AndroidHorizontalScrollContentViewNativeComponent: HostComponent = NativeComponentRegistry.get( - 'AndroidHorizontalScrollContentView', - () => ({ - uiViewClassName: 'AndroidHorizontalScrollContentView', - bubblingEventTypes: {}, - directEventTypes: {}, - validAttributes: {}, - }), -); +type NativeProps = $ReadOnly<{| + ...ViewProps, +|}>; -export default AndroidHorizontalScrollContentViewNativeComponent; +type NativeType = HostComponent; + +export default (codegenNativeComponent( + 'AndroidHorizontalScrollContentView', +): NativeType); diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 39967a67111649..646e7d981a1ecf 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -1083,6 +1083,13 @@ function InternalTextInput(props: Props): React.Node { ], ); + // Hide caret during test runs due to a flashing caret + // makes screenshot tests flakey + let caretHidden = props.caretHidden; + if (Platform.isTesting) { + caretHidden = true; + } + // TextInput handles onBlur and onFocus events // so omitting onBlur and onFocus pressability handlers here. const {onBlur, onFocus, ...eventHandlers} = usePressability(config) || {}; @@ -1105,6 +1112,7 @@ function InternalTextInput(props: Props): React.Node { {...eventHandlers} accessible={accessible} blurOnSubmit={blurOnSubmit} + caretHidden={caretHidden} dataDetectorTypes={props.dataDetectorTypes} focusable={focusable} mostRecentEventCount={mostRecentEventCount} @@ -1143,6 +1151,7 @@ function InternalTextInput(props: Props): React.Node { accessible={accessible} autoCapitalize={autoCapitalize} blurOnSubmit={blurOnSubmit} + caretHidden={caretHidden} children={children} disableFullscreenUI={props.disableFullscreenUI} focusable={focusable} diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index 19012b8c9e581e..540a865d70f1a1 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -373,6 +373,8 @@ class FlatList extends React.PureComponent, void> { | ?React.ElementRef | ?React.ElementRef { if (this._listRef) { + /* $FlowFixMe[incompatible-return] Suppresses errors found when fixing + * TextInput typing */ return this._listRef.getScrollRef(); } } diff --git a/Libraries/NativeAnimation/React-RCTAnimation.podspec b/Libraries/NativeAnimation/React-RCTAnimation.podspec index 547534b755b562..2138829a1de837 100644 --- a/Libraries/NativeAnimation/React-RCTAnimation.podspec +++ b/Libraries/NativeAnimation/React-RCTAnimation.podspec @@ -39,9 +39,9 @@ Pod::Spec.new do |s| } s.dependency "RCT-Folly", folly_version + s.dependency "FBReactNativeSpec", version s.dependency "RCTTypeSafety", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version - s.dependency "FBReactNativeSpec", version s.dependency "React-Core/RCTAnimationHeaders", version end diff --git a/Libraries/ReactNative/AppRegistry.js b/Libraries/ReactNative/AppRegistry.js index c08d003ac054bb..894d6a291a9c11 100644 --- a/Libraries/ReactNative/AppRegistry.js +++ b/Libraries/ReactNative/AppRegistry.js @@ -124,6 +124,7 @@ const AppRegistry = { showArchitectureIndicator, scopedPerformanceLogger, appKey === 'LogBox', + appKey, ); }, }; diff --git a/Libraries/ReactNative/renderApplication.js b/Libraries/ReactNative/renderApplication.js index 747b8ac36f251c..870b1e28968bf0 100644 --- a/Libraries/ReactNative/renderApplication.js +++ b/Libraries/ReactNative/renderApplication.js @@ -28,12 +28,13 @@ function renderApplication( showArchitectureIndicator?: boolean, scopedPerformanceLogger?: IPerformanceLogger, isLogBox?: boolean, + debugName?: string, ) { invariant(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag); const performanceLogger = scopedPerformanceLogger ?? GlobalPerformanceLogger; - const renderable = ( + let renderable = ( ( ); + if (__DEV__ && debugName) { + const RootComponentWithMeaningfulName = ({children}) => children; + RootComponentWithMeaningfulName.displayName = `${debugName}(RootComponent)`; + renderable = ( + + {renderable} + + ); + } + performanceLogger.startTimespan('renderApplication_React_render'); performanceLogger.setExtra('usedReactFabric', fabric ? '1' : '0'); diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index 552b118556aaf0..3811bfa35ad91c 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -99,7 +99,7 @@ export type PartialViewConfig = $ReadOnly<{ validAttributes?: PartialAttributeConfiguration, }>; -export type NativeMethods = { +export type NativeMethods = {| blur(): void, focus(): void, measure(callback: MeasureOnSuccessCallback): void, @@ -110,8 +110,7 @@ export type NativeMethods = { onFail?: () => void, ): void, setNativeProps(nativeProps: {...}): void, - ... -}; +|}; export type HostComponent = AbstractComponent>; diff --git a/React/Base/RCTBridge.h b/React/Base/RCTBridge.h index 36678d39629e4e..87c1a616bd13e1 100644 --- a/React/Base/RCTBridge.h +++ b/React/Base/RCTBridge.h @@ -160,6 +160,10 @@ RCT_EXTERN void RCTEnableTurboModuleEagerInit(BOOL enabled); RCT_EXTERN BOOL RCTTurboModuleSharedMutexInitEnabled(void); RCT_EXTERN void RCTEnableTurboModuleSharedMutexInit(BOOL enabled); +// Turn on TurboModule shared mutex initialization +RCT_EXTERN BOOL RCTTurboModuleBlockGuardEnabled(void); +RCT_EXTERN void RCTEnableTurboModuleBlockGuard(BOOL enabled); + /** * Async batched bridge used to communicate with the JavaScript application. */ diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index cee883f875d980..ee31c54c379256 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -135,6 +135,17 @@ void RCTEnableTurboModuleSharedMutexInit(BOOL enabled) turboModuleSharedMutexInitEnabled = enabled; } +static BOOL turboModuleBlockGuardEnabled = NO; +BOOL RCTTurboModuleBlockGuardEnabled(void) +{ + return turboModuleBlockGuardEnabled; +} + +void RCTEnableTurboModuleBlockGuard(BOOL enabled) +{ + turboModuleBlockGuardEnabled = enabled; +} + @interface RCTBridge () @end diff --git a/React/Base/RCTTouchHandler.m b/React/Base/RCTTouchHandler.m index fc32afb0a79cfc..bfcadc3d607335 100644 --- a/React/Base/RCTTouchHandler.m +++ b/React/Base/RCTTouchHandler.m @@ -8,6 +8,7 @@ #import "RCTTouchHandler.h" #import +#import #import "RCTAssert.h" #import "RCTBridge.h" @@ -39,6 +40,10 @@ @implementation RCTTouchHandler { __weak UIView *_cachedRootView; + // See Touch.h and usage. This gives us a time-basis for a monotonic + // clock that acts like a timestamp of milliseconds elapsed since UNIX epoch. + NSTimeInterval _unixEpochBasisTime; + uint16_t _coalescingKey; } @@ -53,6 +58,9 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge _reactTouches = [NSMutableArray new]; _touchViews = [NSMutableArray new]; + // Get a UNIX epoch basis time: + _unixEpochBasisTime = [[NSDate date] timeIntervalSince1970] - [NSProcessInfo processInfo].systemUptime; + // `cancelsTouchesInView` and `delaysTouches*` are needed in order to be used as a top level // event delegated recognizer. Otherwise, lower-level components not built // using RCT, will fail to recognize gestures. @@ -159,7 +167,7 @@ - (void)_updateReactTouchAtIndex:(NSInteger)touchIndex reactTouch[@"pageY"] = @(RCTSanitizeNaNValue(rootViewLocation.y, @"touchEvent.pageY")); reactTouch[@"locationX"] = @(RCTSanitizeNaNValue(touchViewLocation.x, @"touchEvent.locationX")); reactTouch[@"locationY"] = @(RCTSanitizeNaNValue(touchViewLocation.y, @"touchEvent.locationY")); - reactTouch[@"timestamp"] = @(nativeTouch.timestamp * 1000); // in ms, for JS + reactTouch[@"timestamp"] = @((_unixEpochBasisTime + nativeTouch.timestamp) * 1000); // in ms, for JS // TODO: force for a 'normal' touch is usually 1.0; // should we expose a `normalTouchForce` constant somewhere (which would diff --git a/React/CoreModules/RCTDevSettings.mm b/React/CoreModules/RCTDevSettings.mm index 1fde6654bde424..05ce7049d129b8 100644 --- a/React/CoreModules/RCTDevSettings.mm +++ b/React/CoreModules/RCTDevSettings.mm @@ -166,6 +166,16 @@ - (instancetype)initWithDataSource:(id)dataSource return self; } +#if RCT_ENABLE_INSPECTOR +// In bridgeless mode, `setBridge` is not called, so dev server connection +// must be kicked off here. +- (void)setBundleURL:(NSURL *)bundleURL +{ + _bundleURL = bundleURL; + [RCTInspectorDevServerHelper connectWithBundleURL:_bundleURL]; +} +#endif + - (void)setBridge:(RCTBridge *)bridge { [super setBridge:bridge]; diff --git a/React/Fabric/RCTScheduler.h b/React/Fabric/RCTScheduler.h index 55670daca64646..6eca003c03356b 100644 --- a/React/Fabric/RCTScheduler.h +++ b/React/Fabric/RCTScheduler.h @@ -14,6 +14,7 @@ #import #import #import +#import #import NS_ASSUME_NONNULL_BEGIN @@ -47,26 +48,13 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithToolbox:(facebook::react::SchedulerToolbox)toolbox; -- (void)startSurfaceWithSurfaceId:(facebook::react::SurfaceId)surfaceId - moduleName:(NSString *)moduleName - initialProps:(NSDictionary *)initialProps - layoutConstraints:(facebook::react::LayoutConstraints)layoutConstraints - layoutContext:(facebook::react::LayoutContext)layoutContext; - -- (void)stopSurfaceWithSurfaceId:(facebook::react::SurfaceId)surfaceId; - -- (CGSize)measureSurfaceWithLayoutConstraints:(facebook::react::LayoutConstraints)layoutConstraints - layoutContext:(facebook::react::LayoutContext)layoutContext - surfaceId:(facebook::react::SurfaceId)surfaceId; - -- (void)constraintSurfaceLayoutWithLayoutConstraints:(facebook::react::LayoutConstraints)layoutConstraints - layoutContext:(facebook::react::LayoutContext)layoutContext - surfaceId:(facebook::react::SurfaceId)surfaceId; +- (void)registerSurface:(facebook::react::SurfaceHandler const &)surfaceHandler; +- (void)unregisterSurface:(facebook::react::SurfaceHandler const &)surfaceHandler; - (facebook::react::ComponentDescriptor const *)findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN: (facebook::react::ComponentHandle)handle; -- (facebook::react::MountingCoordinator::Shared)mountingCoordinatorWithSurfaceId:(facebook::react::SurfaceId)surfaceId; +- (void)setupAnimationDriver:(facebook::react::SurfaceHandler const &)surfaceHandler; - (void)onAnimationStarted; diff --git a/React/Fabric/RCTScheduler.mm b/React/Fabric/RCTScheduler.mm index 3e7281be63c02c..b9d38d6cd869ef 100644 --- a/React/Fabric/RCTScheduler.mm +++ b/React/Fabric/RCTScheduler.mm @@ -139,43 +139,14 @@ - (void)dealloc _animationDriver = nullptr; } -- (void)startSurfaceWithSurfaceId:(SurfaceId)surfaceId - moduleName:(NSString *)moduleName - initialProps:(NSDictionary *)initialProps - layoutConstraints:(LayoutConstraints)layoutConstraints - layoutContext:(LayoutContext)layoutContext +- (void)registerSurface:(facebook::react::SurfaceHandler const &)surfaceHandler { - SystraceSection s("-[RCTScheduler startSurfaceWithSurfaceId:...]"); - - auto props = convertIdToFollyDynamic(initialProps); - _scheduler->startSurface(surfaceId, RCTStringFromNSString(moduleName), props, layoutConstraints, layoutContext); - - _scheduler->findMountingCoordinator(surfaceId)->setMountingOverrideDelegate(_animationDriver); - - _scheduler->renderTemplateToSurface( - surfaceId, props.getDefault("navigationConfig").getDefault("initialUITemplate", "").getString()); -} - -- (void)stopSurfaceWithSurfaceId:(SurfaceId)surfaceId -{ - SystraceSection s("-[RCTScheduler stopSurfaceWithSurfaceId:]"); - _scheduler->stopSurface(surfaceId); -} - -- (CGSize)measureSurfaceWithLayoutConstraints:(LayoutConstraints)layoutConstraints - layoutContext:(LayoutContext)layoutContext - surfaceId:(SurfaceId)surfaceId -{ - SystraceSection s("-[RCTScheduler measureSurfaceWithLayoutConstraints:]"); - return RCTCGSizeFromSize(_scheduler->measureSurface(surfaceId, layoutConstraints, layoutContext)); + _scheduler->registerSurface(surfaceHandler); } -- (void)constraintSurfaceLayoutWithLayoutConstraints:(LayoutConstraints)layoutConstraints - layoutContext:(LayoutContext)layoutContext - surfaceId:(SurfaceId)surfaceId +- (void)unregisterSurface:(facebook::react::SurfaceHandler const &)surfaceHandler { - SystraceSection s("-[RCTScheduler constraintSurfaceLayoutWithLayoutConstraints:]"); - _scheduler->constraintSurfaceLayout(surfaceId, layoutConstraints, layoutContext); + _scheduler->unregisterSurface(surfaceHandler); } - (ComponentDescriptor const *)findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN:(ComponentHandle)handle @@ -183,9 +154,9 @@ - (ComponentDescriptor const *)findComponentDescriptorByHandle_DO_NOT_USE_THIS_I return _scheduler->findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN(handle); } -- (MountingCoordinator::Shared)mountingCoordinatorWithSurfaceId:(SurfaceId)surfaceId +- (void)setupAnimationDriver:(facebook::react::SurfaceHandler const &)surfaceHandler { - return _scheduler->findMountingCoordinator(surfaceId); + surfaceHandler.getMountingCoordinator()->setMountingOverrideDelegate(_animationDriver); } - (void)onAnimationStarted diff --git a/React/Fabric/RCTSurfacePresenter.h b/React/Fabric/RCTSurfacePresenter.h index 6293ef6167ce89..0053a376ee1c17 100644 --- a/React/Fabric/RCTSurfacePresenter.h +++ b/React/Fabric/RCTSurfacePresenter.h @@ -11,6 +11,7 @@ #import #import #import +#import #import NS_ASSUME_NONNULL_BEGIN @@ -45,34 +46,25 @@ NS_ASSUME_NONNULL_BEGIN @interface RCTSurfacePresenter (Surface) -/** +/* * Surface uses these methods to register itself in the Presenter. */ - (void)registerSurface:(RCTFabricSurface *)surface; - (void)unregisterSurface:(RCTFabricSurface *)surface; -- (void)setProps:(NSDictionary *)props surface:(RCTFabricSurface *)surface; +@property (readonly) RCTMountingManager *mountingManager; - (nullable RCTFabricSurface *)surfaceForRootTag:(ReactTag)rootTag; -/** - * Measures the Surface with given constraints. - */ -- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize - maximumSize:(CGSize)maximumSize - surface:(RCTFabricSurface *)surface; - -/** - * Sets `minimumSize` and `maximumSize` layout constraints for the Surface. - */ -- (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize surface:(RCTFabricSurface *)surface; - - (BOOL)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag props:(NSDictionary *)props; -- (BOOL)synchronouslyWaitSurface:(RCTFabricSurface *)surface timeout:(NSTimeInterval)timeout; +- (void)setupAnimationDriverWithSurfaceHandler:(facebook::react::SurfaceHandler const &)surfaceHandler; +/* + * Deprecated. + * Use `RCTMountingTransactionObserverCoordinator` instead. + */ - (void)addObserver:(id)observer; - - (void)removeObserver:(id)observer; /* diff --git a/React/Fabric/RCTSurfacePresenter.mm b/React/Fabric/RCTSurfacePresenter.mm index e982243d62e849..bd11901c67ff07 100644 --- a/React/Fabric/RCTSurfacePresenter.mm +++ b/React/Fabric/RCTSurfacePresenter.mm @@ -40,25 +40,6 @@ using namespace facebook::react; -static inline LayoutConstraints RCTGetLayoutConstraintsForSize(CGSize minimumSize, CGSize maximumSize) -{ - return { - .minimumSize = RCTSizeFromCGSize(minimumSize), - .maximumSize = RCTSizeFromCGSize(maximumSize), - .layoutDirection = RCTLayoutDirection([[RCTI18nUtil sharedInstance] isRTL]), - }; -} - -static inline LayoutContext RCTGetLayoutContext(CGPoint viewportOffset) -{ - return { - .pointScaleFactor = RCTScreenScale(), - .swapLeftAndRightInRTL = - [[RCTI18nUtil sharedInstance] isRTL] && [[RCTI18nUtil sharedInstance] doLeftAndRightSwapInRTL], - .fontSizeMultiplier = RCTFontSizeMultiplier(), - .viewportOffset = RCTPointFromCGPoint(viewportOffset)}; -} - static dispatch_queue_t RCTGetBackgroundQueue() { static dispatch_queue_t queue; @@ -119,16 +100,16 @@ - (instancetype)initWithContextContainer:(ContextContainer::Shared)contextContai _observers = [NSMutableArray array]; _scheduler = [self _createScheduler]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(_handleContentSizeCategoryDidChangeNotification:) - name:UIContentSizeCategoryDidChangeNotification - object:nil]; } return self; } +- (RCTMountingManager *)mountingManager +{ + return _mountingManager; +} + - (RCTScheduler *_Nullable)_scheduler { std::lock_guard lock(_schedulerAccessMutex); @@ -163,10 +144,10 @@ - (void)setRuntimeExecutor:(RuntimeExecutor)runtimeExecutor - (void)registerSurface:(RCTFabricSurface *)surface { - RCTScheduler *scheduler = [self _scheduler]; [_surfaceRegistry registerSurface:surface]; + RCTScheduler *scheduler = [self _scheduler]; if (scheduler) { - [self _startSurface:surface scheduler:scheduler]; + [scheduler registerSurface:surface.surfaceHandler]; } } @@ -174,54 +155,16 @@ - (void)unregisterSurface:(RCTFabricSurface *)surface { RCTScheduler *scheduler = [self _scheduler]; if (scheduler) { - [self _stopSurface:surface scheduler:scheduler]; + [scheduler unregisterSurface:surface.surfaceHandler]; } [_surfaceRegistry unregisterSurface:surface]; } -- (void)setProps:(NSDictionary *)props surface:(RCTFabricSurface *)surface -{ - RCTScheduler *scheduler = [self _scheduler]; - if (scheduler) { - [self _stopSurface:surface scheduler:scheduler]; - [self _startSurface:surface scheduler:scheduler]; - } -} - - (RCTFabricSurface *)surfaceForRootTag:(ReactTag)rootTag { return [_surfaceRegistry surfaceForRootTag:rootTag]; } -- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize - maximumSize:(CGSize)maximumSize - surface:(RCTFabricSurface *)surface -{ - RCTScheduler *scheduler = [self _scheduler]; - if (!scheduler) { - return minimumSize; - } - LayoutContext layoutContext = RCTGetLayoutContext(surface.viewportOffset); - LayoutConstraints layoutConstraints = RCTGetLayoutConstraintsForSize(minimumSize, maximumSize); - return [scheduler measureSurfaceWithLayoutConstraints:layoutConstraints - layoutContext:layoutContext - surfaceId:surface.rootTag]; -} - -- (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize surface:(RCTFabricSurface *)surface -{ - RCTScheduler *scheduler = [self _scheduler]; - if (!scheduler) { - return; - } - - LayoutContext layoutContext = RCTGetLayoutContext(surface.viewportOffset); - LayoutConstraints layoutConstraints = RCTGetLayoutConstraintsForSize(minimumSize, maximumSize); - [scheduler constraintSurfaceLayoutWithLayoutConstraints:layoutConstraints - layoutContext:layoutContext - surfaceId:surface.rootTag]; -} - - (UIView *)findComponentViewWithTag_DO_NOT_USE_DEPRECATED:(NSInteger)tag { UIView *componentView = @@ -253,22 +196,9 @@ - (BOOL)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag props:(NSDictiona return YES; } -- (BOOL)synchronouslyWaitSurface:(RCTFabricSurface *)surface timeout:(NSTimeInterval)timeout +- (void)setupAnimationDriverWithSurfaceHandler:(facebook::react::SurfaceHandler const &)surfaceHandler { - RCTScheduler *scheduler = [self _scheduler]; - if (!scheduler) { - return NO; - } - - auto mountingCoordinator = [scheduler mountingCoordinatorWithSurfaceId:surface.rootTag]; - - if (!mountingCoordinator->waitForTransaction(std::chrono::duration(timeout))) { - return NO; - } - - [_mountingManager scheduleTransaction:mountingCoordinator]; - - return YES; + [[self _scheduler] setupAnimationDriver:surfaceHandler]; } - (BOOL)suspend @@ -377,39 +307,12 @@ - (RCTScheduler *)_createScheduler return scheduler; } -- (void)_startSurface:(RCTFabricSurface *)surface scheduler:(RCTScheduler *)scheduler -{ - RCTMountingManager *mountingManager = _mountingManager; - RCTExecuteOnMainQueue(^{ - [mountingManager attachSurfaceToView:surface.view surfaceId:surface.rootTag]; - }); - - LayoutContext layoutContext = RCTGetLayoutContext(surface.viewportOffset); - - LayoutConstraints layoutConstraints = RCTGetLayoutConstraintsForSize(surface.minimumSize, surface.maximumSize); - - [scheduler startSurfaceWithSurfaceId:surface.rootTag - moduleName:surface.moduleName - initialProps:surface.properties - layoutConstraints:layoutConstraints - layoutContext:layoutContext]; -} - -- (void)_stopSurface:(RCTFabricSurface *)surface scheduler:(RCTScheduler *)scheduler -{ - [scheduler stopSurfaceWithSurfaceId:surface.rootTag]; - - RCTMountingManager *mountingManager = _mountingManager; - RCTExecuteOnMainQueue(^{ - [mountingManager detachSurfaceFromView:surface.view surfaceId:surface.rootTag]; - }); -} - - (void)_startAllSurfacesWithScheduler:(RCTScheduler *)scheduler { [_surfaceRegistry enumerateWithBlock:^(NSEnumerator *enumerator) { for (RCTFabricSurface *surface in enumerator) { - [self _startSurface:surface scheduler:scheduler]; + [scheduler registerSurface:surface.surfaceHandler]; + [surface start]; } }]; } @@ -418,24 +321,8 @@ - (void)_stopAllSurfacesWithScheduler:(RCTScheduler *)scheduler { [_surfaceRegistry enumerateWithBlock:^(NSEnumerator *enumerator) { for (RCTFabricSurface *surface in enumerator) { - [self _stopSurface:surface scheduler:scheduler]; - } - }]; -} - -- (void)_handleContentSizeCategoryDidChangeNotification:(NSNotification *)notification -{ - RCTScheduler *scheduler = [self _scheduler]; - - [_surfaceRegistry enumerateWithBlock:^(NSEnumerator *enumerator) { - for (RCTFabricSurface *surface in enumerator) { - LayoutContext layoutContext = RCTGetLayoutContext(surface.viewportOffset); - - LayoutConstraints layoutConstraints = RCTGetLayoutConstraintsForSize(surface.minimumSize, surface.maximumSize); - - [scheduler constraintSurfaceLayoutWithLayoutConstraints:layoutConstraints - layoutContext:layoutContext - surfaceId:surface.rootTag]; + [surface stop]; + [scheduler unregisterSurface:surface.surfaceHandler]; } }]; } diff --git a/React/Fabric/RCTSurfaceTouchHandler.mm b/React/Fabric/RCTSurfaceTouchHandler.mm index eb5d126eda3370..ba64bef7c1c786 100644 --- a/React/Fabric/RCTSurfaceTouchHandler.mm +++ b/React/Fabric/RCTSurfaceTouchHandler.mm @@ -10,6 +10,7 @@ #import #import #import +#import #import "RCTConversions.h" #import "RCTTouchableComponentViewProtocol.h" @@ -82,7 +83,8 @@ static void UpdateActiveTouchWithUITouch( ActiveTouch &activeTouch, UITouch *uiTouch, UIView *rootComponentView, - CGPoint rootViewOriginOffset) + CGPoint rootViewOriginOffset, + NSTimeInterval unixTimestampBasis) { CGPoint offsetPoint = [uiTouch locationInView:activeTouch.componentView]; CGPoint screenPoint = [uiTouch locationInView:uiTouch.window]; @@ -93,14 +95,18 @@ static void UpdateActiveTouchWithUITouch( activeTouch.touch.screenPoint = RCTPointFromCGPoint(screenPoint); activeTouch.touch.pagePoint = RCTPointFromCGPoint(pagePoint); - activeTouch.touch.timestamp = uiTouch.timestamp; + activeTouch.touch.timestamp = unixTimestampBasis + uiTouch.timestamp; if (RCTForceTouchAvailable()) { activeTouch.touch.force = RCTZeroIfNaN(uiTouch.force / uiTouch.maximumPossibleForce); } } -static ActiveTouch CreateTouchWithUITouch(UITouch *uiTouch, UIView *rootComponentView, CGPoint rootViewOriginOffset) +static ActiveTouch CreateTouchWithUITouch( + UITouch *uiTouch, + UIView *rootComponentView, + CGPoint rootViewOriginOffset, + NSTimeInterval unixTimestampBasis) { ActiveTouch activeTouch = {}; @@ -117,7 +123,7 @@ static ActiveTouch CreateTouchWithUITouch(UITouch *uiTouch, UIView *rootComponen componentView = componentView.superview; } - UpdateActiveTouchWithUITouch(activeTouch, uiTouch, rootComponentView, rootViewOriginOffset); + UpdateActiveTouchWithUITouch(activeTouch, uiTouch, rootComponentView, rootViewOriginOffset, unixTimestampBasis); return activeTouch; } @@ -167,6 +173,12 @@ @implementation RCTSurfaceTouchHandler { */ __weak UIView *_rootComponentView; IdentifierPool<11> _identifierPool; + + /* + * See Touch.h and usage. This gives us a time-basis for a monotonic + * clock that acts like a timestamp of milliseconds elapsed since UNIX epoch. + */ + NSTimeInterval _unixEpochBasisTime; } - (instancetype)init @@ -181,6 +193,8 @@ - (instancetype)init self.delaysTouchesEnded = NO; self.delegate = self; + + _unixEpochBasisTime = [[NSDate date] timeIntervalSince1970] - [NSProcessInfo processInfo].systemUptime; } return self; @@ -208,7 +222,7 @@ - (void)detachFromView:(UIView *)view - (void)_registerTouches:(NSSet *)touches { for (UITouch *touch in touches) { - auto activeTouch = CreateTouchWithUITouch(touch, _rootComponentView, _viewOriginOffset); + auto activeTouch = CreateTouchWithUITouch(touch, _rootComponentView, _viewOriginOffset, _unixEpochBasisTime); activeTouch.touch.identifier = _identifierPool.dequeue(); _activeTouches.emplace(touch, activeTouch); } @@ -223,7 +237,7 @@ - (void)_updateTouches:(NSSet *)touches continue; } - UpdateActiveTouchWithUITouch(iterator->second, touch, _rootComponentView, _viewOriginOffset); + UpdateActiveTouchWithUITouch(iterator->second, touch, _rootComponentView, _viewOriginOffset, _unixEpochBasisTime); } } diff --git a/React/Fabric/Surface/RCTFabricSurface.h b/React/Fabric/Surface/RCTFabricSurface.h index 1c3e4af43f71dd..77b3c906cc7dd0 100644 --- a/React/Fabric/Surface/RCTFabricSurface.h +++ b/React/Fabric/Surface/RCTFabricSurface.h @@ -8,6 +8,7 @@ #import #import #import +#import NS_ASSUME_NONNULL_BEGIN @@ -128,12 +129,7 @@ NS_ASSUME_NONNULL_BEGIN @interface RCTFabricSurface (Internal) -/** - * Sets and clears given stage flags (bitmask). - * Returns `YES` if the actual state was changed. - */ -- (BOOL)_setStage:(RCTSurfaceStage)stage; -- (BOOL)_unsetStage:(RCTSurfaceStage)stage; +- (facebook::react::SurfaceHandler const &)surfaceHandler; @end diff --git a/React/Fabric/Surface/RCTFabricSurface.mm b/React/Fabric/Surface/RCTFabricSurface.mm index 616945339cd760..ba325ac55c8bc1 100644 --- a/React/Fabric/Surface/RCTFabricSurface.mm +++ b/React/Fabric/Surface/RCTFabricSurface.mm @@ -10,6 +10,10 @@ #import #import +#import +#import +#import +#import #import #import #import @@ -23,26 +27,25 @@ using namespace facebook::react; @implementation RCTFabricSurface { - // Immutable __weak RCTSurfacePresenter *_surfacePresenter; - NSString *_moduleName; - - // Protected by the `_mutex` - std::mutex _mutex; - RCTSurfaceStage _stage; - NSDictionary *_properties; - CGSize _minimumSize; - CGSize _maximumSize; - CGPoint _viewportOffset; - CGSize _intrinsicSize; - - // The Main thread only + + // `SurfaceHandler` is a thread-safe object, so we don't need additional synchronization. + // Objective-C++ classes cannot have instance variables without default constructors, + // hence we wrap a value into `optional` to workaround it. + better::optional _surfaceHandler; + + // Protects Surface's start and stop processes. + // Even though SurfaceHandler is tread-safe, it will crash if we try to stop a surface that is not running. + // To make the API easy to use, we check the status of the surface before calling `start` or `stop`, + // and we need this mutex to prevent races. + std::mutex _surfaceMutex; + + // Can be accessed from the main thread only. RCTSurfaceView *_Nullable _view; RCTSurfaceTouchHandler *_Nullable _touchHandler; } @synthesize delegate = _delegate; -@synthesize rootTag = _rootTag; - (instancetype)initWithSurfacePresenter:(RCTSurfacePresenter *)surfacePresenter moduleName:(NSString *)moduleName @@ -50,15 +53,19 @@ - (instancetype)initWithSurfacePresenter:(RCTSurfacePresenter *)surfacePresenter { if (self = [super init]) { _surfacePresenter = surfacePresenter; - _moduleName = moduleName; - _properties = [initialProperties copy]; - _rootTag = [RCTAllocateRootViewTag() integerValue]; - _minimumSize = CGSizeZero; + _surfaceHandler = + SurfaceHandler{RCTStringFromNSString(moduleName), (SurfaceId)[RCTAllocateRootViewTag() integerValue]}; + _surfaceHandler->setProps(convertIdToFollyDynamic(initialProperties)); - _maximumSize = CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX); + [_surfacePresenter registerSurface:self]; - _stage = RCTSurfaceStageSurfaceDidInitialize; + [self _updateLayoutContext]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(handleContentSizeCategoryDidChangeNotification:) + name:UIContentSizeCategoryDidChangeNotification + object:nil]; } return self; @@ -66,41 +73,62 @@ - (instancetype)initWithSurfacePresenter:(RCTSurfacePresenter *)surfacePresenter - (void)resetWithSurfacePresenter:(RCTSurfacePresenter *)surfacePresenter { - _surfacePresenter = surfacePresenter; - _stage = RCTSurfaceStageSurfaceDidInitialize; _view = nil; + _surfacePresenter = surfacePresenter; + [_surfacePresenter registerSurface:self]; } +- (void)dealloc +{ + [_surfacePresenter unregisterSurface:self]; +} + +#pragma mark - Life-cycle management + - (BOOL)start { - if (![self _setStage:RCTSurfaceStageRunning]) { + std::lock_guard lock(_surfaceMutex); + + if (_surfaceHandler->getStatus() != SurfaceHandler::Status::Registered) { return NO; } - [_surfacePresenter registerSurface:self]; + _surfaceHandler->start(); + [self _propagateStageChange]; + + RCTExecuteOnMainQueue(^{ + [self->_surfacePresenter.mountingManager attachSurfaceToView:self.view + surfaceId:self->_surfaceHandler->getSurfaceId()]; + }); + + [_surfacePresenter setupAnimationDriverWithSurfaceHandler:*_surfaceHandler]; return YES; } - (BOOL)stop { - if (![self _unsetStage:RCTSurfaceStageRunning]) { + std::lock_guard lock(_surfaceMutex); + + if (_surfaceHandler->getStatus() != SurfaceHandler::Status::Running) { return NO; } - [_surfacePresenter unregisterSurface:self]; - return YES; -} + _surfaceHandler->stop(); + [self _propagateStageChange]; -- (void)dealloc -{ - [self stop]; + RCTExecuteOnMainQueue(^{ + [self->_surfacePresenter.mountingManager detachSurfaceFromView:self.view + surfaceId:self->_surfaceHandler->getSurfaceId()]; + }); + + return YES; } #pragma mark - Immutable Properties (no need to enforce synchronization) - (NSString *)moduleName { - return _moduleName; + return RCTNSStringFromString(_surfaceHandler->getModuleName()); } #pragma mark - Main-Threaded Routines @@ -122,49 +150,13 @@ - (RCTSurfaceView *)view - (RCTSurfaceStage)stage { - std::lock_guard lock(_mutex); - return _stage; -} - -- (BOOL)_setStage:(RCTSurfaceStage)stage -{ - return [self _setStage:stage setOrUnset:YES]; + return _surfaceHandler->getStatus() == SurfaceHandler::Status::Running ? RCTSurfaceStageRunning + : RCTSurfaceStagePreparing; } -- (BOOL)_unsetStage:(RCTSurfaceStage)stage +- (void)_propagateStageChange { - return [self _setStage:stage setOrUnset:NO]; -} - -- (BOOL)_setStage:(RCTSurfaceStage)stage setOrUnset:(BOOL)setOrUnset -{ - RCTSurfaceStage updatedStage; - { - std::lock_guard lock(_mutex); - - if (setOrUnset) { - updatedStage = (RCTSurfaceStage)(_stage | stage); - } else { - updatedStage = (RCTSurfaceStage)(_stage & ~stage); - } - - if (updatedStage == _stage) { - return NO; - } - - _stage = updatedStage; - } - - [self _propagateStageChange:updatedStage]; - return YES; -} - -- (void)_propagateStageChange:(RCTSurfaceStage)stage -{ - // Updating the `view` - RCTExecuteOnMainQueue(^{ - self->_view.stage = stage; - }); + RCTSurfaceStage stage = self.stage; // Notifying the `delegate` id delegate = self.delegate; @@ -173,114 +165,113 @@ - (void)_propagateStageChange:(RCTSurfaceStage)stage } } +- (void)_updateLayoutContext +{ + auto layoutConstraints = _surfaceHandler->getLayoutConstraints(); + auto layoutContext = _surfaceHandler->getLayoutContext(); + + layoutContext.pointScaleFactor = RCTScreenScale(); + layoutContext.swapLeftAndRightInRTL = + [[RCTI18nUtil sharedInstance] isRTL] && [[RCTI18nUtil sharedInstance] doLeftAndRightSwapInRTL]; + layoutContext.fontSizeMultiplier = RCTFontSizeMultiplier(); + + _surfaceHandler->constraintLayout(layoutConstraints, layoutContext); +} + #pragma mark - Properties Management - (NSDictionary *)properties { - std::lock_guard lock(_mutex); - return _properties; + return convertFollyDynamicToId(_surfaceHandler->getProps()); } - (void)setProperties:(NSDictionary *)properties { - { - std::lock_guard lock(_mutex); + _surfaceHandler->setProps(convertIdToFollyDynamic(properties)); +} + +#pragma mark - Layout + +- (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize viewportOffset:(CGPoint)viewportOffset +{ + auto layoutConstraints = _surfaceHandler->getLayoutConstraints(); + auto layoutContext = _surfaceHandler->getLayoutContext(); - if ([properties isEqualToDictionary:_properties]) { - return; - } + layoutConstraints.minimumSize = RCTSizeFromCGSize(minimumSize); + layoutConstraints.maximumSize = RCTSizeFromCGSize(maximumSize); - _properties = [properties copy]; + if (!isnan(viewportOffset.x) && !isnan(viewportOffset.y)) { + layoutContext.viewportOffset = RCTPointFromCGPoint(viewportOffset); } - [_surfacePresenter setProps:properties surface:self]; + _surfaceHandler->constraintLayout(layoutConstraints, layoutContext); } -#pragma mark - Layout - -- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize +- (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize { - return [_surfacePresenter sizeThatFitsMinimumSize:minimumSize maximumSize:maximumSize surface:self]; + [self setMinimumSize:minimumSize maximumSize:maximumSize viewportOffset:CGPointMake(NAN, NAN)]; } -#pragma mark - Size Constraints - - (void)setSize:(CGSize)size { - [self setMinimumSize:size maximumSize:size viewportOffset:_viewportOffset]; + [self setMinimumSize:size maximumSize:size]; } -- (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize viewportOffset:(CGPoint)viewportOffset +- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize { - { - std::lock_guard lock(_mutex); - if (CGSizeEqualToSize(minimumSize, _minimumSize) && CGSizeEqualToSize(maximumSize, _maximumSize) && - CGPointEqualToPoint(viewportOffset, _viewportOffset)) { - return; - } - - _maximumSize = maximumSize; - _minimumSize = minimumSize; - _viewportOffset = viewportOffset; - } + auto layoutConstraints = _surfaceHandler->getLayoutConstraints(); + auto layoutContext = _surfaceHandler->getLayoutContext(); - [_surfacePresenter setMinimumSize:minimumSize maximumSize:maximumSize surface:self]; -} + layoutConstraints.minimumSize = RCTSizeFromCGSize(minimumSize); + layoutConstraints.maximumSize = RCTSizeFromCGSize(maximumSize); -- (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize -{ - [self setMinimumSize:minimumSize maximumSize:maximumSize viewportOffset:_viewportOffset]; + return RCTCGSizeFromSize(_surfaceHandler->measure(layoutConstraints, layoutContext)); } - (CGSize)minimumSize { - std::lock_guard lock(_mutex); - return _minimumSize; + return RCTCGSizeFromSize(_surfaceHandler->getLayoutConstraints().minimumSize); } - (CGSize)maximumSize { - std::lock_guard lock(_mutex); - return _maximumSize; + return RCTCGSizeFromSize(_surfaceHandler->getLayoutConstraints().maximumSize); } - (CGPoint)viewportOffset { - std::lock_guard lock(_mutex); - return _viewportOffset; + return RCTCGPointFromPoint(_surfaceHandler->getLayoutContext().viewportOffset); } -#pragma mark - intrinsicSize +#pragma mark - Synchronous Waiting -- (void)setIntrinsicSize:(CGSize)intrinsicSize +- (BOOL)synchronouslyWaitFor:(NSTimeInterval)timeout { - { - std::lock_guard lock(_mutex); - if (CGSizeEqualToSize(intrinsicSize, _intrinsicSize)) { - return; - } + auto mountingCoordinator = _surfaceHandler->getMountingCoordinator(); - _intrinsicSize = intrinsicSize; + if (!mountingCoordinator) { + return NO; } - // Notifying `delegate` - id delegate = self.delegate; - if ([delegate respondsToSelector:@selector(surface:didChangeIntrinsicSize:)]) { - [delegate surface:(RCTSurface *)(id)self didChangeIntrinsicSize:intrinsicSize]; + if (!mountingCoordinator->waitForTransaction(std::chrono::duration(timeout))) { + return NO; } + + [_surfacePresenter.mountingManager scheduleTransaction:mountingCoordinator]; + + return YES; } -- (CGSize)intrinsicSize +- (void)handleContentSizeCategoryDidChangeNotification:(NSNotification *)notification { - std::lock_guard lock(_mutex); - return _intrinsicSize; + [self _updateLayoutContext]; } -#pragma mark - Synchronous Waiting +#pragma mark - Private -- (BOOL)synchronouslyWaitFor:(NSTimeInterval)timeout +- (SurfaceHandler const &)surfaceHandler; { - return [_surfacePresenter synchronouslyWaitSurface:self timeout:timeout]; + return *_surfaceHandler; } #pragma mark - Deprecated @@ -296,7 +287,12 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge - (NSNumber *)rootViewTag { - return @(_rootTag); + return @(_surfaceHandler->getSurfaceId()); +} + +- (NSInteger)rootTag +{ + return (NSInteger)(_surfaceHandler->getSurfaceId()); } @end diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index 8b8a05d29e4738..0944a54a9bab74 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -378,7 +378,7 @@ task extractJNIFiles { } android { - compileSdkVersion 29 + compileSdkVersion 30 ndkVersion ANDROID_NDK_VERSION compileOptions { sourceCompatibility(JavaVersion.VERSION_1_8) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 056880805cec10..cca71a2dccf28c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -153,6 +153,7 @@ public interface ReactInstanceEventListener { /* accessed from any thread */ private final JavaScriptExecutorFactory mJavaScriptExecutorFactory; + private @Nullable List mViewManagerNames = null; private final @Nullable JSBundleLoader mBundleLoader; private final @Nullable String mJSMainModulePath; /* path to JS bundle root on Metro */ private final List mPackages; @@ -711,6 +712,9 @@ public void destroy() { synchronized (mHasStartedDestroying) { mHasStartedDestroying.notifyAll(); } + synchronized (mPackages) { + mViewManagerNames = null; + } FLog.d(ReactConstants.TAG, "ReactInstanceManager has been destroyed"); } @@ -908,33 +912,38 @@ public List getOrCreateViewManagers( public @Nullable List getViewManagerNames() { Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.getViewManagerNames"); - ReactApplicationContext context; - synchronized (mReactContextLock) { - context = (ReactApplicationContext) getCurrentReactContext(); - if (context == null || !context.hasActiveCatalystInstance()) { - return null; + if (mViewManagerNames == null) { + ReactApplicationContext context; + synchronized (mReactContextLock) { + context = (ReactApplicationContext) getCurrentReactContext(); + if (context == null || !context.hasActiveCatalystInstance()) { + return null; + } } - } - synchronized (mPackages) { - Set uniqueNames = new HashSet<>(); - for (ReactPackage reactPackage : mPackages) { - SystraceMessage.beginSection( - TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.getViewManagerName") - .arg("Package", reactPackage.getClass().getSimpleName()) - .flush(); - if (reactPackage instanceof ViewManagerOnDemandReactPackage) { - List names = - ((ViewManagerOnDemandReactPackage) reactPackage).getViewManagerNames(context); - if (names != null) { - uniqueNames.addAll(names); + synchronized (mPackages) { + if (mViewManagerNames == null) { + Set uniqueNames = new HashSet<>(); + for (ReactPackage reactPackage : mPackages) { + SystraceMessage.beginSection( + TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.getViewManagerName") + .arg("Package", reactPackage.getClass().getSimpleName()) + .flush(); + if (reactPackage instanceof ViewManagerOnDemandReactPackage) { + List names = + ((ViewManagerOnDemandReactPackage) reactPackage).getViewManagerNames(context); + if (names != null) { + uniqueNames.addAll(names); + } + } + SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); } + Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + mViewManagerNames = new ArrayList<>(uniqueNames); } - SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); } - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); - return new ArrayList<>(uniqueNames); } + return new ArrayList<>(mViewManagerNames); } /** Add a listener to be notified of react instance events. */ diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 610dd67bde537f..1efc5fe0890ca3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -27,7 +27,6 @@ import android.view.WindowManager; import android.widget.FrameLayout; import androidx.annotation.Nullable; -import androidx.annotation.UiThread; import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; import com.facebook.infer.annotation.ThreadConfined; @@ -52,6 +51,7 @@ import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.ReactRoot; import com.facebook.react.uimanager.RootView; +import com.facebook.react.uimanager.RootViewUtil; import com.facebook.react.uimanager.UIManagerHelper; import com.facebook.react.uimanager.common.UIManagerType; import com.facebook.react.uimanager.events.EventDispatcher; @@ -420,21 +420,6 @@ public AtomicInteger getState() { return mState; } - @UiThread - public static Point getViewportOffset(View v) { - int[] locationInWindow = new int[2]; - v.getLocationInWindow(locationInWindow); - - // we need to subtract visibleWindowCoords - to subtract possible window insets, split - // screen or multi window - Rect visibleWindowFrame = new Rect(); - v.getWindowVisibleDisplayFrame(visibleWindowFrame); - locationInWindow[0] -= visibleWindowFrame.left; - locationInWindow[1] -= visibleWindowFrame.top; - - return new Point(locationInWindow[0], locationInWindow[1]); - } - /** * Call whenever measure specs change, or if you want to force an update of offsetX/offsetY. If * measureSpecsChanged is false and the offsetX/offsetY don't change, updateRootLayoutSpecs will @@ -472,7 +457,7 @@ private void updateRootLayoutSpecs( int offsetX = 0; int offsetY = 0; if (getUIManagerType() == FABRIC) { - Point viewportOffset = getViewportOffset(this); + Point viewportOffset = RootViewUtil.getViewportOffset(this); offsetX = viewportOffset.x; offsetY = viewportOffset.y; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java index 28d024fd4b002b..30d2de3f2f29dc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java @@ -23,6 +23,7 @@ import com.facebook.react.bridge.queue.ReactQueueConfiguration; import com.facebook.react.common.LifecycleState; import com.facebook.react.common.ReactConstants; +import com.facebook.react.common.annotations.VisibleForTesting; import com.facebook.react.config.ReactFeatureFlags; import java.lang.ref.WeakReference; import java.util.concurrent.CopyOnWriteArraySet; @@ -182,9 +183,14 @@ public LifecycleState getLifecycleState() { return mLifecycleState; } + @VisibleForTesting public void addLifecycleEventListener(final LifecycleEventListener listener) { mLifecycleEventListeners.add(listener); - if (hasActiveCatalystInstance() || isBridgeless()) { + } + + public void addLifecycleEventListenerAndCheckState(final LifecycleEventListener listener) { + mLifecycleEventListeners.add(listener); + if (hasActiveCatalystInstance()) { switch (mLifecycleState) { case BEFORE_CREATE: case BEFORE_RESUME: diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index c195ab8e7bc115..5f493dbf55ee83 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -59,4 +59,7 @@ public class ReactFeatureFlags { /** Enables a more aggressive cleanup during destruction of ReactContext */ public static boolean enableReactContextCleanupFix = false; + + /** Enables setting layout params to empty to fix a crash */ + public static boolean enableSettingEmptyLayoutParams = false; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/BUCK b/ReactAndroid/src/main/java/com/facebook/react/fabric/BUCK index f3cb842381849b..12ad6392e594d6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/BUCK @@ -33,7 +33,6 @@ rn_android_library( react_native_target("java/com/facebook/react/bridge:bridge"), react_native_target("java/com/facebook/react/config:config"), react_native_target("java/com/facebook/react/fabric/jni:jni"), - react_native_target("java/com/facebook/react:react"), react_native_target("java/com/facebook/react/module/annotations:annotations"), react_native_target("java/com/facebook/react/modules/core:core"), react_native_target("java/com/facebook/react/modules/i18nmanager:i18nmanager"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java index 61296c84a70cbb..9020ab17e775f7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java @@ -91,6 +91,7 @@ public void register( jsMessageQueueThread, componentFactory, reactNativeConfig); + setPixelDensity(PixelUtil.getDisplayMetricDensity()); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index ae5a01fcf68fad..e05d0d8c830aa6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -35,7 +35,6 @@ import com.facebook.debug.tags.ReactDebugOverlayTags; import com.facebook.infer.annotation.ThreadConfined; import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.react.ReactRootView; import com.facebook.react.bridge.LifecycleEventListener; import com.facebook.react.bridge.NativeArray; import com.facebook.react.bridge.NativeMap; @@ -73,6 +72,7 @@ import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.ReactRoot; import com.facebook.react.uimanager.ReactRootViewTagGenerator; +import com.facebook.react.uimanager.RootViewUtil; import com.facebook.react.uimanager.StateWrapper; import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.UIManagerHelper; @@ -176,7 +176,7 @@ public FabricUIManager( mEventDispatcher = eventDispatcher; mShouldDeallocateEventDispatcher = false; mEventBeatManager = eventBeatManager; - mReactApplicationContext.addLifecycleEventListener(this); + mReactApplicationContext.addLifecycleEventListenerAndCheckState(this); } public FabricUIManager( @@ -189,7 +189,7 @@ public FabricUIManager( mEventDispatcher = new EventDispatcherImpl(reactContext); mShouldDeallocateEventDispatcher = true; mEventBeatManager = eventBeatManager; - mReactApplicationContext.addLifecycleEventListener(this); + mReactApplicationContext.addLifecycleEventListenerAndCheckState(this); } // TODO (T47819352): Rename this to startSurface for consistency with xplat/iOS @@ -252,7 +252,7 @@ public int startSurface( // ViewportOffset during measurement or onLayout. @SuppressLint("WrongThread") Point viewportOffset = - UiThreadUtil.isOnUiThread() ? ReactRootView.getViewportOffset(rootView) : new Point(0, 0); + UiThreadUtil.isOnUiThread() ? RootViewUtil.getViewportOffset(rootView) : new Point(0, 0); mBinding.startSurfaceWithConstraints( rootTag, @@ -1079,8 +1079,15 @@ public void setJSResponder( new MountItem() { @Override public void execute(MountingManager mountingManager) { - mountingManager.setJSResponder( - surfaceId, reactTag, initialReactTag, blockNativeResponder); + SurfaceMountingManager surfaceMountingManager = + mountingManager.getSurfaceManager(surfaceId); + if (surfaceMountingManager != null) { + surfaceMountingManager.setJSResponder( + reactTag, initialReactTag, blockNativeResponder); + } else { + FLog.e( + TAG, "setJSResponder skipped, surface no longer available [" + surfaceId + "]"); + } } @Override diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk index e63fd782d4d7b1..a20d60caf044f3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk @@ -11,7 +11,7 @@ LOCAL_MODULE := fabricjni LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SHARED_LIBRARIES := libreactconfig librrc_slider librrc_progressbar librrc_switch librrc_modal libyoga libglog libfb libfbjni libglog_init libfolly_json libfolly_futures libreact_render_mounting libreactnativeutilsjni libreact_utils libreact_render_debug libreact_render_graphics libreact_render_core libreact_render_mapbuffer react_render_componentregistry librrc_view librrc_unimplementedview librrc_root librrc_scrollview libbetter libreact_render_attributedstring libreact_render_uimanager libreact_render_templateprocessor libreact_render_scheduler libreact_render_animations libreact_render_imagemanager libreact_render_textlayoutmanager libreact_codegen_rncore rrc_text librrc_image rrc_textinput rrc_picker +LOCAL_SHARED_LIBRARIES := libreactconfig librrc_slider librrc_progressbar librrc_switch librrc_modal libyoga libglog libfb libfbjni libglog_init libfolly_json libfolly_futures libreact_render_mounting libreactnativeutilsjni libreact_utils libreact_render_debug libreact_render_graphics libreact_render_core libreact_render_mapbuffer react_render_componentregistry librrc_view librrc_unimplementedview librrc_root librrc_scrollview libbetter libreact_render_attributedstring libreact_render_uimanager libreact_render_templateprocessor libreact_render_scheduler libreact_render_animations libreact_render_imagemanager libreact_render_textlayoutmanager libreact_codegen_rncore rrc_text librrc_image librrc_textinput librrc_picker libreact_debug LOCAL_STATIC_LIBRARIES := @@ -34,6 +34,7 @@ $(call import-module,yogajni) $(call import-module,glog) $(call import-module,react/utils) +$(call import-module,react/debug) $(call import-module,react/config) $(call import-module,react/renderer/animations) $(call import-module,react/renderer/attributedstring) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index 9e367641098980..afa2ede1e094d1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -105,7 +105,7 @@ static inline int getIntBufferSizeForType(CppMountItem::Type mountItemType) { } else if (mountItemType == CppMountItem::Type::UpdatePadding) { return 5; // tag, top, left, bottom, right } else if (mountItemType == CppMountItem::Type::UpdateLayout) { - return 7; // tag, x, y, w, h, layoutDirection, DisplayType + return 6; // tag, x, y, w, h, DisplayType } else if (mountItemType == CppMountItem::Type::UpdateEventEmitter) { return 1; // tag } else { @@ -958,8 +958,6 @@ void Binding::schedulerDidFinishTransaction( int y = round(scale(frame.origin.y, pointScaleFactor)); int w = round(scale(frame.size.width, pointScaleFactor)); int h = round(scale(frame.size.height, pointScaleFactor)); - int layoutDirection = - toInt(mountItem.newChildShadowView.layoutMetrics.layoutDirection); int displayType = toInt(mountItem.newChildShadowView.layoutMetrics.displayType); @@ -968,10 +966,9 @@ void Binding::schedulerDidFinishTransaction( temp[2] = y; temp[3] = w; temp[4] = h; - temp[5] = layoutDirection; - temp[6] = displayType; - env->SetIntArrayRegion(intBufferArray, intBufferPosition, 7, temp); - intBufferPosition += 7; + temp[5] = displayType; + env->SetIntArrayRegion(intBufferArray, intBufferPosition, 6, temp); + intBufferPosition += 6; } } if (cppUpdateEventEmitterMountItems.size() > 0) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/CoreComponentsRegistry.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/CoreComponentsRegistry.cpp index 560b8eaaa70fb2..cd13e075b17c1d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/CoreComponentsRegistry.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/CoreComponentsRegistry.cpp @@ -64,6 +64,9 @@ CoreComponentsRegistry::sharedProviderRegistry() { concreteComponentDescriptorProvider()); providerRegistry->add( concreteComponentDescriptorProvider()); + providerRegistry->add( + concreteComponentDescriptorProvider< + AndroidHorizontalScrollContentViewComponentDescriptor>()); providerRegistry->add( concreteComponentDescriptorProvider()); providerRegistry->add(concreteComponentDescriptorProvider< diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java index b916ff6ffd3bc6..a45742450dc8b8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java @@ -270,38 +270,15 @@ public void updateProps(int reactTag, @Nullable ReadableMap props) { getSurfaceManagerForViewEnforced(reactTag).updateProps(reactTag, props); } - /** - * Set the JS responder for the view associated with the tags received as a parameter. - * - *

The JSResponder coordinates the return values of the onInterceptTouch method in Android - * Views. This allows JS to coordinate when a touch should be handled by JS or by the Android - * native views. See {@link JSResponderHandler} for more details. - * - *

This method is going to be executed on the UIThread as soon as it is delivered from JS to - * RN. - * - *

Currently, there is no warranty that the view associated with the react tag exists, because - * this method is not handled by the react commit process. - * - * @param reactTag React tag of the first parent of the view that is NOT virtual - * @param initialReactTag React tag of the JS view that initiated the touch operation - * @param blockNativeResponder If native responder should be blocked or not - */ - @UiThread - public synchronized void setJSResponder( - int surfaceId, int reactTag, int initialReactTag, boolean blockNativeResponder) { - UiThreadUtil.assertOnUiThread(); - - getSurfaceManagerEnforced(surfaceId, "setJSResponder") - .setJSResponder(reactTag, initialReactTag, blockNativeResponder); - } - /** * Clears the JS Responder specified by {@link #setJSResponder(int, int, int, boolean)}. After * this method is called, all the touch events are going to be handled by JS. */ @UiThread public void clearJSResponder() { + // MountingManager and SurfaceMountingManagers all share the same JSResponderHandler. + // Must be called on MountingManager instead of SurfaceMountingManager, because we don't + // know what surfaceId it's being called for. mJSResponderHandler.clearJSResponder(); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java index 311a08143ea3be..d6d3a0f9c2b4e5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java @@ -161,8 +161,6 @@ public void execute(@NonNull MountingManager mountingManager) { int y = mIntBuffer[i++]; int width = mIntBuffer[i++]; int height = mIntBuffer[i++]; - // The final buffer, layoutDirection, seems unused? - i++; int displayType = mIntBuffer[i++]; surfaceMountingManager.updateLayout(reactTag, x, y, width, height, displayType); @@ -232,8 +230,7 @@ public String toString() { } else if (type == INSTRUCTION_UPDATE_LAYOUT) { s.append( String.format( - "UPDATE LAYOUT [%d]: x:%d y:%d w:%d h:%d layoutDirection:%d displayType:%d\n", - mIntBuffer[i++], + "UPDATE LAYOUT [%d]: x:%d y:%d w:%d h:%d displayType:%d\n", mIntBuffer[i++], mIntBuffer[i++], mIntBuffer[i++], diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/PreAllocateViewMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/PreAllocateViewMountItem.java index 7764bd58a3c452..7b540ae89a42d3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/PreAllocateViewMountItem.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/PreAllocateViewMountItem.java @@ -16,6 +16,7 @@ import com.facebook.common.logging.FLog; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.fabric.mounting.MountingManager; +import com.facebook.react.fabric.mounting.SurfaceMountingManager; import com.facebook.react.uimanager.StateWrapper; /** {@link MountItem} that is used to pre-allocate views for JS components. */ @@ -53,9 +54,15 @@ public void execute(@NonNull MountingManager mountingManager) { if (ENABLE_FABRIC_LOGS) { FLog.d(TAG, "Executing pre-allocation of: " + toString()); } - mountingManager - .getSurfaceManagerEnforced(mSurfaceId, "PreAllocateViewMountItem") - .preallocateView(mComponent, mReactTag, mProps, mStateWrapper, mIsLayoutable); + SurfaceMountingManager surfaceMountingManager = mountingManager.getSurfaceManager(mSurfaceId); + if (surfaceMountingManager == null) { + FLog.e( + TAG, + "Skipping View PreAllocation; no SurfaceMountingManager found for [" + mSurfaceId + "]"); + return; + } + surfaceMountingManager.preallocateView( + mComponent, mReactTag, mProps, mStateWrapper, mIsLayoutable); } @Override diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.java index 8ac7f07606a4a0..5abe37b3a5a23f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.java @@ -68,7 +68,7 @@ public TimingModule(ReactApplicationContext reactContext, DevSupportManager devS @Override public void initialize() { - getReactApplicationContext().addLifecycleEventListener(this); + getReactApplicationContext().addLifecycleEventListenerAndCheckState(this); HeadlessJsTaskContext headlessJsTaskContext = HeadlessJsTaskContext.getInstance(getReactApplicationContext()); headlessJsTaskContext.addTaskEventListener(this); diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/DeviceInfoModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/DeviceInfoModule.java index 083c9c1d9f27b1..2de4acce4ef862 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/DeviceInfoModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/DeviceInfoModule.java @@ -37,7 +37,7 @@ public DeviceInfoModule(ReactApplicationContext reactContext) { DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext); mFontScale = reactContext.getResources().getConfiguration().fontScale; mReactApplicationContext = reactContext; - mReactApplicationContext.addLifecycleEventListener(this); + mReactApplicationContext.addLifecycleEventListenerAndCheckState(this); } public DeviceInfoModule(Context context) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootViewUtil.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootViewUtil.java index 41bae5be249ae2..2c2e35460b8074 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootViewUtil.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootViewUtil.java @@ -7,8 +7,11 @@ package com.facebook.react.uimanager; +import android.graphics.Point; +import android.graphics.Rect; import android.view.View; import android.view.ViewParent; +import androidx.annotation.UiThread; import com.facebook.infer.annotation.Assertions; public class RootViewUtil { @@ -28,4 +31,19 @@ public static RootView getRootView(View reactView) { current = (View) next; } } + + @UiThread + public static Point getViewportOffset(View v) { + int[] locationInWindow = new int[2]; + v.getLocationInWindow(locationInWindow); + + // we need to subtract visibleWindowCoords - to subtract possible window insets, split + // screen or multi window + Rect visibleWindowFrame = new Rect(); + v.getWindowVisibleDisplayFrame(visibleWindowFrame); + locationInWindow[0] -= visibleWindowFrame.left; + locationInWindow[1] -= visibleWindowFrame.top; + + return new Point(locationInWindow[0], locationInWindow[1]); + } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.java index 15701d63618a40..2e1493f3f437f3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.java @@ -56,8 +56,8 @@ public ThemedReactContext( } @Override - public void addLifecycleEventListener(LifecycleEventListener listener) { - mReactApplicationContext.addLifecycleEventListener(listener); + public void addLifecycleEventListenerAndCheckState(LifecycleEventListener listener) { + mReactApplicationContext.addLifecycleEventListenerAndCheckState(listener); } @Override diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 1d49251377d546..182c04fb84077d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -158,7 +158,7 @@ public UIManagerModule( mEventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs); - reactContext.addLifecycleEventListener(this); + reactContext.addLifecycleEventListenerAndCheckState(this); } @Deprecated @@ -180,7 +180,7 @@ public UIManagerModule( mEventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs); - reactContext.addLifecycleEventListener(this); + reactContext.addLifecycleEventListenerAndCheckState(this); } /** diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java index bd3b06b16e6de1..e8976cce961970 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java @@ -38,6 +38,15 @@ public abstract class Event { private long mTimestampMs; private int mUniqueID = sUniqueID++; + // Android native Event times use 'uptimeMillis', and historically we've used `uptimeMillis` + // throughout this Event class as the coalescing key for events, and for other purposes. + // To get an accurate(ish) absolute UNIX time for the event, we store the initial clock time here. + // uptimeMillis can then be added to this to get an accurate UNIX time. + // However, we still default to uptimeMillis: you must explicitly request UNIX time if you want + // that; see `getUnixTimestampMs`. + public static final long sInitialClockTimeUnixOffset = + SystemClock.currentTimeMillis() - SystemClock.uptimeMillis(); + protected Event() {} @Deprecated @@ -58,8 +67,10 @@ protected void init(int viewTag) { protected void init(int surfaceId, int viewTag) { mSurfaceId = surfaceId; mViewTag = viewTag; - mTimestampMs = SystemClock.uptimeMillis(); mInitialized = true; + + // This is a *relative* time. See `getUnixTimestampMs`. + mTimestampMs = SystemClock.uptimeMillis(); } /** @return the view id for the view that generated this event */ @@ -80,6 +91,11 @@ public final long getTimestampMs() { return mTimestampMs; } + /** @return the time at which the event happened as a UNIX timestamp, in milliseconds. */ + public final long getUnixTimestampMs() { + return sInitialClockTimeUnixOffset + mTimestampMs; + } + /** @return false if this Event can *never* be coalesced */ public boolean canCoalesce() { return true; diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java index a99d6b1eb31699..8e3ded74b1d13d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java @@ -104,7 +104,7 @@ public int compare(Event lhs, Event rhs) { public EventDispatcherImpl(ReactApplicationContext reactContext) { mReactContext = reactContext; - mReactContext.addLifecycleEventListener(this); + mReactContext.addLifecycleEventListenerAndCheckState(this); mReactEventEmitter = new ReactEventEmitter(mReactContext); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java index 187e61211604c2..b67f6e3eff06ef 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java @@ -64,7 +64,7 @@ private static WritableArray createsPointersArray( touch.putDouble(LOCATION_Y_KEY, PixelUtil.toDIPFromPixel(locationY)); touch.putInt(TARGET_SURFACE_KEY, surfaceId); touch.putInt(TARGET_KEY, reactTarget); - touch.putDouble(TIMESTAMP_KEY, event.getTimestampMs()); + touch.putDouble(TIMESTAMP_KEY, event.getUnixTimestampMs()); touch.putDouble(POINTER_IDENTIFIER_KEY, motionEvent.getPointerId(index)); touches.pushMap(touch); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK index 73cedfd484bba5..20c442aef6ebee 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK @@ -17,6 +17,7 @@ rn_android_library( YOGA_TARGET, react_native_dep("third-party/java/infer-annotations:infer-annotations"), react_native_dep("third-party/java/jsr-305:jsr-305"), + react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"), react_native_root_target("Libraries:generated_components_java-FBReactNativeComponentSpec"), react_native_target("java/com/facebook/react/bridge:bridge"), react_native_target("java/com/facebook/react/common:common"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java index db03bfac47ad45..32d04e36b453e2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java @@ -23,6 +23,7 @@ import android.widget.FrameLayout; import androidx.annotation.Nullable; import androidx.annotation.UiThread; +import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; import com.facebook.react.R; import com.facebook.react.bridge.GuardedRunnable; @@ -61,6 +62,8 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListener, FabricViewStateManager.HasFabricViewStateManager { + private static final String TAG = "ReactModalHost"; + // This listener is called when the user presses KeyEvent.KEYCODE_BACK // An event is then passed to JS which can either close or not close the Modal by setting the // visible property @@ -244,6 +247,15 @@ protected void showOrUpdate() { // If the existing Dialog is currently up, we may need to redraw it or we may be able to update // the property without having to recreate the dialog if (mDialog != null) { + Context dialogContext = ContextUtils.findContextOfType(mDialog.getContext(), Activity.class); + // TODO(T85755791): remove after investigation + FLog.e( + TAG, + "Updating existing dialog with context: " + + dialogContext + + "@" + + dialogContext.hashCode()); + if (mPropertyRequiresNewDialog) { dismiss(); } else { @@ -269,6 +281,9 @@ protected void showOrUpdate() { WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); + // TODO(T85755791): remove after investigation + FLog.e(TAG, "Creating new dialog from context: " + context + "@" + context.hashCode()); + mDialog.setContentView(getContentView()); updateProperties(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java index f7a0a18995fe75..11dabebc61fb7d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java @@ -31,6 +31,7 @@ import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; import com.facebook.react.common.ReactConstants; +import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.ReactCompoundView; import com.facebook.react.uimanager.UIManagerModule; @@ -47,6 +48,10 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie private static final ViewGroup.LayoutParams EMPTY_LAYOUT_PARAMS = new ViewGroup.LayoutParams(0, 0); + private static final ViewGroup.LayoutParams WRAP_CONTENT_LAYOUT_PARAMS = + new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + private boolean mContainsImages; private int mDefaultGravityHorizontal; private int mDefaultGravityVertical; @@ -269,7 +274,11 @@ public void setText(ReactTextUpdate update) { // null; explicitly set the LayoutParams to prevent this crash. See: // https://github.com/facebook/react-native/pull/7011 if (getLayoutParams() == null) { - setLayoutParams(EMPTY_LAYOUT_PARAMS); + if (ReactFeatureFlags.enableSettingEmptyLayoutParams) { + setLayoutParams(EMPTY_LAYOUT_PARAMS); + } else { + setLayoutParams(WRAP_CONTENT_LAYOUT_PARAMS); + } } Spannable spannable = update.getText(); if (mLinkifyMaskType > 0) { diff --git a/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java b/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java index 9696e9a8069a9a..43a4558dd7fb52 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java @@ -115,7 +115,7 @@ public void testTouchEmitter() { rootView.startReactApplication(instanceManager, ""); rootView.simulateAttachForTesting(); - long ts = SystemClock.uptimeMillis(); + long ts = SystemClock.currentTimeMillis(); // Test ACTION_DOWN event rootView.onTouchEvent(MotionEvent.obtain(100, ts, MotionEvent.ACTION_DOWN, 0, 0, 0)); diff --git a/ReactCommon/ReactCommon.podspec b/ReactCommon/ReactCommon.podspec index e4b34411605933..f63950228c0cee 100644 --- a/ReactCommon/ReactCommon.podspec +++ b/ReactCommon/ReactCommon.podspec @@ -53,6 +53,10 @@ Pod::Spec.new do |s| "react/nativemodule/core/platform/ios/**/*.{mm,cpp,h}" end + s.subspec "react_debug_core" do |sss| + sss.source_files = "react/debug/*.{cpp,h}" + end + ss.subspec "samples" do |sss| sss.source_files = "react/nativemodule/samples/ReactCommon/**/*.{cpp,h}", "react/nativemodule/samples/platform/ios/**/*.{mm,cpp,h}" diff --git a/ReactCommon/cxxreact/ModuleRegistry.cpp b/ReactCommon/cxxreact/ModuleRegistry.cpp index da75bc5b5857f3..741d97073d36b6 100644 --- a/ReactCommon/cxxreact/ModuleRegistry.cpp +++ b/ReactCommon/cxxreact/ModuleRegistry.cpp @@ -48,6 +48,11 @@ void ModuleRegistry::updateModuleNamesFromIndex(size_t index) { void ModuleRegistry::registerModules( std::vector> modules) { SystraceSection s_("ModuleRegistry::registerModules"); + // Noop if there are no NativeModules to add + if (modules.empty()) { + return; + } + if (modules_.empty() && unknownModules_.empty()) { modules_ = std::move(modules); } else { diff --git a/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp b/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp index f490891446060f..f1d4c5170604cf 100644 --- a/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp +++ b/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp @@ -439,7 +439,7 @@ Value JSIExecutor::nativeCallSyncHook(const Value *args, size_t count) { throw std::invalid_argument("nativeCallSyncHook arg count must be 3"); } - if (!args[2].asObject(*runtime_).isArray(*runtime_)) { + if (!args[2].isObject() || !args[2].asObject(*runtime_).isArray(*runtime_)) { throw std::invalid_argument( folly::to("method parameters should be array")); } diff --git a/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp b/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp index e7c56c206a5f26..0bf27d402e9eec 100644 --- a/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp +++ b/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp @@ -89,6 +89,8 @@ folly::Optional JSINativeModules::createModule( valueFromDynamic(rt, result->config), static_cast(result->index)); CHECK(!moduleInfo.isNull()) << "Module returned from genNativeModule is null"; + CHECK(moduleInfo.isObject()) + << "Module returned from genNativeModule isn't an Object"; folly::Optional module( moduleInfo.asObject(rt).getPropertyAsObject(rt, "module")); diff --git a/ReactCommon/react/debug/Android.mk b/ReactCommon/react/debug/Android.mk index fed711337bf390..669418516b2109 100644 --- a/ReactCommon/react/debug/Android.mk +++ b/ReactCommon/react/debug/Android.mk @@ -17,11 +17,15 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ LOCAL_SHARED_LIBRARIES := libfolly_json +LOCAL_LDLIBS := -llog + LOCAL_CFLAGS := \ -DLOG_TAG=\"Fabric\" LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall -llog +LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog + include $(BUILD_SHARED_LIBRARY) $(call import-module,folly) diff --git a/ReactCommon/react/nativemodule/core/Android.mk b/ReactCommon/react/nativemodule/core/Android.mk index 70f7651b4831f4..13339cab74d730 100644 --- a/ReactCommon/react/nativemodule/core/Android.mk +++ b/ReactCommon/react/nativemodule/core/Android.mk @@ -15,7 +15,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/ReactCommon/*.cpp) $(wildcard $(LOCA LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/platform/android/ -LOCAL_SHARED_LIBRARIES := libfbjni libfolly_json libreactnativejni +LOCAL_SHARED_LIBRARIES := libfbjni libfolly_json libreactnativejni libreact_debug LOCAL_STATIC_LIBRARIES := libjsi libreactperflogger diff --git a/ReactCommon/react/nativemodule/core/BUCK b/ReactCommon/react/nativemodule/core/BUCK index 18cc72b93f90af..bf3ae66161b86a 100644 --- a/ReactCommon/react/nativemodule/core/BUCK +++ b/ReactCommon/react/nativemodule/core/BUCK @@ -79,6 +79,7 @@ rn_xplat_cxx_library( react_native_xplat_target("cxxreact:bridge"), react_native_xplat_target("cxxreact:module"), react_native_xplat_target("callinvoker:callinvoker"), + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("reactperflogger:reactperflogger"), ], exported_deps = [ diff --git a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp index f00e8bb95e5981..a8bb21897ba3c0 100644 --- a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp +++ b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -133,7 +134,7 @@ std::string stringifyJSIValue(const jsi::Value &v, jsi::Runtime *rt = nullptr) { return "a string (\"" + v.getString(*rt).utf8(*rt) + "\")"; } - assert(v.isObject() && "Expecting object."); + react_native_assert(v.isObject() && "Expecting object."); return rt != nullptr && v.getObject(*rt).isFunction(*rt) ? "a function" : "an object"; } diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.h b/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.h new file mode 100644 index 00000000000000..38dbd2bee4b7f3 --- /dev/null +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * RCTBlockGuard is designed to be used with obj-c blocks to assist with manual deallocation of C++ resources + * tied to lifetime of a block. If C++ resources needs to be manually released at the end of block or when the block + * is deallocated, place the clean up code inside constructor and make sure the instace of the class is references in + * the block. + */ +@interface RCTBlockGuard : NSObject + +- (instancetype)initWithCleanup:(void (^)(void))cleanup; + +@end + +NS_ASSUME_NONNULL_END diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.mm new file mode 100644 index 00000000000000..54a856a25a768a --- /dev/null +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.mm @@ -0,0 +1,28 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import "RCTBlockGuard.h" + +@implementation RCTBlockGuard { + void (^_cleanup)(void); +} + +- (instancetype)initWithCleanup:(void (^)(void))cleanup +{ + if (self = [super init]) { + _cleanup = cleanup; + } + + return self; +} + +- (void)dealloc +{ + _cleanup(); +} + +@end diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm index de1bed23f8ea50..b730492b9033d8 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm @@ -6,6 +6,7 @@ */ #import "RCTTurboModule.h" +#import "RCTBlockGuard.h" #import #import @@ -170,6 +171,16 @@ static int32_t getUniqueId() convertJSIFunctionToCallback(jsi::Runtime &runtime, const jsi::Function &value, std::shared_ptr jsInvoker) { auto weakWrapper = CallbackWrapper::createWeak(value.getFunction(runtime), runtime, jsInvoker); + RCTBlockGuard *blockGuard; + if (RCTTurboModuleBlockGuardEnabled()) { + blockGuard = [[RCTBlockGuard alloc] initWithCleanup:^() { + auto strongWrapper = weakWrapper.lock(); + if (strongWrapper) { + strongWrapper->destroy(); + } + }]; + } + BOOL __block wrapperWasCalled = NO; RCTResponseSenderBlock callback = ^(NSArray *responses) { if (wrapperWasCalled) { @@ -181,7 +192,7 @@ static int32_t getUniqueId() return; } - strongWrapper->jsInvoker().invokeAsync([weakWrapper, responses]() { + strongWrapper->jsInvoker().invokeAsync([weakWrapper, responses, blockGuard]() { auto strongWrapper2 = weakWrapper.lock(); if (!strongWrapper2) { return; @@ -190,6 +201,9 @@ static int32_t getUniqueId() std::vector args = convertNSArrayToStdVector(strongWrapper2->runtime(), responses); strongWrapper2->callback().call(strongWrapper2->runtime(), (const jsi::Value *)args.data(), args.size()); strongWrapper2->destroy(); + + // Delete the CallbackWrapper when the block gets dealloced without being invoked. + (void)blockGuard; }); wrapperWasCalled = YES; diff --git a/ReactCommon/react/renderer/animations/Android.mk b/ReactCommon/react/renderer/animations/Android.mk index da7c4531e0b6bd..0f0e3cc0f07576 100644 --- a/ReactCommon/react/renderer/animations/Android.mk +++ b/ReactCommon/react/renderer/animations/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libreact_render_graphics libglog_init glog libruntimeexecutor libyoga librrc_view libreact_render_uimanager libfolly_futures libreact_render_componentregistry libreactconfig libfolly_json libjsi libreact_render_core libreact_render_debug libreact_render_mounting +LOCAL_SHARED_LIBRARIES := libreact_render_graphics libglog_init glog libruntimeexecutor libyoga librrc_view libreact_render_uimanager libfolly_futures libreact_render_componentregistry libreactconfig libfolly_json libjsi libreact_render_core libreact_render_debug libreact_render_mounting libreact_debug include $(BUILD_SHARED_LIBRARY) @@ -39,3 +39,4 @@ $(call import-module,react/renderer/mounting) $(call import-module,react/renderer/uimanager) $(call import-module,yogajni) $(call import-module,runtimeexecutor) +$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/attributedstring/Android.mk b/ReactCommon/react/renderer/attributedstring/Android.mk index a9cfe21f7f01d0..2b90b0378380cb 100644 --- a/ReactCommon/react/renderer/attributedstring/Android.mk +++ b/ReactCommon/react/renderer/attributedstring/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libbetter libreact_render_graphics libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug librrc_view libreact_utils +LOCAL_SHARED_LIBRARIES := libbetter libreact_render_graphics libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug librrc_view libreact_utils libreact_debug include $(BUILD_SHARED_LIBRARY) @@ -35,4 +35,5 @@ $(call import-module,react/renderer/core) $(call import-module,react/renderer/debug) $(call import-module,react/renderer/graphics) $(call import-module,react/utils) +$(call import-module,react/debug) $(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/componentregistry/Android.mk b/ReactCommon/react/renderer/componentregistry/Android.mk index 3ca9726aa4d927..5483a322716da3 100644 --- a/ReactCommon/react/renderer/componentregistry/Android.mk +++ b/ReactCommon/react/renderer/componentregistry/Android.mk @@ -15,7 +15,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ -LOCAL_SHARED_LIBRARIES := libjsi libfolly_futures libfolly_json libreact_render_core libreact_render_debug libreact_utils libglog_init +LOCAL_SHARED_LIBRARIES := libjsi libfolly_futures libfolly_json libreact_render_core libreact_render_debug libreact_utils libglog_init libreact_debug LOCAL_CFLAGS := \ -DLOG_TAG=\"Fabric\" @@ -30,3 +30,4 @@ $(call import-module,jsi) $(call import-module,react/renderer/core) $(call import-module,react/renderer/debug) $(call import-module,react/utils) +$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp index cb149393dde838..27cb851b102c7c 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp @@ -68,7 +68,7 @@ static std::string componentNameByReactViewName(std::string viewName) { } // TODO T63839307: remove this condition after deleting TextInlineImage from - // Paper + // non-Fabric code if (viewName == "TextInlineImage") { return "Image"; } @@ -94,9 +94,8 @@ static std::string componentNameByReactViewName(std::string viewName) { // We need this temporarily for testing purposes until we have proper // implementation of core components. - if (viewName == "ScrollContentView" || - viewName == "AndroidHorizontalScrollContentView" // Android - ) { + // iOS-only + if (viewName == "ScrollContentView") { return "View"; } diff --git a/ReactCommon/react/renderer/components/image/Android.mk b/ReactCommon/react/renderer/components/image/Android.mk index f1b4276e50f675..eeaa35d4e74ae6 100644 --- a/ReactCommon/react/renderer/components/image/Android.mk +++ b/ReactCommon/react/renderer/components/image/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_render_imagemanager +LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_render_imagemanager libreact_debug include $(BUILD_SHARED_LIBRARY) @@ -34,3 +34,4 @@ $(call import-module,react/renderer/graphics) $(call import-module,react/renderer/imagemanager) $(call import-module,react/renderer/components/view) $(call import-module,yogajni) +$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/components/image/BUCK b/ReactCommon/react/renderer/components/image/BUCK index f6288911bfe11d..512859a6e39aaa 100644 --- a/ReactCommon/react/renderer/components/image/BUCK +++ b/ReactCommon/react/renderer/components/image/BUCK @@ -50,6 +50,7 @@ rn_xplat_cxx_library( "//xplat/folly:headers_only", "//xplat/folly:molly", YOGA_CXX_TARGET, + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/debug:debug"), react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/graphics:graphics"), diff --git a/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h b/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h index 1e2b6708649ff2..56bf1f18c35290 100644 --- a/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -28,7 +29,7 @@ class ImageComponentDescriptor final void adopt(UnsharedShadowNode shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - assert(std::dynamic_pointer_cast(shadowNode)); + react_native_assert(std::dynamic_pointer_cast(shadowNode)); auto imageShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/image/conversions.h b/ReactCommon/react/renderer/components/image/conversions.h index a77d40fad489e1..fa1dd602161e12 100644 --- a/ReactCommon/react/renderer/components/image/conversions.h +++ b/ReactCommon/react/renderer/components/image/conversions.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -88,7 +89,7 @@ inline std::string toString(const ImageSource &value) { } inline void fromRawValue(const RawValue &value, ImageResizeMode &result) { - assert(value.hasType()); + react_native_assert(value.hasType()); auto stringValue = (std::string)value; if (stringValue == "cover") { result = ImageResizeMode::Cover; diff --git a/ReactCommon/react/renderer/components/modal/BUCK b/ReactCommon/react/renderer/components/modal/BUCK index 8078dd25c100d0..3eb48ca4cb6cdd 100644 --- a/ReactCommon/react/renderer/components/modal/BUCK +++ b/ReactCommon/react/renderer/components/modal/BUCK @@ -75,6 +75,7 @@ rn_xplat_cxx_library( "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/debug:debug"), react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/components/image:image"), diff --git a/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h b/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h index e821c911d38879..d9e9fc87796238 100644 --- a/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h @@ -8,6 +8,7 @@ #pragma once #include +#include #include #include @@ -24,11 +25,12 @@ class ModalHostViewComponentDescriptor final using ConcreteComponentDescriptor::ConcreteComponentDescriptor; void adopt(UnsharedShadowNode shadowNode) const override { - assert(std::dynamic_pointer_cast(shadowNode)); + react_native_assert( + std::dynamic_pointer_cast(shadowNode)); auto modalShadowNode = std::static_pointer_cast(shadowNode); - assert( + react_native_assert( std::dynamic_pointer_cast(modalShadowNode)); auto layoutableShadowNode = std::static_pointer_cast(modalShadowNode); diff --git a/ReactCommon/react/renderer/components/picker/Android.mk b/ReactCommon/react/renderer/components/picker/Android.mk index 44e77f7fd947dd..0aa9cce17b777b 100644 --- a/ReactCommon/react/renderer/components/picker/Android.mk +++ b/ReactCommon/react/renderer/components/picker/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_uimanager librrc_view libreact_render_componentregistry libreact_codegen_rncore +LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_uimanager librrc_view libreact_render_componentregistry libreact_codegen_rncore libreact_debug include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/react/renderer/components/picker/iospicker/BUCK b/ReactCommon/react/renderer/components/picker/iospicker/BUCK index 5ae7c2764206cc..cfba993e95315d 100644 --- a/ReactCommon/react/renderer/components/picker/iospicker/BUCK +++ b/ReactCommon/react/renderer/components/picker/iospicker/BUCK @@ -48,6 +48,7 @@ rn_xplat_cxx_library( deps = [ "//xplat/folly:headers_only", YOGA_CXX_TARGET, + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/utils:utils"), react_native_xplat_target("react/renderer/attributedstring:attributedstring"), react_native_xplat_target("react/renderer/core:core"), diff --git a/ReactCommon/react/renderer/components/picker/iospicker/conversions.h b/ReactCommon/react/renderer/components/picker/iospicker/conversions.h index b39f10431b78bc..c2577779cdea82 100644 --- a/ReactCommon/react/renderer/components/picker/iospicker/conversions.h +++ b/ReactCommon/react/renderer/components/picker/iospicker/conversions.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -17,26 +18,26 @@ namespace react { inline void fromRawValue( const RawValue &value, std::vector &items) { - assert(value.hasType>()); + react_native_assert(value.hasType>()); auto array = (std::vector)value; items.reserve(array.size()); for (auto const &val : array) { bool check = val.hasType>(); - assert(check); + react_native_assert(check); auto map = (better::map)val; PickerItemsStruct item; if (map.find("label") != map.end()) { - assert(map.at("label").hasType()); + react_native_assert(map.at("label").hasType()); item.label = (std::string)map.at("label"); } if (map.find("value") != map.end()) { - assert(map.at("value").hasType()); + react_native_assert(map.at("value").hasType()); item.value = (std::string)map.at("value"); } if (map.find("textColor") != map.end()) { - assert(map.at("textColor").hasType()); + react_native_assert(map.at("textColor").hasType()); item.textColor = (int)map.at("textColor"); } items.push_back(item); diff --git a/ReactCommon/react/renderer/components/progressbar/Android.mk b/ReactCommon/react/renderer/components/progressbar/Android.mk index 5bdcc3d147d4e9..6e0297990bdcff 100644 --- a/ReactCommon/react/renderer/components/progressbar/Android.mk +++ b/ReactCommon/react/renderer/components/progressbar/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libfbjni libreact_codegen_rncore libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view +LOCAL_SHARED_LIBRARIES := libfbjni libreact_codegen_rncore libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/react/renderer/components/root/Android.mk b/ReactCommon/react/renderer/components/root/Android.mk index ed7f2302b60fff..76de642727803e 100644 --- a/ReactCommon/react/renderer/components/root/Android.mk +++ b/ReactCommon/react/renderer/components/root/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view +LOCAL_SHARED_LIBRARIES := libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug include $(BUILD_SHARED_LIBRARY) @@ -32,4 +32,5 @@ $(call import-module,react/renderer/components/view) $(call import-module,react/renderer/core) $(call import-module,react/renderer/debug) $(call import-module,react/renderer/graphics) +$(call import-module,react/debug) $(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/components/scrollview/Android.mk b/ReactCommon/react/renderer/components/scrollview/Android.mk index c935e080753022..8726fbea871b8c 100644 --- a/ReactCommon/react/renderer/components/scrollview/Android.mk +++ b/ReactCommon/react/renderer/components/scrollview/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view +LOCAL_SHARED_LIBRARIES := libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug include $(BUILD_SHARED_LIBRARY) @@ -32,4 +32,5 @@ $(call import-module,react/renderer/components/view) $(call import-module,react/renderer/core) $(call import-module,react/renderer/debug) $(call import-module,react/renderer/graphics) +$(call import-module,react/debug) $(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/components/slider/Android.mk b/ReactCommon/react/renderer/components/slider/Android.mk index b77f1085462ba1..d64d8a9cb6dab4 100644 --- a/ReactCommon/react/renderer/components/slider/Android.mk +++ b/ReactCommon/react/renderer/components/slider/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libfbjni libreact_codegen_rncore libreact_render_imagemanager libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager librrc_image libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view +LOCAL_SHARED_LIBRARIES := libfbjni libreact_codegen_rncore libreact_render_imagemanager libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager librrc_image libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/react/renderer/components/slider/BUCK b/ReactCommon/react/renderer/components/slider/BUCK index 0b686ba447d76b..412f0443b3e7bc 100644 --- a/ReactCommon/react/renderer/components/slider/BUCK +++ b/ReactCommon/react/renderer/components/slider/BUCK @@ -83,6 +83,7 @@ rn_xplat_cxx_library( "//xplat/folly:headers_only", "//xplat/folly:molly", YOGA_CXX_TARGET, + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/debug:debug"), react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/components/image:image"), diff --git a/ReactCommon/react/renderer/components/slider/SliderComponentDescriptor.h b/ReactCommon/react/renderer/components/slider/SliderComponentDescriptor.h index 687ea411a0c06c..8b699249e9f5f1 100644 --- a/ReactCommon/react/renderer/components/slider/SliderComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/slider/SliderComponentDescriptor.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -31,7 +32,8 @@ class SliderComponentDescriptor final void adopt(UnsharedShadowNode shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - assert(std::dynamic_pointer_cast(shadowNode)); + react_native_assert( + std::dynamic_pointer_cast(shadowNode)); auto sliderShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/slider/platform/ios/SliderMeasurementsManager.cpp b/ReactCommon/react/renderer/components/slider/platform/ios/SliderMeasurementsManager.cpp index b7b930825e224d..d23aff739c7aff 100644 --- a/ReactCommon/react/renderer/components/slider/platform/ios/SliderMeasurementsManager.cpp +++ b/ReactCommon/react/renderer/components/slider/platform/ios/SliderMeasurementsManager.cpp @@ -7,13 +7,15 @@ #include "SliderMeasurementsManager.h" +#include + namespace facebook { namespace react { Size SliderMeasurementsManager::measure( SurfaceId surfaceId, LayoutConstraints layoutConstraints) const { - assert(false); // should never reach this point + react_native_assert(false); // should never reach this point return {}; } diff --git a/ReactCommon/react/renderer/components/switch/Android.mk b/ReactCommon/react/renderer/components/switch/Android.mk index 3f155056991974..1cba4aa39daf87 100644 --- a/ReactCommon/react/renderer/components/switch/Android.mk +++ b/ReactCommon/react/renderer/components/switch/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libfbjni libreact_codegen_rncore libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view +LOCAL_SHARED_LIBRARIES := libfbjni libreact_codegen_rncore libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/react/renderer/components/text/Android.mk b/ReactCommon/react/renderer/components/text/Android.mk index d1e0b37affd010..160867b6ac9067 100644 --- a/ReactCommon/react/renderer/components/text/Android.mk +++ b/ReactCommon/react/renderer/components/text/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_uimanager libreact_render_textlayoutmanager libreact_render_attributedstring libreact_render_mounting librrc_view libreact_utils +LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_uimanager libreact_render_textlayoutmanager libreact_render_attributedstring libreact_render_mounting librrc_view libreact_utils libreact_debug include $(BUILD_SHARED_LIBRARY) @@ -37,4 +37,5 @@ $(call import-module,react/renderer/textlayoutmanager) $(call import-module,react/renderer/uimanager) $(call import-module,react/renderer/components/view) $(call import-module,react/utils) +$(call import-module,react/debug) $(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/components/text/BUCK b/ReactCommon/react/renderer/components/text/BUCK index c3616745a1418f..1a38a17d874945 100644 --- a/ReactCommon/react/renderer/components/text/BUCK +++ b/ReactCommon/react/renderer/components/text/BUCK @@ -98,5 +98,6 @@ fb_xplat_cxx_test( ":text", "//xplat/folly:molly", "//xplat/third-party/gmock:gtest", + react_native_xplat_target("react/debug:debug"), ], ) diff --git a/ReactCommon/react/renderer/components/text/ParagraphState.h b/ReactCommon/react/renderer/components/text/ParagraphState.h index 8f320af68e6a1f..bc72ac28c55179 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphState.h +++ b/ReactCommon/react/renderer/components/text/ParagraphState.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -54,7 +55,7 @@ class ParagraphState final { ParagraphState( ParagraphState const &previousState, folly::dynamic const &data) { - assert(false && "Not supported"); + react_native_assert(false && "Not supported"); }; folly::dynamic getDynamic() const; #endif diff --git a/ReactCommon/react/renderer/components/text/tests/ParagraphLocalDataTest.cpp b/ReactCommon/react/renderer/components/text/tests/ParagraphLocalDataTest.cpp index 24e51148450f3c..f38bfe8de4f8e7 100644 --- a/ReactCommon/react/renderer/components/text/tests/ParagraphLocalDataTest.cpp +++ b/ReactCommon/react/renderer/components/text/tests/ParagraphLocalDataTest.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -40,12 +41,14 @@ TEST(ParagraphLocalDataTest, testSomething) { auto result = toDynamic(paragraphState)["attributedString"]; - assert(result["string"] == fragment.string); + react_native_assert(result["string"] == fragment.string); auto textAttribute = result["fragments"][0]["textAttributes"]; - assert(textAttribute["foregroundColor"] == toDynamic(text.foregroundColor)); - assert(textAttribute["opacity"] == text.opacity); - assert(textAttribute["fontStyle"] == toString(*text.fontStyle)); - assert(textAttribute["fontWeight"] == toString(*text.fontWeight)); + react_native_assert( + textAttribute["foregroundColor"] == toDynamic(text.foregroundColor)); + react_native_assert(textAttribute["opacity"] == text.opacity); + react_native_assert(textAttribute["fontStyle"] == toString(*text.fontStyle)); + react_native_assert( + textAttribute["fontWeight"] == toString(*text.fontWeight)); } #endif diff --git a/ReactCommon/react/renderer/components/textinput/Android.mk b/ReactCommon/react/renderer/components/textinput/Android.mk index f04e39bab0dbb2..729aa7de908756 100644 --- a/ReactCommon/react/renderer/components/textinput/Android.mk +++ b/ReactCommon/react/renderer/components/textinput/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_mounting libreact_render_componentregistry libreact_render_debug libreact_render_graphics libreact_render_uimanager libreact_render_imagemanager libreact_render_textlayoutmanager libreact_render_attributedstring librrc_text librrc_image librrc_view libreact_utils +LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_mounting libreact_render_componentregistry libreact_render_debug libreact_render_graphics libreact_render_uimanager libreact_render_imagemanager libreact_render_textlayoutmanager libreact_render_attributedstring librrc_text librrc_image librrc_view libreact_utils libreact_debug include $(BUILD_SHARED_LIBRARY) @@ -41,4 +41,5 @@ $(call import-module,react/renderer/components/image) $(call import-module,react/renderer/components/view) $(call import-module,react/renderer/components/text) $(call import-module,react/utils) +$(call import-module,react/debug) $(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.cpp b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.cpp index 4e771d9e5e5780..fb5c0ff7f33bda 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.cpp +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.cpp @@ -7,6 +7,7 @@ #include "TextInputShadowNode.h" +#include #include #include #include @@ -82,8 +83,8 @@ void TextInputShadowNode::updateStateIfNeeded( auto reactTreeAttributedString = getAttributedString(layoutContext); auto const &state = getStateData(); - assert(textLayoutManager_); - assert( + react_native_assert(textLayoutManager_); + react_native_assert( (!state.layoutManager || state.layoutManager == textLayoutManager_) && "`StateData` refers to a different `TextLayoutManager`"); diff --git a/ReactCommon/react/renderer/components/unimplementedview/Android.mk b/ReactCommon/react/renderer/components/unimplementedview/Android.mk index 4495846594ace0..64e291b5fce9a4 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/Android.mk +++ b/ReactCommon/react/renderer/components/unimplementedview/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view +LOCAL_SHARED_LIBRARIES := libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug include $(BUILD_SHARED_LIBRARY) @@ -33,3 +33,4 @@ $(call import-module,react/renderer/core) $(call import-module,react/renderer/debug) $(call import-module,react/renderer/graphics) $(call import-module,yogajni) +$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/components/unimplementedview/BUCK b/ReactCommon/react/renderer/components/unimplementedview/BUCK index cce569f735a355..f7ce99f0223af6 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/BUCK +++ b/ReactCommon/react/renderer/components/unimplementedview/BUCK @@ -53,6 +53,7 @@ rn_xplat_cxx_library( "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/debug:debug"), react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/components/view:view"), diff --git a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp index 24946364a4cf1d..56e5d2a6fa13ed 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp +++ b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp @@ -7,6 +7,8 @@ #include "UnimplementedViewComponentDescriptor.h" +#include + namespace facebook { namespace react { @@ -25,7 +27,8 @@ Props::Shared UnimplementedViewComponentDescriptor::cloneProps( auto clonedProps = ConcreteComponentDescriptor::cloneProps( props, rawProps); - assert(std::dynamic_pointer_cast(clonedProps)); + react_native_assert( + std::dynamic_pointer_cast(clonedProps)); // We have to clone `Props` object one more time to make sure that we have // an unshared (and non-`const`) copy of it which we can mutate. diff --git a/ReactCommon/react/renderer/components/view/Android.mk b/ReactCommon/react/renderer/components/view/Android.mk index e8c7254d592996..de9148308c95e2 100644 --- a/ReactCommon/react/renderer/components/view/Android.mk +++ b/ReactCommon/react/renderer/components/view/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics +LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_debug include $(BUILD_SHARED_LIBRARY) @@ -32,3 +32,4 @@ $(call import-module,react/renderer/core) $(call import-module,react/renderer/debug) $(call import-module,react/renderer/graphics) $(call import-module,yogajni) +$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/components/view/Touch.h b/ReactCommon/react/renderer/components/view/Touch.h index 91b6db7522b552..5a150b955e321d 100644 --- a/ReactCommon/react/renderer/components/view/Touch.h +++ b/ReactCommon/react/renderer/components/view/Touch.h @@ -52,7 +52,38 @@ struct Touch { Float force; /* - * The time in seconds when the touch occurred or when it was last mutated. + * The time in seconds (with fractional milliseconds) when the touch occurred + * or when it was last mutated. + * + * Whenever possible this should be computed as: + * 1. Pick MONO_CLOCK_NOW, a monotonic system clock. Generally, something like + * `systemUptimeMillis`. + * 2. BASIS_TIME = unix timestamp from unix epoch (ms) - MONO_CLOCK_NOW + * 3. Then assign timestamp = BASIS_TIME + MONO_CLOCK_NOW + * + * The effect should be UNIX timestamp from UNIX epoch, but as a monotonic + * clock (if you just assign to current system time, it can move backwards due + * to clock adjustements, leap seconds, etc etc). So the vast majority of the + * time it will look identical to current UNIX time, but there are some + * edge-cases where it can drift. + * + * If you are not able to use the scheme above for some reason, prefer to use + * a monotonic clock. This timestamp MUST be monotonic. Do NOT just pass along + * system time. + * + * The goal is to allow touch latency to be computed in JS. JS does not have + * access to something like `systemUptimeMillis`, it generally can only access + * the current system time. This *does* mean that the touch latency could be + * computed incorrectly in cases of clock drift, so you should only use this + * as telemetry to get a decent, but not totally perfect, idea of performance. + * Do not use this latency information for anything "mission critical". You + * can assume it's probably reasonably accurate 99% of the time. + * + * Note that we attempt to adhere to the spec of timestamp here: + * https://dom.spec.whatwg.org/#dom-event-timestamp + * Notably, since `global` is not a Window object in React Native, we have + * some flexibility in how we define the time origin: + * https://w3c.github.io/hr-time/#dfn-time-origin */ Float timestamp; diff --git a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp index d30974b4949115..5f17f378a05133 100644 --- a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -6,6 +6,7 @@ */ #include "YogaLayoutableShadowNode.h" +#include #include #include #include @@ -715,7 +716,7 @@ void YogaLayoutableShadowNode::ensureConsistency() const { } void YogaLayoutableShadowNode::ensureYogaChildrenOwnersConsistency() const { -#ifndef NDEBUG +#ifdef REACT_NATIVE_DEBUG // Checking that all Yoga node children have the same `owner`. // The owner might be not equal to the `yogaNode_` though. auto &yogaChildren = yogaNode_.getChildren(); @@ -730,7 +731,7 @@ void YogaLayoutableShadowNode::ensureYogaChildrenOwnersConsistency() const { } void YogaLayoutableShadowNode::ensureYogaChildrenLookFine() const { -#ifndef NDEBUG +#ifdef REACT_NATIVE_DEBUG // Checking that the shapes of Yoga node children object look fine. // This is the only heuristic that might produce false-positive results // (really broken dangled nodes might look fine). This is useful as an early @@ -748,7 +749,7 @@ void YogaLayoutableShadowNode::ensureYogaChildrenLookFine() const { } void YogaLayoutableShadowNode::ensureYogaChildrenAlighment() const { -#ifndef NDEBUG +#ifdef REACT_NATIVE_DEBUG // If the node is not a leaf node, checking that: // - All children are `YogaLayoutableShadowNode` subclasses. // - All Yoga children are owned/connected to corresponding children of diff --git a/ReactCommon/react/renderer/core/Android.mk b/ReactCommon/react/renderer/core/Android.mk index 66912423b0514b..b6787cd9cd8d10 100644 --- a/ReactCommon/react/renderer/core/Android.mk +++ b/ReactCommon/react/renderer/core/Android.mk @@ -15,7 +15,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ -LOCAL_SHARED_LIBRARIES := libfolly_json libjsi libfolly_futures libreact_utils libreact_render_debug libreact_render_graphics +LOCAL_SHARED_LIBRARIES := libfolly_json libjsi libfolly_futures libreact_utils libreact_debug libreact_render_debug libreact_render_graphics LOCAL_CFLAGS := \ -DLOG_TAG=\"Fabric\" @@ -27,5 +27,6 @@ include $(BUILD_SHARED_LIBRARY) $(call import-module,folly) $(call import-module,jsi) $(call import-module,react/utils) +$(call import-module,react/debug) $(call import-module,react/renderer/debug) $(call import-module,react/renderer/graphics) diff --git a/ReactCommon/react/renderer/core/BUCK b/ReactCommon/react/renderer/core/BUCK index 63c5767c9ac19b..329b70c69bc609 100644 --- a/ReactCommon/react/renderer/core/BUCK +++ b/ReactCommon/react/renderer/core/BUCK @@ -80,6 +80,7 @@ fb_xplat_cxx_test( deps = [ "//xplat/folly:molly", "//xplat/js/react-native-github/ReactCommon/react/renderer/element:element", + react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/components/view:view"), react_native_xplat_target("react/renderer/components/scrollview:scrollview"), react_native_xplat_target("react/renderer/components/text:text"), diff --git a/ReactCommon/react/renderer/core/Sealable.cpp b/ReactCommon/react/renderer/core/Sealable.cpp index d2e6fc46432233..2326a4ed7b2f70 100644 --- a/ReactCommon/react/renderer/core/Sealable.cpp +++ b/ReactCommon/react/renderer/core/Sealable.cpp @@ -7,6 +7,7 @@ #include "Sealable.h" +#include #include namespace facebook { @@ -24,7 +25,7 @@ namespace react { * http://en.cppreference.com/w/cpp/language/rule_of_three */ -#ifndef NDEBUG +#ifdef REACT_NATIVE_DEBUG Sealable::Sealable() : sealed_(false) {} diff --git a/ReactCommon/react/renderer/core/Sealable.h b/ReactCommon/react/renderer/core/Sealable.h index 2ca6f64aa65025..f57c42eda5ac2b 100644 --- a/ReactCommon/react/renderer/core/Sealable.h +++ b/ReactCommon/react/renderer/core/Sealable.h @@ -9,6 +9,8 @@ #include +#include + namespace facebook { namespace react { @@ -42,8 +44,9 @@ namespace react { * must be prevented. */ -#ifdef NDEBUG +#ifndef REACT_NATIVE_DEBUG +// Release-mode, production version class Sealable { public: inline void seal() const {} @@ -55,6 +58,7 @@ class Sealable { #else +// Debug version class Sealable { public: Sealable(); diff --git a/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp b/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp index 48a8726662b641..7bb589914edd8d 100644 --- a/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp +++ b/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -275,7 +276,7 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypesIncomplete) { EXPECT_EQ((int)*raw.at("intValue", nullptr, nullptr), 42); } -#ifndef NDEBUG +#ifdef REACT_NATIVE_DEBUG TEST(RawPropsTest, handleRawPropsPrimitiveTypesIncorrectLookup) { const auto &raw = RawProps(folly::dynamic::object("intValue", (int)42)); diff --git a/ReactCommon/react/renderer/graphics/Android.mk b/ReactCommon/react/renderer/graphics/Android.mk index 675a27973a5f91..8ef8528ecb6a72 100644 --- a/ReactCommon/react/renderer/graphics/Android.mk +++ b/ReactCommon/react/renderer/graphics/Android.mk @@ -11,7 +11,7 @@ LOCAL_MODULE := react_render_graphics LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp $(LOCAL_PATH)/platform/cxx/react/renderer/graphics/*.cpp) -LOCAL_SHARED_LIBRARIES := libfolly_json +LOCAL_SHARED_LIBRARIES := libfolly_json libreact_debug LOCAL_STATIC_LIBRARIES := @@ -27,3 +27,4 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall include $(BUILD_SHARED_LIBRARY) $(call import-module,folly) +$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/imagemanager/Android.mk b/ReactCommon/react/renderer/imagemanager/Android.mk index 0eca0e748917b9..b9a73742cacb9b 100644 --- a/ReactCommon/react/renderer/imagemanager/Android.mk +++ b/ReactCommon/react/renderer/imagemanager/Android.mk @@ -11,7 +11,7 @@ LOCAL_MODULE := react_render_imagemanager LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp $(LOCAL_PATH)/platform/cxx/react/renderer/imagemanager/*.cpp) -LOCAL_SHARED_LIBRARIES := libfolly_json libyoga libfolly_json libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_mounting +LOCAL_SHARED_LIBRARIES := libfolly_json libyoga libfolly_json libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_mounting libreact_debug LOCAL_STATIC_LIBRARIES := @@ -32,4 +32,5 @@ $(call import-module,react/renderer/core) $(call import-module,react/renderer/debug) $(call import-module,react/renderer/graphics) $(call import-module,react/renderer/mounting) +$(call import-module,react/debug) $(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp b/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp index 048a4510856bce..5d718d50493b8c 100644 --- a/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp +++ b/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp @@ -7,7 +7,6 @@ #include -#include #include #include diff --git a/ReactCommon/react/renderer/mounting/Android.mk b/ReactCommon/react/renderer/mounting/Android.mk index 7992d10a977c53..672372269bb028 100644 --- a/ReactCommon/react/renderer/mounting/Android.mk +++ b/ReactCommon/react/renderer/mounting/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libbetter libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug librrc_view librrc_root libreact_utils +LOCAL_SHARED_LIBRARIES := libbetter libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug librrc_view librrc_root libreact_utils libreact_debug include $(BUILD_SHARED_LIBRARY) @@ -34,4 +34,5 @@ $(call import-module,react/renderer/components/view) $(call import-module,react/renderer/core) $(call import-module,react/renderer/debug) $(call import-module,react/utils) +$(call import-module,react/debug) $(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/scheduler/Android.mk b/ReactCommon/react/renderer/scheduler/Android.mk index 992ac27f7edd9f..99f83fe362f806 100644 --- a/ReactCommon/react/renderer/scheduler/Android.mk +++ b/ReactCommon/react/renderer/scheduler/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libyoga librrc_view libreact_utils libreact_render_templateprocessor libreact_render_graphics libreact_render_uimanager libfolly_futures libreact_render_componentregistry glog libreactconfig libfolly_json libjsi libreact_render_core libreact_render_debug librrc_root libreact_render_mounting +LOCAL_SHARED_LIBRARIES := libyoga librrc_view libreact_utils libreact_render_templateprocessor libreact_render_graphics libreact_render_uimanager libfolly_futures libreact_render_componentregistry glog libreactconfig libfolly_json libjsi libreact_render_core libreact_render_debug librrc_root libreact_render_mounting libreact_debug include $(BUILD_SHARED_LIBRARY) @@ -39,4 +39,5 @@ $(call import-module,react/renderer/mounting) $(call import-module,react/renderer/uimanager) $(call import-module,react/renderer/templateprocessor) $(call import-module,react/utils) +$(call import-module,react/debug) $(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp b/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp index 2649227d327ffd..4b8cabf43a3305 100644 --- a/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp +++ b/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp @@ -7,6 +7,8 @@ #include "AsynchronousEventBeat.h" +#include + namespace facebook { namespace react { @@ -23,7 +25,7 @@ AsynchronousEventBeat::AsynchronousEventBeat( void AsynchronousEventBeat::activityDidChange( RunLoopObserver::Delegate const *delegate, RunLoopObserver::Activity activity) const noexcept { - assert(delegate == this); + react_native_assert(delegate == this); induce(); } diff --git a/ReactCommon/react/renderer/textlayoutmanager/Android.mk b/ReactCommon/react/renderer/textlayoutmanager/Android.mk index d048ec00061327..fd9e86cdb38b8e 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/Android.mk +++ b/ReactCommon/react/renderer/textlayoutmanager/Android.mk @@ -11,7 +11,7 @@ LOCAL_MODULE := react_render_textlayoutmanager LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp $(LOCAL_PATH)/platform/android/react/renderer/textlayoutmanager/*.cpp) -LOCAL_SHARED_LIBRARIES := libfolly_futures libreactnativeutilsjni libreact_utils libfb libfbjni libreact_render_uimanager libreact_render_componentregistry libreact_render_attributedstring libfolly_json libyoga libfolly_json libreact_render_core libreact_render_debug libreact_render_graphics +LOCAL_SHARED_LIBRARIES := libfolly_futures libreactnativeutilsjni libreact_utils libfb libfbjni libreact_render_uimanager libreact_render_componentregistry libreact_render_attributedstring libfolly_json libyoga libfolly_json libreact_render_core libreact_render_debug libreact_render_graphics libreact_debug LOCAL_STATIC_LIBRARIES := diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp index 83f8c930311316..a9e486219a3558 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp @@ -7,6 +7,8 @@ #include "TextLayoutManager.h" +#include + #include #include #include @@ -29,12 +31,15 @@ TextMeasurement TextLayoutManager::measure( LayoutConstraints layoutConstraints) const { auto &attributedString = attributedStringBox.getValue(); - return measureCache_.get( + auto measurement = measureCache_.get( {attributedString, paragraphAttributes, layoutConstraints}, [&](TextMeasureCacheKey const &key) { return doMeasure( attributedString, paragraphAttributes, layoutConstraints); }); + + measurement.size = layoutConstraints.clamp(measurement.size); + return measurement; } TextMeasurement TextLayoutManager::measureCachedSpannableById( @@ -126,6 +131,8 @@ TextMeasurement TextLayoutManager::doMeasure( AttributedString attributedString, ParagraphAttributes paragraphAttributes, LayoutConstraints layoutConstraints) const { + layoutConstraints.maximumSize.height = std::numeric_limits::infinity(); + int attachmentsCount = 0; for (auto fragment : attributedString.getFragments()) { if (fragment.isAttachment()) { diff --git a/ReactCommon/react/renderer/uimanager/Android.mk b/ReactCommon/react/renderer/uimanager/Android.mk index 8ddd0e15831d61..95a4e53dd1d00e 100644 --- a/ReactCommon/react/renderer/uimanager/Android.mk +++ b/ReactCommon/react/renderer/uimanager/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libreact_render_graphics libfolly_futures libruntimeexecutor libreact_render_componentregistry glog libreactconfig libfolly_json libjsi libreact_render_core libreact_render_debug librrc_view librrc_root libreact_render_mounting +LOCAL_SHARED_LIBRARIES := libreact_render_graphics libfolly_futures libruntimeexecutor libreact_render_componentregistry glog libreactconfig libfolly_json libjsi libreact_render_core libreact_render_debug librrc_view librrc_root libreact_render_mounting libreact_debug include $(BUILD_SHARED_LIBRARY) @@ -36,4 +36,5 @@ $(call import-module,react/renderer/core) $(call import-module,react/renderer/debug) $(call import-module,react/renderer/graphics) $(call import-module,react/renderer/mounting) +$(call import-module,react/debug) $(call import-module,runtimeexecutor) diff --git a/ReactCommon/react/utils/Android.mk b/ReactCommon/react/utils/Android.mk index 8a8cfca179728a..4e15562a50dcd0 100644 --- a/ReactCommon/react/utils/Android.mk +++ b/ReactCommon/react/utils/Android.mk @@ -11,7 +11,7 @@ LOCAL_MODULE := react_utils LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_C_INCLUDES := $(LOCAL_PATH) +LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/../../ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../ LOCAL_CFLAGS := \ @@ -20,6 +20,8 @@ LOCAL_CFLAGS := \ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := +LOCAL_SHARED_LIBRARIES := libreact_debug include $(BUILD_SHARED_LIBRARY) + +$(call import-module,react/debug) diff --git a/ReactCommon/react/utils/BUCK b/ReactCommon/react/utils/BUCK index 2eddc79ce719d2..6e2f7ab2fe9021 100644 --- a/ReactCommon/react/utils/BUCK +++ b/ReactCommon/react/utils/BUCK @@ -59,5 +59,6 @@ rn_xplat_cxx_library( "//xplat/folly:molly", "//xplat/jsi:jsi", react_native_xplat_target("better:better"), + react_native_xplat_target("react/debug:debug"), ], ) diff --git a/ReactCommon/react/utils/CalledOnceMovableOnlyFunction.h b/ReactCommon/react/utils/CalledOnceMovableOnlyFunction.h index b6d31707d139cc..4d4d2c0d056d96 100644 --- a/ReactCommon/react/utils/CalledOnceMovableOnlyFunction.h +++ b/ReactCommon/react/utils/CalledOnceMovableOnlyFunction.h @@ -7,6 +7,8 @@ #include +#include + namespace facebook { namespace react { @@ -31,7 +33,7 @@ class CalledOnceMovableOnlyFunction { } ~CalledOnceMovableOnlyFunction() { - assert( + react_native_assert( (wasCalled_ || wasMovedFrom_) && "`CalledOnceMovableOnlyFunction` is destroyed before being called."); } @@ -57,7 +59,7 @@ class CalledOnceMovableOnlyFunction { CalledOnceMovableOnlyFunction &operator=( CalledOnceMovableOnlyFunction &&other) noexcept { - assert( + react_native_assert( (wasCalled_ || wasMovedFrom_) && "`CalledOnceMovableOnlyFunction` is re-assigned before being called."); wasCalled_ = false; @@ -71,10 +73,10 @@ class CalledOnceMovableOnlyFunction { * Callable. */ ReturnT operator()(ArgumentT... args) { - assert( + react_native_assert( !wasMovedFrom_ && "`CalledOnceMovableOnlyFunction` is called after being moved from."); - assert( + react_native_assert( !wasCalled_ && "`CalledOnceMovableOnlyFunction` is called more than once."); diff --git a/ReactCommon/react/utils/ContextContainer.h b/ReactCommon/react/utils/ContextContainer.h index a8d09655660995..f0e2613fdb9931 100644 --- a/ReactCommon/react/utils/ContextContainer.h +++ b/ReactCommon/react/utils/ContextContainer.h @@ -15,6 +15,9 @@ #include #include +#include +#include + namespace facebook { namespace react { @@ -43,7 +46,7 @@ class ContextContainer final { instances_.insert({key, std::make_shared(instance)}); -#ifndef NDEBUG +#ifdef REACT_NATIVE_DEBUG typeNames_.insert({key, typeid(T).name()}); #endif } @@ -57,7 +60,7 @@ class ContextContainer final { instances_.erase(key); -#ifndef NDEBUG +#ifdef REACT_NATIVE_DEBUG typeNames_.erase(key); #endif } @@ -73,7 +76,7 @@ class ContextContainer final { for (auto const &pair : contextContainer.instances_) { instances_.erase(pair.first); instances_.insert(pair); -#ifndef NDEBUG +#ifdef REACT_NATIVE_DEBUG typeNames_.erase(pair.first); typeNames_.insert( {pair.first, contextContainer.typeNames_.at(pair.first)}); @@ -90,12 +93,14 @@ class ContextContainer final { T at(std::string const &key) const { std::shared_lock lock(mutex_); - assert( + react_native_assert( instances_.find(key) != instances_.end() && "ContextContainer doesn't have an instance for given key."); - assert( +#ifdef REACT_NATIVE_DEBUG + react_native_assert( typeNames_.at(key) == typeid(T).name() && "ContextContainer stores an instance of different type for given key."); +#endif return *std::static_pointer_cast(instances_.at(key)); } @@ -113,9 +118,11 @@ class ContextContainer final { return {}; } - assert( +#ifdef REACT_NATIVE_DEBUG + react_native_assert( typeNames_.at(key) == typeid(T).name() && "ContextContainer stores an instance of different type for given key."); +#endif return *std::static_pointer_cast(iterator->second); } @@ -124,7 +131,7 @@ class ContextContainer final { mutable better::shared_mutex mutex_; // Protected by mutex_`. mutable better::map> instances_; -#ifndef NDEBUG +#ifdef REACT_NATIVE_DEBUG mutable better::map typeNames_; #endif }; diff --git a/ReactCommon/react/utils/ManagedObjectWrapper.h b/ReactCommon/react/utils/ManagedObjectWrapper.h index 623158015740d5..f91cd3e99d81d2 100644 --- a/ReactCommon/react/utils/ManagedObjectWrapper.h +++ b/ReactCommon/react/utils/ManagedObjectWrapper.h @@ -7,6 +7,8 @@ #pragma once +#include + #if defined(__OBJC__) && defined(__cplusplus) #if TARGET_OS_MAC && TARGET_OS_IPHONE @@ -65,7 +67,7 @@ inline std::shared_ptr wrapManagedObjectWeakly(id object) noexcept inline id unwrapManagedObjectWeakly(std::shared_ptr const &object) noexcept { RCTInternalGenericWeakWrapper *weakWrapper = (RCTInternalGenericWeakWrapper *)unwrapManagedObject(object); - assert(weakWrapper && "`RCTInternalGenericWeakWrapper` instance must not be `nil`."); + react_native_assert(weakWrapper && "`RCTInternalGenericWeakWrapper` instance must not be `nil`."); return weakWrapper.object; } diff --git a/ReactCommon/react/utils/RunLoopObserver.cpp b/ReactCommon/react/utils/RunLoopObserver.cpp index bca81b6664d7b5..d24c3ede72bb13 100644 --- a/ReactCommon/react/utils/RunLoopObserver.cpp +++ b/ReactCommon/react/utils/RunLoopObserver.cpp @@ -7,7 +7,7 @@ #include "RunLoopObserver.h" -#include +#include namespace facebook { namespace react { @@ -19,8 +19,9 @@ RunLoopObserver::RunLoopObserver( void RunLoopObserver::setDelegate(Delegate const *delegate) const noexcept { // We need these constraints to ensure basic thread-safety. - assert(delegate && "A delegate must not be `nullptr`."); - assert(!delegate_ && "`RunLoopObserver::setDelegate` must be called once."); + react_native_assert(delegate && "A delegate must not be `nullptr`."); + react_native_assert( + !delegate_ && "`RunLoopObserver::setDelegate` must be called once."); delegate_ = delegate; } @@ -47,7 +48,7 @@ void RunLoopObserver::activityDidChange(Activity activity) const noexcept { return; } - assert( + react_native_assert( !owner_.expired() && "`owner_` is null. The caller must `lock` the owner and check it for being not null."); diff --git a/package.json b/package.json index b3e149b7080a26..b736a49fe7b2bc 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "prettier": "prettier --write \"./**/*.{js,md,yml}\"", "format-check": "prettier --list-different \"./**/*.{js,md,yml}\"", "update-lock": "npx yarn-deduplicate", - "docker-setup-android": "docker pull reactnativecommunity/react-native-android:2.1", + "docker-setup-android": "docker pull reactnativecommunity/react-native-android:3.2", "docker-build-android": "docker build -t reactnativeci/android -f .circleci/Dockerfiles/Dockerfile.android .", "test-android-run-instrumentation": "docker run --cap-add=SYS_ADMIN -it reactnativeci/android bash .circleci/Dockerfiles/scripts/run-android-docker-instrumentation-tests.sh", "test-android-run-unit": "docker run --cap-add=SYS_ADMIN -it reactnativeci/android bash .circleci/Dockerfiles/scripts/run-android-docker-unit-tests.sh", @@ -102,10 +102,10 @@ "hermes-engine": "~0.7.0", "invariant": "^2.2.4", "jsc-android": "^245459.0.0", - "metro-babel-register": "0.65.1", - "metro-react-native-babel-transformer": "0.65.1", - "metro-runtime": "0.65.1", - "metro-source-map": "0.65.1", + "metro-babel-register": "0.65.2", + "metro-react-native-babel-transformer": "0.65.2", + "metro-runtime": "0.65.2", + "metro-source-map": "0.65.2", "nullthrows": "^1.1.1", "pretty-format": "^26.5.2", "promise": "^8.0.3", diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js index bbce51534add61..7c98c6e7f7b56f 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js @@ -80,7 +80,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/${libraryName} -LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug LOCAL_STATIC_LIBRARIES := libjsi diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap index 8f1674fad58166..6bb1b8b9a9485f 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap @@ -52,7 +52,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/complex_objects -LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug LOCAL_STATIC_LIBRARIES := libjsi @@ -118,7 +118,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/empty_native_modules -LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug LOCAL_STATIC_LIBRARIES := libjsi @@ -184,7 +184,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/native_modules_with_type_aliases -LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug LOCAL_STATIC_LIBRARIES := libjsi @@ -258,7 +258,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/real_module_example -LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug LOCAL_STATIC_LIBRARIES := libjsi @@ -324,7 +324,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/simple_native_modules -LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug LOCAL_STATIC_LIBRARIES := libjsi @@ -398,7 +398,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/two_modules_different_files -LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug LOCAL_STATIC_LIBRARIES := libjsi diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index 63b8dc52935978..ae885b01454857 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -57,7 +57,5 @@ target 'RNTesterIntegrationTests' do end post_install do |installer| - if !USE_FRAMEWORKS - flipper_post_install(installer) - end + react_native_post_install(installer) end diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index af9913d9812217..3c56904b3df43a 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -1,7 +1,6 @@ PODS: - boost-for-react-native (1.63.0) - CocoaAsyncSocket (7.6.5) - - CocoaLibEvent (1.0.0) - DoubleConversion (1.1.6) - FBLazyVector (1000.0.0) - FBReactNativeSpec (1000.0.0): @@ -11,56 +10,55 @@ PODS: - React-Core (= 1000.0.0) - React-jsi (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - - Flipper (0.54.0): - - Flipper-Folly (~> 2.2) - - Flipper-RSocket (~> 1.1) + - Flipper (0.75.1): + - Flipper-Folly (~> 2.5) + - Flipper-RSocket (~> 1.3) - Flipper-DoubleConversion (1.1.7) - - Flipper-Folly (2.3.0): + - Flipper-Folly (2.5.1): - boost-for-react-native - - CocoaLibEvent (~> 1.0) - Flipper-DoubleConversion - Flipper-Glog - - OpenSSL-Universal (= 1.0.2.20) + - libevent (~> 2.1.12) + - OpenSSL-Universal (= 1.1.180) - Flipper-Glog (0.3.6) - Flipper-PeerTalk (0.0.4) - - Flipper-RSocket (1.1.0): - - Flipper-Folly (~> 2.2) - - FlipperKit (0.54.0): - - FlipperKit/Core (= 0.54.0) - - FlipperKit/Core (0.54.0): - - Flipper (~> 0.54.0) + - Flipper-RSocket (1.3.0): + - Flipper-Folly (~> 2.5) + - FlipperKit (0.75.1): + - FlipperKit/Core (= 0.75.1) + - FlipperKit/Core (0.75.1): + - Flipper (~> 0.75.1) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - - FlipperKit/CppBridge (0.54.0): - - Flipper (~> 0.54.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.54.0): - - Flipper-Folly (~> 2.2) - - FlipperKit/FBDefines (0.54.0) - - FlipperKit/FKPortForwarding (0.54.0): + - FlipperKit/CppBridge (0.75.1): + - Flipper (~> 0.75.1) + - FlipperKit/FBCxxFollyDynamicConvert (0.75.1): + - Flipper-Folly (~> 2.5) + - FlipperKit/FBDefines (0.75.1) + - FlipperKit/FKPortForwarding (0.75.1): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitHighlightOverlay (0.54.0) - - FlipperKit/FlipperKitLayoutPlugin (0.54.0): + - FlipperKit/FlipperKitHighlightOverlay (0.75.1) + - FlipperKit/FlipperKitLayoutPlugin (0.75.1): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - YogaKit (~> 1.18) - - FlipperKit/FlipperKitLayoutTextSearchable (0.54.0) - - FlipperKit/FlipperKitNetworkPlugin (0.54.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.75.1) + - FlipperKit/FlipperKitNetworkPlugin (0.75.1): - FlipperKit/Core - - FlipperKit/FlipperKitReactPlugin (0.54.0): + - FlipperKit/FlipperKitReactPlugin (0.75.1): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.54.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.75.1): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.54.0): + - FlipperKit/SKIOSNetworkPlugin (0.75.1): - FlipperKit/Core - FlipperKit/FlipperKitNetworkPlugin - glog (0.3.5) - - OpenSSL-Universal (1.0.2.20): - - OpenSSL-Universal/Static (= 1.0.2.20) - - OpenSSL-Universal/Static (1.0.2.20) + - libevent (2.1.12) + - OpenSSL-Universal (1.1.180) - RCT-Folly (2020.01.13.00): - boost-for-react-native - DoubleConversion @@ -663,25 +661,25 @@ DEPENDENCIES: - DoubleConversion (from `../../third-party-podspecs/DoubleConversion.podspec`) - FBLazyVector (from `../../Libraries/FBLazyVector`) - FBReactNativeSpec (from `../../React/FBReactNativeSpec`) - - Flipper (~> 0.54.0) + - Flipper (~> 0.75.1) - Flipper-DoubleConversion (= 1.1.7) - - Flipper-Folly (~> 2.2) + - Flipper-Folly (~> 2.5) - Flipper-Glog (= 0.3.6) - Flipper-PeerTalk (~> 0.0.4) - - Flipper-RSocket (~> 1.1) - - FlipperKit (~> 0.54.0) - - FlipperKit/Core (~> 0.54.0) - - FlipperKit/CppBridge (~> 0.54.0) - - FlipperKit/FBCxxFollyDynamicConvert (~> 0.54.0) - - FlipperKit/FBDefines (~> 0.54.0) - - FlipperKit/FKPortForwarding (~> 0.54.0) - - FlipperKit/FlipperKitHighlightOverlay (~> 0.54.0) - - FlipperKit/FlipperKitLayoutPlugin (~> 0.54.0) - - FlipperKit/FlipperKitLayoutTextSearchable (~> 0.54.0) - - FlipperKit/FlipperKitNetworkPlugin (~> 0.54.0) - - FlipperKit/FlipperKitReactPlugin (~> 0.54.0) - - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.54.0) - - FlipperKit/SKIOSNetworkPlugin (~> 0.54.0) + - Flipper-RSocket (~> 1.3) + - FlipperKit (~> 0.75.1) + - FlipperKit/Core (~> 0.75.1) + - FlipperKit/CppBridge (~> 0.75.1) + - FlipperKit/FBCxxFollyDynamicConvert (~> 0.75.1) + - FlipperKit/FBDefines (~> 0.75.1) + - FlipperKit/FKPortForwarding (~> 0.75.1) + - FlipperKit/FlipperKitHighlightOverlay (~> 0.75.1) + - FlipperKit/FlipperKitLayoutPlugin (~> 0.75.1) + - FlipperKit/FlipperKitLayoutTextSearchable (~> 0.75.1) + - FlipperKit/FlipperKitNetworkPlugin (~> 0.75.1) + - FlipperKit/FlipperKitReactPlugin (~> 0.75.1) + - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.75.1) + - FlipperKit/SKIOSNetworkPlugin (~> 0.75.1) - glog (from `../../third-party-podspecs/glog.podspec`) - RCT-Folly (from `../../third-party-podspecs/RCT-Folly.podspec`) - RCT-Folly/Fabric (from `../../third-party-podspecs/RCT-Folly.podspec`) @@ -722,7 +720,6 @@ SPEC REPOS: trunk: - boost-for-react-native - CocoaAsyncSocket - - CocoaLibEvent - Flipper - Flipper-DoubleConversion - Flipper-Folly @@ -730,6 +727,7 @@ SPEC REPOS: - Flipper-PeerTalk - Flipper-RSocket - FlipperKit + - libevent - OpenSSL-Universal - YogaKit @@ -804,19 +802,19 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 - CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f - DoubleConversion: cde416483dac037923206447da6e1454df403714 + DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662 FBLazyVector: 91e874a8823933a268c38765a88cbd5dba1fa024 FBReactNativeSpec: 6793f00102a091fb931674853172fb22e5a2c4cf - Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365 + Flipper: d3da1aa199aad94455ae725e9f3aa43f3ec17021 Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 - Flipper-Folly: e4493b013c02d9347d5e0cb4d128680239f6c78a + Flipper-Folly: f7a3caafbd74bda4827954fd7a6e000e36355489 Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6 Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 - Flipper-RSocket: 64e7431a55835eb953b0bf984ef3b90ae9fdddd7 - FlipperKit: ab353d41aea8aae2ea6daaf813e67496642f3d7d - glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3 - OpenSSL-Universal: ff34003318d5e1163e9529b08470708e389ffcdd + Flipper-RSocket: 602921fee03edacf18f5d6f3d3594ba477f456e5 + FlipperKit: 8a20b5c5fcf9436cac58551dc049867247f64b00 + glog: 5337263514dd6f09803962437687240c5dc39aa4 + libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 + OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c RCTRequired: 047bd218d23dbe95d2a933eb5030a269d2a42929 RCTTypeSafety: c2fc670603ca48eb4c1230091eaffb422e6d0d4d @@ -832,7 +830,7 @@ SPEC CHECKSUMS: React-jsinspector: 52fe8073736a97304c9bc61a5bbae8b66ca55701 React-perflogger: e5c447a0435eb9cdd1e5cd692a48b5c5463406b0 React-RCTActionSheet: 555656ac47e1b81d986a3822e22c374523e0ed17 - React-RCTAnimation: 639d6784188ee28b3cbb5c4915f18fb63b816a46 + React-RCTAnimation: 0bb7a765e92907fb44073438b3a6752ca4ef0df1 React-RCTBlob: b0af8ae625ea63199504c9cfe09151ebeae51884 React-RCTFabric: 447f94b853788b8868157002022bcaa911f2cf00 React-RCTImage: 8626895dc6dabc11f28e3d6a9eb866b2e2c2742d @@ -844,10 +842,10 @@ SPEC CHECKSUMS: React-RCTText: 83931feaad2b470868af24bf7b943cc52a84603d React-RCTVibration: c739e240076fd7dabd90d6242d6a949297565f72 React-runtimeexecutor: d3e89935c7d4733ddf7da3dd8e0b2533adb7bca4 - ReactCommon: 293077fd73008093e681d96ae99e34e56d47160a + ReactCommon: 959d51c4ce5f5885ffd44115a38052dc45b4a489 Yoga: 69c2b21737d8220f647e61141aec8c28f7249ef2 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: 799678aa4c11e7c6d8a431a3883e94b09b8dd0f1 +PODFILE CHECKSUM: 6e910a576b7db9347c60dfc58f7852f692200116 COCOAPODS: 1.10.1 diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj index 47fb7dd64bf7a9..e59f85b3e91717 100644 --- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj +++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj @@ -77,6 +77,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 0CC3BE1A25DDB68A0033CAEB /* RNTester.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = RNTester.entitlements; path = RNTester/RNTester.entitlements; sourceTree = ""; }; 13B07F961A680F5B00A75B9A /* RNTester.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RNTester.app; sourceTree = BUILT_PRODUCTS_DIR; }; 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = RNTester/AppDelegate.h; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = RNTester/Info.plist; sourceTree = ""; }; @@ -219,6 +220,7 @@ 13B07FAE1A68108700A75B9A /* RNTester */ = { isa = PBXGroup; children = ( + 0CC3BE1A25DDB68A0033CAEB /* RNTester.entitlements */, E771AEEA22B44E3100EA1189 /* Info.plist */, 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 5C60EB1B226440DB0018C04F /* AppDelegate.mm */, @@ -406,6 +408,7 @@ 68CD48B71D2BCB2C007E06A9 /* Build JS Bundle */, 5CF0FD27207FC6EC00C13D65 /* Start Metro */, CD2B49A7F80C8171E7A5B233 /* [CP] Copy Pods Resources */, + FCBC860F39D3E385BA7C6FF7 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -665,6 +668,23 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + FCBC860F39D3E385BA7C6FF7 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -748,15 +768,15 @@ isa = XCBuildConfiguration; baseConfigurationReference = 98233960D1D6A1977D1C7EAF /* Pods-RNTester.debug.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CODE_SIGN_ENTITLEMENTS = RNTester/RNTester.entitlements; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/RNTester/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", + "@executable_path/Frameworks", ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -781,9 +801,8 @@ isa = XCBuildConfiguration; baseConfigurationReference = 5BEC8567F3741044B6A5EFC5 /* Pods-RNTester.release.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CODE_SIGN_ENTITLEMENTS = RNTester/RNTester.entitlements; DEVELOPMENT_TEAM = ""; EXCLUDED_ARCHS = ""; INFOPLIST_FILE = "$(SRCROOT)/RNTester/Info.plist"; @@ -791,6 +810,7 @@ LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", + "@executable_path/Frameworks", ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -847,6 +867,7 @@ ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 "; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -930,6 +951,7 @@ ENABLE_BITCODE = NO; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 "; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; diff --git a/packages/rn-tester/android/app/gradle.properties b/packages/rn-tester/android/app/gradle.properties index 5c93b3bca832dc..9eea6a6e70f5db 100644 --- a/packages/rn-tester/android/app/gradle.properties +++ b/packages/rn-tester/android/app/gradle.properties @@ -10,4 +10,4 @@ android.useAndroidX=true android.enableJetifier=true # Version of flipper SDK to use with React Native -FLIPPER_VERSION=0.54.0 +FLIPPER_VERSION=0.75.1 diff --git a/packages/rn-tester/js/examples/SectionList/SectionListExamples.js b/packages/rn-tester/js/examples/SectionList/SectionListExamples.js index 6eb9eb4c2dc8ea..df68a5209f41fe 100644 --- a/packages/rn-tester/js/examples/SectionList/SectionListExamples.js +++ b/packages/rn-tester/js/examples/SectionList/SectionListExamples.js @@ -46,8 +46,16 @@ const VIEWABILITY_CONFIG = { const Item = ({item, section, separators}) => { return ( { + separators.highlight(); + }} + onPress={() => { + separators.updateProps('trailing', {hasBeenHighlighted: true}); + separators.updateProps('leading', {hasBeenHighlighted: true}); + }} + onPressOut={() => { + separators.unhighlight(); + }} style={({pressed}) => [ styles.item, { @@ -60,7 +68,18 @@ const Item = ({item, section, separators}) => { ); }; -const Separator = (defaultColor, highlightColor, text) => ({highlighted}) => { +const Separator = (defaultColor, highlightColor, isSectionSeparator) => ({ + leadingItem, + trailingItem, + highlighted, + hasBeenHighlighted, +}) => { + const text = `${ + isSectionSeparator ? 'Section ' : '' + }separator for leading ${leadingItem} and trailing ${trailingItem} has ${ + !hasBeenHighlighted ? 'not ' : '' + }been pressed`; + return ( >(); - const onTest = null; - return ( - + ); } @@ -232,7 +240,6 @@ export function SectionList_onViewableItemsChanged(): React.Node { return ( ); @@ -242,7 +249,7 @@ type Props = { exampleProps: $Shape>, onTest?: ?() => void, testLabel?: ?string, - testOutput: ?string, + testOutput?: ?string, }; const SectionListExampleWithForwardedRef = React.forwardRef( @@ -252,18 +259,20 @@ const SectionListExampleWithForwardedRef = React.forwardRef( ): React.Node { return ( - - - {props.testOutput} - - {props.onTest != null ? ( -