react-native
react-native copied to clipboard
[iOS] [RCTTextViewManager uiManagerWillPerformMounting:] crash
Description
We are facing a crash in RCTTextViewManager uiManagerWillPerformMounting
in our iOS application. The crash happens across application without any specific steps to reproduce. I am assuming this has to do with releasing an already released object. If this is the case then is there any way we can prevent this? This has become our top crash.
Crash Exception:
Crashed: com.facebook.react.ShadowQueue
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x000000000000000c
Crash Logs:
Crashed: com.facebook.react.ShadowQueue
0 libobjc.A.dylib 0x101a8 AutoreleasePoolPage::AutoreleasePoolPage(AutoreleasePoolPage*) + 80
1 libobjc.A.dylib 0x146f4 AutoreleasePoolPage::autoreleaseFullPage(objc_object*, AutoreleasePoolPage*) + 72
2 libobjc.A.dylib 0x29618 moveTLSAutoreleaseToPool(ReturnAutoreleaseInfo) + 128
3 libobjc.A.dylib 0x29488 objc_object::rootAutorelease() + 116
4 Foundation 0x10c1c -[NSConcreteHashTable countByEnumeratingWithState:objects:count:] + 144
5 ReactNativeFramework 0x4e296c -[RCTTextViewManager uiManagerWillPerformMounting:] + 73 (RCTTextViewManager.m:73)
6 ReactNativeFramework 0x47abd8 -[RCTUIManagerObserverCoordinator uiManagerWillPerformMounting:] + 72 (RCTUIManagerObserverCoordinator.mm:72)
7 ReactNativeFramework 0x47771c -[RCTUIManager _layoutAndMount] + 1172 (RCTUIManager.m:1172)
8 ReactNativeFramework 0x435888 __32-[RCTCxxBridge batchDidComplete]_block_invoke + 1573 (RCTCxxBridge.mm:1573)
9 libdispatch.dylib 0x63850 _dispatch_call_block_and_release + 24
10 libdispatch.dylib 0x647c8 _dispatch_client_callout + 16
11 libdispatch.dylib 0x3f854 _dispatch_lane_serial_drain$VARIANT$armv81 + 604
12 libdispatch.dylib 0x402e4 _dispatch_lane_invoke$VARIANT$armv81 + 380
13 libdispatch.dylib 0x4a000 _dispatch_workloop_worker_thread + 612
14 libsystem_pthread.dylib 0x1b50 _pthread_wqthread + 284
15 libsystem_pthread.dylib 0x167c start_wqthread + 8
Version
0.69.1
Output of npx react-native info
System: OS: macOS 12.6 CPU: (10) arm64 Apple M1 Max Memory: 95.41 MB / 32.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.19.0 - ~/.nvm/versions/node/v16.19.0/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 8.19.3 - ~/.nvm/versions/node/v16.19.0/bin/npm Watchman: Not Found Managers: CocoaPods: 1.11.3 - /Users/kunal.chavhan/.rvm/gems/ruby-2.7.5/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: Not Found IDEs: Android Studio: Dolphin 2021.3.1 Patch 1 Dolphin 2021.3.1 Patch 1 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild Languages: Java: 11.0.11 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: Not Found react-native: Not Found react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
We are unable to reproduce this crash, above logs are shared from firebase.
Snack, code example, screenshot, or link to a repository
This is the way we are using Text
in our code base. The crash is not reproducible at our end but we are seeing a very high volume of crashes in firebase.
export const TextImpl = (props: TextProps) => {
const fontWeight = props.fontWeight || FontWeight.Regular
const {
i18n: {language},
} = useTranslation()
const font = getFontFamilyStyles(props.locale ?? (language as Lang))
return (
/* When ellipsized mode is used having space in string will cause the
string to break at those spaces and this causes issues. So non breaking
Space is used instead. */
<Text
{...props}
allowFontScaling={false}
style={[
!props.inheritColor && styles.textColor,
props.style,
font.text,
fontWeight === FontWeight.Bold && font.weightBold,
fontWeight === FontWeight.Medium && font.weightMedium,
fontWeight === FontWeight.Regular && font.weightRegular,
]}>
{props?.numberOfLines === 1 &&
(props.ellipsizeMode ? props.ellipsizeMode === 'tail' : true)
? Array.isArray(props.children)
? props.children?.map((child) =>
typeof child === 'string'
? child.replace(RegExp(' ', 'g'), '\u00A0')
: child,
)
: props.children?.toString().replace(RegExp(' ', 'g'), '\u00A0')
: props.children}
</Text>
)
}
We are having the same problem. 100k users of us has been crashed. Just only happened from iOS 15
0 libobjc.A.dylib 0x3309adc0c objc_loadWeakRetained
1 libobjc.A.dylib 0x3309b1084 [inlined] objc_loadWeak
2 libobjc.A.dylib 0x3309b1084 objc_loadWeak
3 Foundation 0x3046a4738 <redacted>
4 RCTText 0x10530af68 -[RCTTextViewManager uiManagerWillPerformMounting:] (RCTTextViewManager.m:73)
5 React 0x10569dd90 -[RCTUIManagerObserverCoordinator uiManagerWillPerformMounting:] (RCTUIManagerObserverCoordinator.mm:70)
6 React 0x10569b1a8 -[RCTUIManager _layoutAndMount] (RCTUIManager.m:1161)
7 React 0x10565f32c __32-[RCTCxxBridge batchDidComplete]_block_invoke (RCTCxxBridge.mm:1504)
8 libdispatch.dylib 0x3012a3094 <redacted>
9 libdispatch.dylib 0x3012a4094 <redacted>
10 libdispatch.dylib 0x30124a73c <redacted>
11 libdispatch.dylib 0x30124b1f4 <redacted>
12 libdispatch.dylib 0x301254ec8 <redacted>
13 libsystem_pthread.dylib 0x3b804fe10 _pthread_wqthread
I see the problem fixes in this PR https://github.com/facebook/react-native/pull/36099/commits/118bd73978d6fbbcd70c8b38de5f4d02b1ee7efa
@mr-dangvanhien Thank you replying. Does this fixes the issue? Also any idea when this change will go live?
@mr-dangvanhien The changes in above commit will not solve the problem as mentioned here.
We are also facing this issue @kunal-d11 have you been able to fix the issue?
@chrisdelaney10 We have not figured out a fix yet. Any help here would be appreciated.
@kunal-d11 are you using react-navigation
and if so what version?
@chrisdelaney10 yes v6.
Any suggestions? I'm facing the same issue on all devices running 1OS 16
We are also facing a large number of crashes due to this ERROR.
Having this crash in production?
@lucaswitch yeah it only happens in production mode. We are getting tons of crash reports from users
In our case this was happening when app memory is critically low, the reason for low memory was due to react-query making infinite queries and using lot of memory. After fixing this and couple of other memory leak fixes, we are not seeing this crash now.
Hi @kunal-d11 Could you please help how did you resolve this crash wrt to react-query?
This happens on 0.73.2 pretty consistently when i use bundled react-native modal Here is my stacktrace:
Can anyone help us with this?
@lucaswitch in our case sudden memory spikes was causing this crash, we were able to reproduce this crash by adding intentional memory spikes, can you do the same and try to reproduce it?
I was able to solve this issue rewriting some modals logic.
@lucaswitch , can you provide detail how you wrote modal logic. Is this related to react-native-modal or how we show alerts in React native.
Experiencing the same issue after app goes over 1GB of used memory