I have a Xamarin.Forms app (version 5.0.0.2662) which, in a specific page, renders HTML that I download from my backend and store in the local file system. The app uses a custom WebView with its own custom renderer.
The HTML is rendered correctly always on iOS devices but on Android it depends on the Android System WebView version and OS version.
So far I could test in 2 real devices:
-
Samsung Galaxy A21s:
- Android 12
- Android System WebView 125.0.6422.165 -> FAILS
- Android System WebView 96.0.4664.104 (uninstalling updates from the previous latest)-> WORKS!
-
Samsung Galaxy S10+:
- Android 10
- Android System WebView 125.0.6422.165 -> WORKS
I inspected the WebView with chrome://inspect to see that only a about:blank page is shown. No content is visible on the DOM window of the inspector, no console messages, nothing.
I went to the code and played with the custom renderer I use to play a bit with the options there. I confirmed I allow for file access:
Control.Settings.AllowFileAccess = true;
I also use an extended WebViewChrome
but it doesn’t affect the output when I stop using it.
I tried also with the default Xamarin.Forms WebView element but the results are the same.
I also tried setting to true some of the other flags the native Android WebView offers to no avail:
Control.Settings.JavaScriptEnabled = true;
Control.Settings.AllowFileAccessFromFileURLs = true;
Control.Settings.AllowUniversalAccessFromFileURLs = true;
Control.Settings.AllowContentAccess = true;
Control.Settings.DomStorageEnabled = true;
Control.Settings.UseWideViewPort = true;
Control.Settings.LoadWithOverviewMode = true;
I also tried to use a custom WebViewClient
and I overwrote many methods to see if they were at least triggered but none of them was hit:
Control.SetWebViewClient(new ExtendedWebViewClient());
I thought about checking the source code of the not working version of the Android System WebView but couldn’t find it.
I’m quite lost and despite the problem having a workaround (uninstall updates for the Android System WebView), I would like to know the cause of the issue and a better workaround. Does anyone have any ideas?
Thanks!