Skip to content

Commit 2b5938c

Browse files
RSNarafacebook-github-bot
authored andcommitted
Remove legacy validation warning infra (#53792)
Summary: Pull Request resolved: #53792 This validation infra served us well, but it's no longer needed. All the legacy architecture classes have been identified and deprecated. And in the next major release, we will simply remove them. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D82470292 fbshipit-source-id: 44b58e63b7aca4fa22ac6b891275417bf1add8d1
1 parent d389008 commit 2b5938c

File tree

9 files changed

+0
-181
lines changed

9 files changed

+0
-181
lines changed

packages/react-native/React/Base/RCTAssert.h

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -174,43 +174,3 @@ RCT_EXTERN NSString *RCTFormatStackTrace(NSArray<NSDictionary<NSString *, id> *>
174174
} while (0)
175175

176176
#endif
177-
178-
// MARK: - New Architecture Validation
179-
180-
typedef enum {
181-
RCTNotAllowedInBridgeless = 1,
182-
RCTNotAllowedInFabricWithoutLegacy = 2,
183-
RCTNotAllowedValidationDisabled = 3,
184-
} RCTNotAllowedValidation;
185-
186-
/**
187-
* // TODO: (T125626909) Only validate legacy architecture usages in Bridgeless mode, not Bridged Fabric mode
188-
*
189-
* Ensure runtime assumptions holds for the new architecture by reporting when assumptions are violated.
190-
* Note: this is work in progress.
191-
*
192-
* When level is RCTNotAllowedInFabricWithoutLegacy, validate Fabric assumptions.
193-
* i.e. Report legacy pre-Fabric call sites that should not be used while Fabric is enabled on all surfaces.
194-
*
195-
* When level is RCTNotAllowedInBridgeless, validate Fabric or Bridgeless assumptions.
196-
* i.e. Report Bridge call sites that should not be used while Bridgeless mode is enabled.
197-
*
198-
* Note: enabling this at runtime is not early enough to report issues within ObjC class +load execution.
199-
*/
200-
__attribute__((used)) RCT_EXTERN void RCTNewArchitectureSetMinValidationLevel(RCTNotAllowedValidation level);
201-
202-
// When new architecture validation reporting is enabled, trigger an assertion and crash.
203-
__attribute__((used)) RCT_EXTERN void
204-
RCTEnforceNewArchitectureValidation(RCTNotAllowedValidation type, id context, NSString *extra);
205-
// When new architecture validation reporting is enabled, trigger an error but do not crash.
206-
// When ready, switch to stricter variant above.
207-
__attribute__((used)) RCT_EXTERN void
208-
RCTErrorNewArchitectureValidation(RCTNotAllowedValidation type, id context, NSString *extra);
209-
// When new architecture validation reporting is enabled, log an message.
210-
// When ready, switch to stricter variant above.
211-
__attribute__((used)) RCT_EXTERN void
212-
RCTLogNewArchitectureValidation(RCTNotAllowedValidation type, id context, NSString *extra);
213-
// A placeholder for callsites that frequently fail validation.
214-
// When ready, switch to stricter variant above.
215-
__attribute__((used)) RCT_EXTERN void
216-
RCTNewArchitectureValidationPlaceholder(RCTNotAllowedValidation type, id context, NSString *extra);

packages/react-native/React/Base/RCTAssert.m

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -231,115 +231,3 @@ RCTFatalExceptionHandler RCTGetFatalExceptionHandler(void)
231231
{
232232
return RCTCurrentFatalExceptionHandler;
233233
}
234-
235-
// MARK: - New Architecture Validation - Enable Reporting
236-
237-
#if RCT_ONLY_NEW_ARCHITECTURE_EXPERIMENTAL_DO_NOT_USE
238-
static RCTNotAllowedValidation minValidationLevel = RCTNotAllowedInBridgeless;
239-
#else
240-
static RCTNotAllowedValidation minValidationLevel = RCTNotAllowedValidationDisabled;
241-
#endif
242-
243-
__attribute__((used)) RCT_EXTERN void RCTNewArchitectureSetMinValidationLevel(RCTNotAllowedValidation level)
244-
{
245-
#if RCT_ONLY_NEW_ARCHITECTURE_EXPERIMENTAL_DO_NOT_USE
246-
// Cannot disable the reporting in this mode.
247-
#else
248-
minValidationLevel = level;
249-
#endif
250-
}
251-
252-
// MARK: - New Architecture Validation - Private
253-
254-
static BOOL shouldEnforceValidation(RCTNotAllowedValidation type)
255-
{
256-
return type >= minValidationLevel;
257-
}
258-
259-
static NSString *stringDescribingContext(id context)
260-
{
261-
if ([context isKindOfClass:NSString.class]) {
262-
return context;
263-
} else if (context) {
264-
Class klass = [context class];
265-
if (klass) {
266-
return NSStringFromClass(klass);
267-
}
268-
}
269-
return @"uncategorized";
270-
}
271-
272-
static NSString *validationMessage(RCTNotAllowedValidation type, id context, NSString *extra)
273-
{
274-
NSString *notAllowedType;
275-
switch (type) {
276-
case RCTNotAllowedValidationDisabled:
277-
RCTAssert(0, @"RCTNotAllowedValidationDisabled not a validation type.");
278-
return nil;
279-
case RCTNotAllowedInFabricWithoutLegacy:
280-
notAllowedType = @"Fabric";
281-
break;
282-
case RCTNotAllowedInBridgeless:
283-
notAllowedType = @"Bridgeless";
284-
break;
285-
}
286-
287-
return
288-
[NSString stringWithFormat:@"[ReactNative Architecture][NotAllowedIn%@] Unexpectedly reached code path in %@. %@",
289-
notAllowedType,
290-
stringDescribingContext(context),
291-
extra ?: @""];
292-
}
293-
294-
static void
295-
newArchitectureValidationInternal(RCTLogLevel level, RCTNotAllowedValidation type, id context, NSString *extra)
296-
{
297-
if (!shouldEnforceValidation(type)) {
298-
return;
299-
}
300-
301-
NSString *msg = validationMessage(type, context, extra);
302-
if (msg) {
303-
switch (level) {
304-
case RCTLogLevelInfo:
305-
RCTLogInfo(@"%@", msg);
306-
break;
307-
case RCTLogLevelError:
308-
RCTLogError(@"%@", msg);
309-
break;
310-
case RCTLogLevelFatal:
311-
RCTAssert(0, @"%@", msg);
312-
break;
313-
default:
314-
RCTAssert(0, @"New architecture validation is only for info, error, and fatal levels.");
315-
}
316-
}
317-
}
318-
319-
// MARK: - New Architecture Validation - Public
320-
321-
void RCTEnforceNewArchitectureValidation(RCTNotAllowedValidation type, id context, NSString *extra)
322-
{
323-
newArchitectureValidationInternal(RCTLogLevelFatal, type, context, extra);
324-
}
325-
326-
void RCTErrorNewArchitectureValidation(RCTNotAllowedValidation type, id context, NSString *extra)
327-
{
328-
#if RCT_ONLY_NEW_ARCHITECTURE_EXPERIMENTAL_DO_NOT_USE
329-
newArchitectureValidationInternal(RCTLogLevelFatal, type, context, extra);
330-
#else
331-
newArchitectureValidationInternal(RCTLogLevelError, type, context, extra);
332-
#endif
333-
}
334-
335-
void RCTLogNewArchitectureValidation(RCTNotAllowedValidation type, id context, NSString *extra)
336-
{
337-
newArchitectureValidationInternal(RCTLogLevelInfo, type, context, extra);
338-
}
339-
340-
void RCTNewArchitectureValidationPlaceholder(RCTNotAllowedValidation type, id context, NSString *extra)
341-
{
342-
#if RCT_ONLY_NEW_ARCHITECTURE_EXPERIMENTAL_DO_NOT_USE
343-
newArchitectureValidationInternal(RCTLogLevelInfo, type, context, extra);
344-
#endif
345-
}

packages/react-native/React/Base/RCTBridge.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ - (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)delegate
386386
#endif
387387

388388
if (self = [super init]) {
389-
RCTEnforceNewArchitectureValidation(RCTNotAllowedInBridgeless, self, nil);
390389
_delegate = delegate;
391390
_bundleURL = bundleURL;
392391
_moduleProvider = block;

packages/react-native/React/Base/RCTDefines.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,3 @@
175175
@throw _RCTNotImplementedException(_cmd, [self class]); \
176176
} \
177177
_Pragma("clang diagnostic pop")
178-
179-
/**
180-
* Controls for activating the new architecture without the legacy system.
181-
* Note: this is work in progress.
182-
*/
183-
#ifdef REACT_NATIVE_FORCE_NEW_ARCHITECTURE_EXPERIMENTAL_DO_NOT_USE
184-
#define RCT_ONLY_NEW_ARCHITECTURE_EXPERIMENTAL_DO_NOT_USE 1
185-
#else
186-
#define RCT_ONLY_NEW_ARCHITECTURE_EXPERIMENTAL_DO_NOT_USE 0
187-
#endif

packages/react-native/React/Base/Surface/RCTSurface.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
6767
moduleName:(NSString *)moduleName
6868
initialProperties:(NSDictionary *)initialProperties
6969
{
70-
RCTErrorNewArchitectureValidation(RCTNotAllowedInFabricWithoutLegacy, @"RCTSurface", nil);
7170
RCTAssert(bridge.valid, @"Valid bridge is required to instantiate `RCTSurface`.");
7271

7372
if (self = [super init]) {

packages/react-native/React/CoreModules/RCTLogBoxView.mm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ - (void)createRootViewController:(UIView *)view
3838
#ifndef RCT_REMOVE_LEGACY_ARCH
3939
- (instancetype)initWithWindow:(UIWindow *)window bridge:(RCTBridge *)bridge
4040
{
41-
RCTErrorNewArchitectureValidation(RCTNotAllowedInFabricWithoutLegacy, @"RCTLogBoxView", nil);
42-
4341
self = [super initWithWindowScene:window.windowScene];
4442

4543
self.windowLevel = UIWindowLevelStatusBar - 1;

packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,6 @@ - (void)_registerComponentIfPossible:(const std::string &)name
152152
// Fallback 3: Try to use Paper Interop.
153153
// TODO(T174674274): Implement lazy loading of legacy view managers in the new architecture.
154154
if (RCTFabricInteropLayerEnabled() && [RCTLegacyViewManagerInteropComponentView isSupported:componentNameString]) {
155-
RCTLogNewArchitectureValidation(
156-
RCTNotAllowedInBridgeless,
157-
self,
158-
[NSString
159-
stringWithFormat:
160-
@"Legacy ViewManagers should be migrated to Fabric ComponentViews in the new architecture to reduce risk. Component using interop layer: %@",
161-
componentNameString]);
162-
163155
auto flavor = std::make_shared<const std::string>(name);
164156
auto componentName = ComponentName{flavor->c_str()};
165157
auto componentHandle = reinterpret_cast<ComponentHandle>(componentName);

packages/react-native/React/Modules/RCTUIManager.mm

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,6 @@ - (NSMapTable *)nativeIDRegistry
246246

247247
- (void)setBridge:(RCTBridge *)bridge
248248
{
249-
RCTEnforceNewArchitectureValidation(
250-
RCTNotAllowedInBridgeless, self, @"RCTUIManager must not be initialized for the new architecture");
251-
252249
RCTAssert(_bridge == nil, @"Should not re-use same UIManager instance");
253250
_bridge = bridge;
254251

@@ -1624,8 +1621,6 @@ - (void)rootViewForReactTag:(NSNumber *)reactTag withCompletion:(void (^)(UIView
16241621

16251622
+ (UIView *)JSResponder
16261623
{
1627-
RCTErrorNewArchitectureValidation(
1628-
RCTNotAllowedInFabricWithoutLegacy, @"RCTUIManager", @"Please migrate this legacy surface to Fabric.");
16291624
return _jsResponder;
16301625
}
16311626

packages/react-native/React/Views/RCTViewManager.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ - (dispatch_queue_t)methodQueue
137137

138138
- (void)setBridge:(RCTBridge *)bridge
139139
{
140-
RCTErrorNewArchitectureValidation(
141-
RCTNotAllowedInBridgeless, self, @"RCTViewManager must not be initialized for the new architecture");
142140
_bridge = bridge;
143141
}
144142

0 commit comments

Comments
 (0)