Skip to content

Commit e06e09e

Browse files
committed
Patch RCTFont.mm to fix crash
This commit implements the following PR as a patch to RCTFont.mm. facebook/react-native#22607 This is an attempt at fixing a high count Bugsnag reported crash which has a profile similar to facebook/react-native#13588
1 parent f9d1909 commit e06e09e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Diff for: patches/RCTFont.patch

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--- RCTFont.mm 2018-11-09 01:14:13.000000000 -0800
2+
+++ RCTFont.new.mm 2019-03-04 00:13:43.000000000 -0800
3+
@@ -145,12 +145,12 @@
4+
static UIFont *cachedSystemFont(CGFloat size, RCTFontWeight weight)
5+
{
6+
static NSCache *fontCache;
7+
- static std::mutex fontCacheMutex;
8+
+ static std::mutex *fontCacheMutex = new std::mutex;
9+
10+
NSString *cacheKey = [NSString stringWithFormat:@"%.1f/%.2f", size, weight];
11+
UIFont *font;
12+
{
13+
- std::lock_guard<std::mutex> lock(fontCacheMutex);
14+
+ std::lock_guard<std::mutex> lock(*fontCacheMutex);
15+
if (!fontCache) {
16+
fontCache = [NSCache new];
17+
}
18+
@@ -177,7 +177,7 @@
19+
}
20+
21+
{
22+
- std::lock_guard<std::mutex> lock(fontCacheMutex);
23+
+ std::lock_guard<std::mutex> lock(*fontCacheMutex);
24+
[fontCache setObject:font forKey:cacheKey];
25+
}
26+
}

Diff for: postinstall.sh

+4
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,8 @@ unamestr=`uname`
9494
if [[ "$unamestr" == 'Darwin' ]]; then
9595
cd ios
9696
pod install
97+
cd ..
9798
fi
99+
100+
# Apply patches
101+
patch ./node_modules/react-native/React/Views/RCTFont.mm ./patches/RCTFont.patch

0 commit comments

Comments
 (0)