Steffen Christensen
Steffen Christensen

Reputation: 683

React-native-webview: net::ERR_FAILED

Bug description: The first time I open my app the website loads correctly in the WebView. Then I go to the homescreen and after a while I return to the app and gets the following error:

Website not available
The website at https://www.example.com?param=value could not be loaded because:
net::ERR_FAILED

Has anyone seen this error before?

Here is some logs from Android Studio that may or my not be related/useful.

2019-06-24 10:59:11.233 16101-16166/? W/cr_ChildProcLH: Create a new ChildConnectionAllocator with package name = com.android.chrome, sandboxed = true
2019-06-24 10:59:11.237 16101-16101/? I/cr_BrowserStartup: Initializing chromium process, singleProcess=false
2019-06-24 10:59:11.239 16101-16101/? W/ResourceType: Failure getting entry for 0x7f130537 (t=18 e=1335) (error -2147483647)

2019-06-24 10:59:11.241 16169-16169/? E//system/bin/webview_zygote32: failed to make and chown /acct/uid_99051: Permission denied
2019-06-24 10:59:11.241 16169-16169/? E/Zygote: createProcessGroup(99051, 0) failed: Permission denied

2019-06-24 10:59:11.244 16169-16169/? W//system/bin/webview_zygote32: Using default instruction set features for ARM CPU variant (cortex-a9) using conservative defaults
2019-06-24 10:59:11.248 1700-6616/? I/ActivityManager: Start proc 16169:com.android.chrome:sandboxed_process0/u0i51 for webview_service dk.MYAPPNAME.app/org.chromium.content.app.SandboxedProcessService0
2019-06-24 10:59:11.264 1991-1991/? I/chatty: uid=10016(u0_a16) com.android.systemui identical 1 line
2019-06-24 10:59:11.265 16169-16169/? I/SamplingProfilerIntegration: Profiling disabled.
2019-06-24 10:59:11.289 16197-16197/? E/asset: setgid: Operation not permitted

To Reproduce: I have only been able to reproduce this error in release - not in debug. This error happens after loading the app the first time, then leaving it and return to the app after a few hours. Maybe it is related to cache.

The problem persist when I force quit the app. If I reinstall the app it is working for a while.

Expected behavior: Website should fully load.

Screenshots/Videos: the error

Environment: - OS: Android (Huawei P20 Pro and multiple other Android phones) - OS version: Android 8 - react-native version: 59.3 - react-native-webview version: 5.6.2

Upvotes: 4

Views: 6955

Answers (1)

Christian B
Christian B

Reputation: 21

I found a fix for this issue!

It looks like a broken service worker stalled the website. I solved it by using the injectedJavascript prop in my WebView to inject the following lines of code:

navigator.serviceWorker.getRegistrations().then(function(registrations) {
   for (let registration of registrations) {
       registration.unregister();
   }
});

It is a bug in Google Chrome 75.

Upvotes: 2

Related Questions