Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back out "Update useNativeViewConfigsInBridgelessMode" #43883

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Back out "Update useNativeViewConfigsInBridgelessMode" (#43883)
Summary:
Pull Request resolved: #43883

Changelog: [Internal]

Backing out original diff `D55705805` to fix CircleCI Dynamic library test failure

Reviewed By: philIip

Differential Revision: D55773581
  • Loading branch information
realsoelynn authored and facebook-github-bot committed Apr 5, 2024
commit 6a5269a2151e9353bc9e3497e3889d5524a07212
11 changes: 1 addition & 10 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ - (RCTRootViewFactory *)createRCTRootViewFactory

class RCTAppDelegateBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults {
public:
RCTAppDelegateBridgelessFeatureFlags(bool fabricEnabled) : _fabricEnabled(fabricEnabled) {}
bool useModernRuntimeScheduler() override
{
return true;
Expand All @@ -311,20 +310,12 @@ bool batchRenderingUpdatesInEventLoop() override
{
return true;
}
bool useNativeViewConfigsInBridgelessMode() override
{
return _fabricEnabled;
}

private:
bool _fabricEnabled;
};

- (void)_setUpFeatureFlags
{
if ([self bridgelessEnabled]) {
facebook::react::ReactNativeFeatureFlags::override(
std::make_unique<RCTAppDelegateBridgelessFeatureFlags>(self.fabricEnabled));
facebook::react::ReactNativeFeatureFlags::override(std::make_unique<RCTAppDelegateBridgelessFeatureFlags>());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,12 @@ - (UIView *)viewWithModuleName:(NSString *)moduleName
initialProperties:(NSDictionary *)initialProperties
launchOptions:(NSDictionary *)launchOptions
{
NSDictionary *initProps = updateInitialProps(initialProperties, _configuration.fabricEnabled);
NSDictionary *initProps = updateInitialProps(initialProperties, self->_configuration.fabricEnabled);

if (self->_configuration.bridgelessEnabled) {
// Enable native view config interop only if both bridgeless mode and Fabric is enabled.
RCTSetUseNativeViewConfigsInBridgelessMode(self->_configuration.fabricEnabled);

if (_configuration.bridgelessEnabled) {
// Enable TurboModule interop by default in Bridgeless mode
RCTEnableTurboModuleInterop(YES);
RCTEnableTurboModuleInteropBridgeProxy(YES);
Expand All @@ -135,8 +138,8 @@ - (UIView *)viewWithModuleName:(NSString *)moduleName
[self createBridgeIfNeeded:launchOptions];
[self createBridgeAdapterIfNeeded];

if (_configuration.createRootViewWithBridge != nil) {
return _configuration.createRootViewWithBridge(self.bridge, moduleName, initProps);
if (self->_configuration.createRootViewWithBridge != nil) {
return self->_configuration.createRootViewWithBridge(self.bridge, moduleName, initProps);
}

return [self createRootViewWithBridge:self.bridge moduleName:moduleName initProps:initProps];
Expand Down
15 changes: 15 additions & 0 deletions packages/react-native/React/Base/RCTConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,18 @@ void RCTSetMemoryPressureUnloadLevel(int value)
{
RCTMemoryPressureUnloadLevel = value;
}

/*
* Use native view configs in bridgeless mode
*/
static BOOL RCTUseNativeViewConfigsInBridgelessMode = NO;

BOOL RCTGetUseNativeViewConfigsInBridgelessMode(void)
{
return RCTUseNativeViewConfigsInBridgelessMode;
}

void RCTSetUseNativeViewConfigsInBridgelessMode(BOOL value)
{
RCTUseNativeViewConfigsInBridgelessMode = value;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#import <AVFoundation/AVFoundation.h>
#import <React/RCTSurfacePresenterStub.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>

#import "RCTAssert.h"
#import "RCTBridge+Private.h"
Expand Down Expand Up @@ -1151,10 +1150,10 @@ - (void)flushUIBlocksWithCompletion:(void (^)(void))completion
return;
}

__weak __typeof(self) weakSelf = self;
__weak typeof(self) weakSelf = self;

void (^mountingBlock)(void) = ^{
__typeof(self) strongSelf = weakSelf;
typeof(self) strongSelf = weakSelf;

@try {
for (RCTViewManagerUIBlock block in previousPendingUIBlocks) {
Expand Down Expand Up @@ -1453,7 +1452,7 @@ static void RCTMeasureLayout(RCTShadowView *view, RCTShadowView *ancestor, RCTRe
// lazifyViewManagerConfig function in JS. This fuction uses NativeModules global object that is not available in the
// New Architecture. To make native view configs work in the New Architecture we will populate these properties in
// native.
if (facebook::react::ReactNativeFeatureFlags::useNativeViewConfigsInBridgelessMode()) {
if (RCTGetUseNativeViewConfigsInBridgelessMode()) {
moduleConstants[@"Commands"] = viewConfig[@"Commands"];
moduleConstants[@"Constants"] = viewConfig[@"Constants"];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#import "RCTComponentData.h"

#import <objc/message.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>

#import "RCTBridge.h"
#import "RCTBridgeModule.h"
Expand Down Expand Up @@ -281,9 +280,9 @@ - (RCTPropBlock)createPropBlock:(NSString *)name isShadowView:(BOOL)isShadowView
case _value: { \
__block BOOL setDefaultValue = NO; \
__block _type defaultValue; \
_type (*convert)(id, SEL, id) = (__typeof(convert))objc_msgSend; \
_type (*get)(id, SEL) = (__typeof(get))objc_msgSend; \
void (*set)(id, SEL, _type) = (__typeof(set))objc_msgSend; \
_type (*convert)(id, SEL, id) = (typeof(convert))objc_msgSend; \
_type (*get)(id, SEL) = (typeof(get))objc_msgSend; \
void (*set)(id, SEL, _type) = (typeof(set))objc_msgSend; \
setterBlock = ^(id target, id json) { \
if (json) { \
if (!setDefaultValue && target) { \
Expand Down Expand Up @@ -502,7 +501,7 @@ - (void)setProps:(NSDictionary<NSString *, id> *)props forView:(id<RCTComponent>
@"baseModuleName" : superClass == [NSObject class] ? (id)kCFNull : RCTViewManagerModuleNameForClass(superClass),
}];

if (facebook::react::ReactNativeFeatureFlags::useNativeViewConfigsInBridgelessMode()) {
if (RCTGetUseNativeViewConfigsInBridgelessMode()) {
result[@"Commands"] = [self commandsForViewMangerClass:managerClass methods:methods methodCount:count];
result[@"Constants"] = [self constantsForViewMangerClass:managerClass];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#import <cxxreact/ReactMarker.h>
#import <jsinspector-modern/ReactCdp.h>
#import <jsireact/JSIExecutor.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>
#import <react/runtime/BridgelessJSCallInvoker.h>
#import <react/utils/ContextContainer.h>
#import <react/utils/ManagedObjectWrapper.h>
Expand Down Expand Up @@ -350,7 +349,7 @@ - (void)_start
});
RCTInstallNativeComponentRegistryBinding(runtime);

if (ReactNativeFeatureFlags::useNativeViewConfigsInBridgelessMode()) {
if (RCTGetUseNativeViewConfigsInBridgelessMode()) {
installLegacyUIManagerConstantsProviderBinding(runtime);
}

Expand Down
Loading