From 2a669b9aa26d11a18cffe632a9e7b4cc82c188cd Mon Sep 17 00:00:00 2001 From: Henry Heino Date: Mon, 23 Dec 2024 11:11:00 -0800 Subject: [PATCH] Refactoring, logging --- .../app-mobile/components/ExtendedWebView/index.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/app-mobile/components/ExtendedWebView/index.tsx b/packages/app-mobile/components/ExtendedWebView/index.tsx index 5c5d26f78..7654f0031 100644 --- a/packages/app-mobile/components/ExtendedWebView/index.tsx +++ b/packages/app-mobile/components/ExtendedWebView/index.tsx @@ -88,11 +88,10 @@ const ExtendedWebView = (props: Props, ref: Ref) => { }, [props.hasPluginScripts]); const [reloadCounter, setReloadCounter] = useState(0); - const refreshWebView = useCallback(() => { - // Reload the WebView after a brief delay. See https://github.com/react-native-webview/react-native-webview/issues/3524 - shim.setTimeout(() => { - setReloadCounter(counter => counter + 1); - }, 150); + const refreshWebViewAfterCrash = useCallback(() => { + // Reload the WebView on crash. See https://github.com/react-native-webview/react-native-webview/issues/3524 + logger.warn('Content process lost. Reloading the webview...'); + setReloadCounter(counter => counter + 1); }, []); // - `setSupportMultipleWindows` must be `true` for security reasons: @@ -132,8 +131,8 @@ const ExtendedWebView = (props: Props, ref: Ref) => { onMessage={props.onMessage} onError={props.onError ?? onError} onLoadEnd={props.onLoadEnd} - onContentProcessDidTerminate={refreshWebView} - onRenderProcessGone={refreshWebView} + onContentProcessDidTerminate={refreshWebViewAfterCrash} + onRenderProcessGone={refreshWebViewAfterCrash} decelerationRate='normal' /> );