Closed tragicmj closed 2 years ago
I think its related to this https://github.com/react-native-webview/react-native-webview/issues/811
Try setting androidHardwareAccelerationDisabled this seems to work for me
I tried the androidHardwareAcceleration to true solution didn't work form me. what worked for me is: ` const style = 'body { opacity: 0.99; }';
<Signature . . . webStyle={style} /> `
Having androids occasionally crash when navigating away after signature is captured on "react-native": "0.70.5", react-native-signature-canvas": "^4.5.0", "react-native-webview": "11.23.1"
None of the above solutions worked for me but made use of the info from here https://github.com/react-native-webview/react-native-webview/issues/811 to learn that this is caused by navigation happening while the webview is still mounted, so came up with a solution that navigates away only when the signature view is unmounted.
/**
* Handle an issue of crashing on android when navigating away from the screen while signature webview is still mounted
*/
// this ref keeps track of if the signature view is mounted, needs to be useState rather than useRef so we can trigger useEffect
const [ref, setRef] = React.useState<SafeAreaView | null>(null);
const [isFinishedSignature, setIsFinishedSignature] = useState(false);
React.useEffect(() => {
// We need to make sure when the signature is uploaded, we unmount the signature view first then navigate back.
// Android devices crash occasionally if we navigate away from the screen while the signature view is mounted.
// There will be delay isFinishedSignature is true and ref being null, so also check ref is gone
if (isFinishedSignature && !ref) {
navigation.goBack();
}
}, [ref, isFinishedSignature]);
{!isFinishedSignature && (
<SafeAreaView
style={{
flex: 1,
}}
ref={setRef}
>
<Signature
handleUpload={handleConfirm}
isLoadingUpload={isLoadingUpload}
/>
</SafeAreaView>
)}
I think this issue has come back with Android 13
<SignatureScreen ref={signatureRef} onOK={this.handleOK} onEnd={this.handleEnd} androidHardwareAccelerationDisabled={true} onBegin={async () => {await this.setState({isScrollEnabled: false})}} webStyle={
.m-signature-pad--footer { display: none; }} />
Below are the crash logs Thread 0 Crashed: 0 libhwui.so 0x7dfea2d724 + 541142996772
1 libhwui.so 0x7dfeacf508 SkDrawable::draw
2 libhwui.so 0x7dfed8b480 + 541146526848
3 libhwui.so 0x7dfea09e2c + 541142851116
4 libhwui.so 0x7dfe9f0074 + 541142745204
5 libhwui.so 0x7dfea0c9d0 + 541142862288
6 libhwui.so 0x7dfea09e2c + 541142851116
7 libhwui.so 0x7dfe9f0074 + 541142745204
8 libhwui.so 0x7dfea0c9d0 + 541142862288
9 libhwui.so 0x7dfea09e2c + 541142851116
10 libhwui.so 0x7dfe9f0074 + 541142745204
11 libhwui.so 0x7dfea0c9d0 + 541142862288
12 libhwui.so 0x7dfea09e2c + 541142851116
13 libhwui.so 0x7dfe9f0074 + 541142745204
14 libhwui.so 0x7dfea0c9d0 + 541142862288
15 libhwui.so 0x7dfea09e2c + 541142851116
16 libhwui.so 0x7dfe9f0074 + 541142745204
17 libhwui.so 0x7dfea0c9d0 + 541142862288
18 libhwui.so 0x7dfea09e2c + 541142851116
19 libhwui.so 0x7dfe9f0074 + 541142745204
20 libhwui.so 0x7dfea0c9d0 + 541142862288
21 libhwui.so 0x7dfea09e2c + 541142851116
22 libhwui.so 0x7dfe9f0074 + 541142745204
23 libhwui.so 0x7dfea3392c + 541143021868
24 libhwui.so 0x7dfea35008 + 541143027720
25 libhwui.so 0x7dfea320e0 + 541143015648
26 libhwui.so 0x7dfea3b67c + 541143053948
27 libhwui.so 0x7dfea3dd50 + 541143063888
28 libhwui.so 0x7dfea2af8c + 541142986636
29 libhwui.so 0x7dfea4f5fc + 541143135740
30 libutils.so 0x7e00fb54cc android::Thread::_threadLoop
31 libutils.so 0x7e00fb4d90 + 541182348688
32 libc.so 0x7e009f4084 __pthread_start
33 libc.so 0x7e00994404 __start_thread
The app is crashing on selected android devices only for example One Plus 8, the android version in that is 11, but it is working fine on other Android 11 devices. "react-native": "0.66.1", "react-native-signature-canvas": "^4.3.0"