ionic-team / cordova-plugin-ionic-webview

Web View plugin for Cordova, specialized for Ionic apps.
Apache License 2.0
484 stars 391 forks source link

Android app stuck on white screen after reload #315

Open iyashsoni opened 5 years ago

iyashsoni commented 5 years ago

Hello all, I am trying an Ionic 4 app with "cordova-plugin-ionic-webview": "4.0.0", and I am facing the blank white screen issue on Android Platform only.

Now the scenario is, The app starts and we make a loadUrl call to CordovaActivity with this parameter file:///android_asset/www/index.html This works fine.

But then, we download some web resources and put into path /data/user/0/io.ionic.starter/no_backup/www/ Next, we reload the app and try to load the new file with URL file:///data/user/0/io.ionic.starter/no_backup/www/index.html

Here is when we hit the blank white screen. Any help is appreciated. I have verified that the file actually exists at the expected path.

Thanks.

ionic-info:

Ionic:

   ionic (Ionic CLI)             : 4.10.3 (/Users/yashsoni/.npm-global/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.1
   @angular-devkit/build-angular : 0.12.4
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.2.4
   @ionic/angular-toolkit        : 1.4.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.0, (and 7 other plugins)

System:

   Android SDK Tools : 26.1.1 (/Users/yashsoni/Library/Android/sdk)
   ios-deploy        : 1.9.4
   NodeJS            : v8.11.1 (/usr/local/bin/node)
   npm               : 6.6.0
   OS                : macOS Mojave
   Xcode             : Xcode 10.1 Build version 10B61

cordova plugin ls:

cordova-plugin-device 2.0.2 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-globalization 1.11.0 "Globalization"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.0.0 "cordova-plugin-ionic-webview"
cordova-plugin-okhttp 2.0.0 "OkHttp"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
arimus commented 5 years ago

FYI, ran into this a couple days ago. Looks like it is related to the way the routes are handles and the way the files are served from iOS, but perhaps you are seeing it on Android as well. Would quite the source, but I can't recall where I found the solution, which was effectively doing the following:

// set the last item in the history to /, you could replace as well or add a query string for a forward after first load (e.g. /?redirectUrl=/tabs/tab1 )
history.pushState({}, 'Home', '/');

// now do your reload
window.location.reload();