Fix: Add api to disable New Architecture validation reporting, and reset reporting when FBReactModule is recreated

Summary:
Changelog: [iOS][Internal] Add api to disable New  validation reporting

Previously `RCTNewArchitectureValidationSetEnabled` was not set to false once it was set to true when a use is in app-wide Bridgeless mode.
This resulted it being in an incorrect state if a user:
1) Opens RN while in app-wide Bridgeless enabled
2) Logout
3) Re-login as another user without killing the app.

The fix is to set `RCTNewArchitectureValidationSetEnabled(RCTNotAllowedValidationDisabled)` in FBReactModule initialization.

Reviewed By: RSNara

Differential Revision: D35233335

fbshipit-source-id: 82a2c2ed030df5d68267a40b14322e652eb29e96
This commit is contained in:
Paige Sun 2022-03-29 18:40:19 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 37e5fa3a6c
Коммит 6031e4ab62
2 изменённых файлов: 9 добавлений и 3 удалений

Просмотреть файл

@ -173,6 +173,7 @@ RCT_EXTERN NSString *RCTFormatStackTrace(NSArray<NSDictionary<NSString *, id> *>
// MARK: - New Architecture Validation
typedef enum {
RCTNotAllowedValidationDisabled = 0,
RCTNotAllowedInAppWideFabric = 1,
RCTNotAllowedInBridgeless = 2,
} RCTNotAllowedValidation;
@ -189,7 +190,7 @@ typedef enum {
*
* Note: enabling this at runtime is not early enough to report issues within ObjC class +load execution.
*/
__attribute__((used)) RCT_EXTERN void RCTEnableNewArchitectureValidationReporting(RCTNotAllowedValidation type);
__attribute__((used)) RCT_EXTERN void RCTNewArchitectureValidationSetEnabled(RCTNotAllowedValidation type);
// When new architecture validation reporting is enabled, trigger an assertion and crash.
__attribute__((used)) RCT_EXTERN void

Просмотреть файл

@ -236,10 +236,10 @@ RCTFatalExceptionHandler RCTGetFatalExceptionHandler(void)
#if RCT_NEW_ARCHITECTURE
static RCTNotAllowedValidation validationReportingEnabled = RCTNotAllowedInBridgeless;
#else
static RCTNotAllowedValidation validationReportingEnabled = 0;
static RCTNotAllowedValidation validationReportingEnabled = RCTNotAllowedValidationDisabled;
#endif
__attribute__((used)) RCT_EXTERN void RCTEnableNewArchitectureValidationReporting(RCTNotAllowedValidation type)
__attribute__((used)) RCT_EXTERN void RCTNewArchitectureValidationSetEnabled(RCTNotAllowedValidation type)
{
#if RCT_NEW_ARCHITECTURE
// Cannot disable the reporting in this mode.
@ -258,6 +258,8 @@ static BOOL shouldEnforceValidation(RCTNotAllowedValidation type)
validationReportingEnabled == RCTNotAllowedInAppWideFabric;
case RCTNotAllowedInBridgeless:
return validationReportingEnabled == RCTNotAllowedInBridgeless;
case RCTNotAllowedValidationDisabled:
return NO;
}
return NO;
}
@ -279,6 +281,9 @@ static NSString *validationMessage(RCTNotAllowedValidation type, id context, NSS
{
NSString *notAllowedType;
switch (type) {
case RCTNotAllowedValidationDisabled:
RCTAssert(0, @"RCTNotAllowedValidationDisabled not a validation type.");
break;
case RCTNotAllowedInAppWideFabric:
notAllowedType = @"Fabric";
break;