ionic-team / ionic-team/cordova-plugin-ionic-webview

Application Error net::ERR_INSUFFICIENT_RESOURCES (file:///android_asset/www/index.html) on app startup

Open
#156 1 comment 8 reactions 0 assignees View on GitHub
Dominant language
Objective-C
Stars
493
Forks
410
PR merge metrics
No merged PRs in 30d

Description

Hello,

I'm getting this error upon application startup since v2 of `cordova-plugin-ionic-webview` on some older Androids in about 1 of 5 startups (couldn't reproduce it on Oreo+ yet):
![img_20180824_145055698](https://user-images.githubusercontent.com/4807083/44918708-2f167500-ad2b-11e8-85fc-09cd59ea2a43.jpg)

I've debugged a litte and the root cause of the problem seems to be that the new version intercepts the initial request to the `launchUrl` in `com.ionicframework.cordova.webview.IonicWebViewEngine#onPageStarted` and tries to load the `CDV_LOCAL_SERVER` Url instead. This defeats Cordova's own protection against errors during load in `org.apache.cordova.engine.SystemWebViewClient#onPageStarted` and `org.apache.cordova.engine.SystemWebViewClient#onPageFinished` that sets and unsets the `isCurrentlyLoading` flag that is used to swallow any errors during loading process in `org.apache.cordova.engine.SystemWebViewClient#onReceivedError`.

The call sequence in our case is (sometimes):
`org.apache.cordova.engine.SystemWebViewClient#onPageStarted` with `launchUrl`
`org.apache.cordova.engine.SystemWebViewClient#onPageStarted` with `CDV_LOCAL_SERVER`
`org.apache.cordova.engine.SystemWebViewClient#onPageFinished` with `launchUrl`
(after this step the `isCurrentlyLoading` flag is set to `false`)
`org.apache.cordova.engine.SystemWebViewClient#onReceivedError` with `launchUrl`
`org.apache.cordova.engine.SystemWebViewClient#onPageFinished` with `CDV_LOCAL_SERVER`

The fun part is that the app loads fine in the background but when the OK button is clicked in the dialog, Cordova closes the app.

Cordova: 8.0.0
Cordova-Android: 6.4.0 (tried with 7.1.1, too)
cordova-plugin-ionic-webview: 2.1.0

Contributor guide

Open the contributing guide

Research direction

Start with com.ionicframework.cordova.webview.IonicWebViewEngine#onPageStarted and compare it with org.apache.cordova.engine.SystemWebViewClient#onPageStarted, #onPageFinished, and #onReceivedError. Reproduce the startup sequence on an older Android version and trace the isCurrentlyLoading flag. Done means the startup error is no longer shown and the app remains open when the load completes.

Written by the indexing model from the issue text.

Assessment

Tech stack
android
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.