cordova - How to find out what is causing my white screen of death? -


i have ionic app. it's works couple of weeks, stops. splash screen followed white screen of death. when debug using chrome://inspect app following message in console:

no content-security-policy meta tag found. please add 1 when using cordova-plugin-whitelist plugin.

if clear data on app, starts working, , same message when debug working app on device, don't think it's plugin @ fault. however, have used plugin explore white-screen problem, because can white screen of death if add following index.html (a content security policy prevents loading resources source):

<meta http-equiv="content-security-policy" content="default-src 'none'"> 

when that, error messages in console:

refused load stylesheet 'file:///android_asset/www/lib/ionic/css/ionic.min.css' because violates following content security policy directive: "default-src 'none'". note 'style-src' not explicitly set, 'default-src' used fallback

and when change tag this:

<meta http-equiv="content-security-policy" content="default-src 'self'"> 

i in console:

refused apply inline style because violates the..etc

and

evalerror: refused evaluate string javascript because 'unsafe-eval' not allowed source of script...etc"

but now, instead of white screen, exception handler catching problem , reporting it.

from this, deduce absence of files causes white screen, because exception handler works if files loaded.

i can rid of errors in console using security policy:

<meta http-equiv="content-security-policy"            content="style-src 'self' ionic.bundle.min.js 'unsafe-inline';                    script-src 'self' console-via-logger.js 'unsafe-eval';                    img-src 'self' ionic.bundle.min.js data:"> 

so wondering if there way catch exception in application @ earlier stage can diagnose original white-screen problem? think must in data preventing file being loaded, how be?

to test kerri shotts theory javascript error getting in way of app startup, added throw app.js file:

(function () {     'use strict';      throw ('test');      //setting dependencies     var app = angular.module('app', [..etc..]     ]);  })(); 

sure enough - white screen of death

next added window.onerror script index.html:

<body data-ng-app="app">     <script>         (function () {             window.onerror = function (errormsg, url, linenumber, column, errorobj) {                 alert('error: ' + errormsg + ' script: ' + url + ' line: ' + linenumber                 + ' column: ' + column + ' stacktrace: ' + errorobj);             }         }());     </script>     ....etc 

i had add 'unsafe-inline' content security policy script run, once did got alert error message instead of white screen.

my csp:

<meta http-equiv="content-security-policy"           content="style-src 'self' ionic.bundle.min.js 'unsafe-inline';                    script-src 'self' console-via-logger.js 'unsafe-eval' 'unsafe-inline';                    img-src 'self' ionic.bundle.min.js data:"> 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -