Skip to content

Commit

Permalink
Fix crash when enabling Performance Monitor on iOS 13.4 (#28512)
Browse files Browse the repository at this point in the history
Summary:
This PR fixes a crash when opening the Performance Monitor on iOS 13.4.
Detailed info: #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: #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 expo#21 has been shipped and tested in Expo Client 37

Fixes #28414

Reviewed By: PeteTheHeat

Differential Revision: D20851131

Pulled By: TheSavior

fbshipit-source-id: ff96301036e8487db59f95947bbe6841fe230e1e
  • Loading branch information
IjzerenHein authored and alloy committed Apr 8, 2020
1 parent 9a00cec commit 6b6877d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions React/CoreModules/RCTPerfMonitor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b6877d

Please sign in to comment.