Skip to content

Commit

Permalink
Patch RCTFont.mm to fix crash
Browse files Browse the repository at this point in the history
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
  • Loading branch information
paullinator committed Mar 4, 2019
1 parent f9d1909 commit e06e09e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions patches/RCTFont.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- RCTFont.mm 2018-11-09 01:14:13.000000000 -0800
+++ RCTFont.new.mm 2019-03-04 00:13:43.000000000 -0800
@@ -145,12 +145,12 @@
static UIFont *cachedSystemFont(CGFloat size, RCTFontWeight weight)
{
static NSCache *fontCache;
- static std::mutex fontCacheMutex;
+ static std::mutex *fontCacheMutex = new std::mutex;

NSString *cacheKey = [NSString stringWithFormat:@"%.1f/%.2f", size, weight];
UIFont *font;
{
- std::lock_guard<std::mutex> lock(fontCacheMutex);
+ std::lock_guard<std::mutex> lock(*fontCacheMutex);
if (!fontCache) {
fontCache = [NSCache new];
}
@@ -177,7 +177,7 @@
}

{
- std::lock_guard<std::mutex> lock(fontCacheMutex);
+ std::lock_guard<std::mutex> lock(*fontCacheMutex);
[fontCache setObject:font forKey:cacheKey];
}
}
4 changes: 4 additions & 0 deletions postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,8 @@ unamestr=`uname`
if [[ "$unamestr" == 'Darwin' ]]; then
cd ios
pod install
cd ..
fi

# Apply patches
patch ./node_modules/react-native/React/Views/RCTFont.mm ./patches/RCTFont.patch

0 comments on commit e06e09e

Please sign in to comment.