From e06e09e626d25dfd8605164fd3d586ee91bbcd11 Mon Sep 17 00:00:00 2001 From: Paul Puey Date: Mon, 4 Mar 2019 01:32:45 -0800 Subject: [PATCH] Patch RCTFont.mm to fix crash This commit implements the following PR as a patch to RCTFont.mm. https://github.com/facebook/react-native/pull/22607 This is an attempt at fixing a high count Bugsnag reported crash which has a profile similar to https://github.com/facebook/react-native/issues/13588 --- patches/RCTFont.patch | 26 ++++++++++++++++++++++++++ postinstall.sh | 4 ++++ 2 files changed, 30 insertions(+) create mode 100644 patches/RCTFont.patch diff --git a/patches/RCTFont.patch b/patches/RCTFont.patch new file mode 100644 index 00000000000..45ead4e0333 --- /dev/null +++ b/patches/RCTFont.patch @@ -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 lock(fontCacheMutex); ++ std::lock_guard lock(*fontCacheMutex); + if (!fontCache) { + fontCache = [NSCache new]; + } +@@ -177,7 +177,7 @@ + } + + { +- std::lock_guard lock(fontCacheMutex); ++ std::lock_guard lock(*fontCacheMutex); + [fontCache setObject:font forKey:cacheKey]; + } + } diff --git a/postinstall.sh b/postinstall.sh index b3c1b9876ad..267869d331b 100755 --- a/postinstall.sh +++ b/postinstall.sh @@ -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