Question
· Jan 14, 2019

Bizarre Behaviour when generating HTML to Android Phone

Hi,

We are using Cache to generate HTML pages (complete with Javascript), which we are reading in an Android phone App's WebView.

If, when we generate HTML as follows:

<html>

<body bgcolor='red'>

Hello World

</body>

</html>

Reading this is iPad gets what you would expect, a red page with Hello World written in it.

However in Android phone, the page is both white and blank.

What stumps us is that for Android, if we intercept the call in the csp page that generates the html, and we redirect the call to another (cache) page's url (ie another csp page), the whole of the content of the new Url is displayed in the Android browser, no matter how complex.

Has anyone had such bizarre behaviour before?

Kind regards,

Anthony

Discussion (16)3
Log in or sign up to continue

Glad to hear you were able to make it work. Debugging these issues can be really painful. Emulators help as you can easily work with the debugger, but emulators only tell you half the story...

I usually debugged and tested these scenarios on a real device, connected to the IDE on my laptop, which allows you to see exactly what is going on via the output window and the debugger of your IDE. 

Eduard, sorry, but you miss-read my comment, I marked 'my' answer as accepted, as my explanation of my fix was in my comment 'to' Stefan.

And just to iterate that answer here, I put the pages concerned through an HTML validator and we discovered some tags that were no longer legal (frameset), even though some browsers still accept this in quirks mode, Android (Xamarin) doesn't.

Hi Stefan, thanks!

I've just resolved the issue, we used http://validator.w3.org/ to validate the HTML and as it turns out the Android webview is really strict and breaks when validation errors occur.

In our case it was a Frameset tag, which although not being legal, are still currently rendered in the other browsers that we use.

So guess what, I'm context-switching from my usual Xamarin duties where I consume the Cache generated content, to figuring out how to style an iframe instead, to work on all browsers. Tricky, because the iframe has to expand to the viewport, and then the content link has to zoom to the bounds of the iframe so that no scroll bars are shown.

Thanks for your suggestion!