Fix crash when enabling Performance Monitor on iOS 13.4 (#28512)

Summary:
This PR fixes a crash when opening the Performance Monitor on iOS 13.4.
Detailed info: https://github.com/facebook/react-native/issues/28414

## Changelog

`[iOS] [Fixed] - Fix crash when enabling Performance Monitor on iOS 13.4`

## How

This PR prevents the JavaScriptCore option from being set altogether.
This ensures that the performance monitor keeps working, but on iOS 13.4 and higher, it will no longer crash trying to show the GC usage.
Pull Request resolved: https://github.com/facebook/react-native/pull/28512

Test Plan:
Tested on iOS 13.4 (simulator):

![image](https://user-images.githubusercontent.com/6184593/77903803-c6370c00-7283-11ea-8b71-b6b6546c82f6.png)

Tested on iOS 13.1 (simulator)

![image](https://user-images.githubusercontent.com/6184593/77903499-41e48900-7283-11ea-9d14-83f67a3b7b77.png)

- Verified that the `setOption` was called, but the Performance Monitor didn't show any GC usage regardless.
- Identical PR https://github.com/expo/react-native/pull/21 has been shipped and tested in Expo Client 37

Fixes https://github.com/facebook/react-native/issues/28414

Reviewed By: PeteTheHeat

Differential Revision: D20851131

Pulled By: TheSavior

fbshipit-source-id: ff96301036e8487db59f95947bbe6841fe230e1e
This commit is contained in:
Hein Rutjes 2020-04-03 20:42:24 -07:00 коммит произвёл Facebook GitHub Bot
Родитель e3b7520174
Коммит e2c417f7cf
1 изменённых файлов: 8 добавлений и 0 удалений

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

@ -44,6 +44,14 @@ static BOOL RCTJSCSetOption(const char *option)
static RCTJSCSetOptionType setOption;
static dispatch_once_t onceToken;
// As of iOS 13.4, it is no longer possible to change the JavaScriptCore
// options at runtime. The options are protected and will cause an
// exception when you try to change them after the VM has been initialized.
// https://github.com/facebook/react-native/issues/28414
if (@available(iOS 13.4, *)) {
return NO;
}
dispatch_once(&onceToken, ^{
/**
* JSC private C++ static method to toggle options at runtime