8

I'm loading a small angular webapp in a webview. I don't have control or any info of the app other than the webpacked bundle.
At an exact point in the web app, my whole Android app crashes with the following logs:

08-22 09:13:33.980 29145-29191/com.my.app E/chromium: [ERROR:validation_errors.cc(87)] Invalid message: VALIDATION_ERROR_DESERIALIZATION_FAILED
08-22 09:13:33.981 29145-29191/com.my.app E/chromium: [ERROR:render_process_host_impl.cc(4399)] Terminating render process for bad Mojo message: Received bad user message: Validation failed for SynchronousCompositorControlHost::ReturnFrame deserializer [VALIDATION_ERROR_DESERIALIZATION_FAILED]
    [ERROR:bad_message.cc(25)] Terminating renderer for bad IPC message, reason 123
08-22 10:05:25.284 18717-18717/mx.tide.fiuanalyticsapp E/chromium: [ERROR:aw_browser_terminator.cc(86)] Render process (18816) kill (OOM or update) wasn't handed by all associated webviews, killing application.

I haven't found anything on the web other than the chromium source code where the errors are defined, I have no clue how to debug this problem as there is no problem while opening the web app directly on mobile Chrome browser.
So, have any of you idea of what this error could be? Or at least a lead for where could I start debugging the problem?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Mark E
  • 3,403
  • 2
  • 22
  • 36
  • Hi Mark, this doesn't looks like the cause of crashing. There must be something else. Can you add the full stacktrace ? Also check if [this](https://stackoverflow.com/questions/35364373/android-app-crashes-without-any-logcat-or-any-exception) one helps to find the error. – Bertram Gilfoyle Aug 22 '18 at 16:43
  • Hi Anees, this is the cause of crashing, I added another line to the logs. It wasn't there before because I was handling the `onRenderProcessGone` error on the webview for testing reasons. – Mark E Aug 22 '18 at 17:08
  • From the updated question, it looks like it is an out of memory issue. I doubt if you will be able to fix the issue without altering the code of the hosting app. – Bertram Gilfoyle Aug 22 '18 at 17:27

5 Answers5

5

I am running into the exact same issue. I was able to find that a css property, will-change: transform, was causing the issue, but I am not sure why yet since this property is being used elsewhere in the same file but does not cause the error.

I was able to find the culprit using charles proxy to set a breakpoint on the response of the webpage and systematically removing the scripts and links from the html. Eventually I found that by removing the main css link, the app no longer crashes. I then had to systematically remove lines from that css file until I found the line breaking the WebView.

I still haven't been able to figure out why this line breaks it, but it is set on a jpeg image in the html. Looks like its an issue with chromium. I am still trying to figure out why chromium has an issue with it.

P. G.
  • 82
  • 6
  • 1
    Bro you saved me. I had to find the issue in a 7000 lines CSS but I finally did it. The line causing the crash was `filter:url(#blur);` – Mark E Aug 23 '18 at 19:16
  • 1
    Btw, for debugging I found easier than the proxy to activate the `WebView.setWebContentsDebuggingEnabled(true);` flag. Then you can debug on a desktop chrome on the machine connected to the device by entering to the following URL: `chrome://inspect` – Mark E Aug 23 '18 at 22:49
  • 1
    why any other browser app can open this link normally? – Andrew F Oct 19 '18 at 13:09
4

Although my problem was solved thanks to @P. G.'s answer, I wanted to add the way I solved the problem without having access to the original web app code, this may help someone else.

So, I needed to replace the CSS which was causing the problem, so I downloaded the original app CSS, fixed it, and uploaded it to my own server. Then, in the android app I overrided the shouldInterceptRequest method of the web view and whenever the app tried to load the CSS I would replace it with my own.
Code:

 mWebView.setWebViewClient(new WebViewClient() {

        @Override
        public WebResourceResponse shouldInterceptRequest (WebView view, WebResourceRequest request){

            String urls = request.getUrl().toString();

            //To prevent the WebView from crashing, we serve our own css modified version
            if( urls.equals("https://originalapphost.com/theircssfile.css")  ) {
                try {
                    URL url = new URL("https://myhost.com/mymodifiedcssfile.css");
                    URLConnection connection = url.openConnection();
                    return new WebResourceResponse(connection.getContentType(), connection.getHeaderField("encoding"), connection.getInputStream());
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }

            return super.shouldInterceptRequest(view, request);
        }
    });

Also, I think that having a list of css that crash the android webview would be really helpful. I'll start it here and if you find another one please feel free to comment here and I'll be updating this answer.

  • will-change: transform;
  • filter:url(#blur);
Mark E
  • 3,403
  • 2
  • 22
  • 36
1

use this solution

        webView.webViewClient = object : WebViewClient() {
            override fun onRenderProcessGone(
                view: WebView?,
                detail: RenderProcessGoneDetail?
            ): Boolean {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
                    if (detail?.didCrash() == false) {
                        webView.loadUrl(url)
                        return true
                    }
                return false
            }
        }
Mahdi Zareei
  • 1,299
  • 11
  • 18
0

We too have the similar issue and after doing lot of analysis found that this happening with CSS file which is related to the width.

we have previously this

.card,
.footer {
    margin: auto;
    max-width: 600px
}

and changed to this and working after the change.

@media (min-width:601px) {
    .card,
    .footer {
        margin: auto;
        max-width: 600px
    }
}
papanito
  • 2,349
  • 2
  • 32
  • 60
  • Hi there, it's weird that it breaks with such common rules. I think that may be your code stopped breaking because the rule is no longer applied after your media query. If that's the case, it will crash if you run it on a device with a larger screen. – Mark E Jul 04 '20 at 02:24
-1

I solved this by disable hardware accelerate.