4

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

Steffen Christensen
  • 673
  • 1
  • 6
  • 15
  • Check the URL which is trying to load... Try to load this URL in your regular browser.. The webview which you are opening might try to redirect user to this particular link which is not available.. – Sriraman Jun 24 '19 at 13:08
  • @Sriraman Thank you for your comment! Unfortunately we have already tried that. In fact, the url is a company url - so we know that the site is not trying to do anything clever. – Steffen Christensen Jun 24 '19 at 15:03

1 Answers1

2

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.

  • If you have a serviceworker installed, I've found the fix suggested in comment 49 and [comment 51](https://bugs.chromium.org/p/chromium/issues/detail?id=977784#c51) is a better fix because it won't affect working versions or actual serviceworker usage! – Rowan Jun 26 '19 at 16:49