Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.
Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.
Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.
Please create a new report for Bug 57451 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the original description:
In special cases on GitHub you might also want the comments: GitHub Markdown with public comments
Linked is a slightly modified version of the solution for the Hanselman.Forms sample. https://1drv.ms/u/s!AmeCKE6dgpGln8ZlXlYGrTLV7o0FZg I've added a "Repro" page and modified the About Page to contain a WebView. The original issue was seen on a stable version of forms. The linked version is based on the 2.3.5.239-pre3 forms package in the chance that something was fixed that might alleviate the problem. To reproduce the problem, build the project (debug or release) for x64 UWP and deploy to the local machine. I'm building on VS 2017 Community and am deploying to a pc running Windows 10 v1703 OS Build 15063.332. run the app. At startup the app displays the added "Repro" page. Sometimes the webview is displayed, other times it doesn't. See the screenshots in the Screenshots folder for success and fail captures. Usually, if the webview does display on the Repro page, going to the About page will demonstrate the issue there. Switching between the windows eventually causes both to display as expected. The problem does not present on the Android or iOS versions of the app.
I was able to reproduce the issue using the project linked to in the description. As mentioned, the issue happens a majority of the time, but not always. I am confirming the report so this can be investigated further. In the repro project, the WebView is loading HTML with a HtmlWebViewSource so I decided to test loading a website instead. When a loading a website the issue appeared to not occur so this may indicate the issue being related to using a HtmlWebViewSource. ### Version Tests 2.3.6.109 BAD 2.3.5-pre3 BAD ### Version Info Microsoft Visual Studio Enterprise 2017 Version 15.2 (26430.13) Release VisualStudio.15.Release/15.2.0+26430.13 Microsoft .NET Framework Version 4.7.02046 Installed Version: Enterprise Visual Basic 2017 00369-60000-00001-AA107 Microsoft Visual Basic 2017 Visual C# 2017 00369-60000-00001-AA107 Microsoft Visual C# 2017 Visual C++ 2017 00369-60000-00001-AA107 Microsoft Visual C++ 2017 Visual F# 4.1 00369-60000-00001-AA107 Microsoft Visual F# 4.1 Application Insights Tools for Visual Studio Package 8.6.00404.2 Application Insights Tools for Visual Studio ASP.NET and Web Tools 2017 15.0.30503.0 ASP.NET and Web Tools 2017 ASP.NET Web Frameworks and Tools 2017 5.2.50303.0 For additional information, visit https://www.asp.net/ Azure App Service Tools v3.0.0 15.0.30209.0 Azure App Service Tools v3.0.0 Common Azure Tools 1.9 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. JavaScript Language Service 2.0 JavaScript Language Service JavaScript Project System 2.0 JavaScript Project System JavaScript UWP Project System 2.0 JavaScript UWP Project System KofePackagePackage Extension 1.0 KofePackagePackage Visual Studio Extension Detailed Info Merq 1.1.17-rc (cba4571) Command Bus, Event Stream and Async Manager for Visual Studio extensions. Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50131.1 Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package Mono Debugging for Visual Studio Mono.Debugging.VisualStudio Support for debugging Mono processes with Visual Studio. NuGet Package Manager 4.2.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/. SQL Server Data Tools 15.1.61702.140 Microsoft SQL Server Data Tools TypeScript 2.2.2.0 TypeScript tools for Visual Studio Visual Studio Tools for Universal Windows Apps 15.0.26430.06 The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit. Xamarin 4.5.0.486 (fec6f88) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin.Android SDK 7.3.1.2 (9dbc4c5) Xamarin.Android Reference Assemblies and MSBuild support. Xamarin.iOS and Xamarin.Mac SDK 10.10.0.37 (ad35de4) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Just ran into the same issue here on 2.3.4.247. HtmlWebViewSource doesn't display any of the provided HTML. It's strange because it was working before when I was building in VS 2015. I've since upgraded Windows 10 Creators update and VS 2017, but now I can't get it to work with any version of Xamarin Forms.
I have no idea what is going on here. It seems to have something to do with the UWP WebViewRenderer calling Control.NavigateToString from within the internalWebView.NavigationCompleted event handler. I've tried wrapping NavigateToString with Dispatcher.RunAsync, but that doesn't help. Calling NavigateToString from the Loading and Loaded events result in the same problem. However, the NavigationStarting event works fine. Need some insight from Microsoft on this one. Here's my current workaround: internal sealed class CustomWebViewRenderer : WebViewRenderer, IWebViewDelegate { void IWebViewDelegate.LoadHtml(string html, string baseUrl) { if (Element.Source is HtmlWebViewSource && string.IsNullOrEmpty(baseUrl)) Control.NavigateToString(html); else LoadHtml(html, baseUrl); } }
Hi, I have the very same problem. The HTML is loaded via a HtmlWebViewSource. The HTML is not displayed. The work around from Taylor Buchanan did not work for me. I notice that when rotating the device, the HTML will be displayed.
Created attachment 23263 [details] Create dynamic HTML and try to display via HtmlWebViewSource. Have a look at the HtmlPage.cs which tries to display a dynamic created HTML.
As an addition. It will never work in relase mode without an attached debugger. It will work in release mode when an debugger is attached. It will work in debug mode (with or without attached debugger). Hope that helps fixing the bug.
Hi. We have the same problem as described by Soernt. Is there any solution for this?
Soernt, The workaround I provided works fine for me and the OP. In the project you attached, the custom renderer is registered incorrectly. [assembly: ExportRenderer(typeof(WebView), typeof(WebViewRenderer))] should be [assembly: ExportRenderer(typeof(WebView), typeof(CustomWebViewRenderer))] After fixing this, the project works as expected.
Is there a fix for this yet? Is there a workaround I can implement in my Xamarin.Forms project?
I still found I was experiencing this issue today. The work around Taylor mentions I found wouldn't load local resources (styles, javascript etc) so I dug a bit more and found the ContentLoaded event never fires. I was then able to look to see if this event had fired after X milliseconds and simply load the HTML again to fix the issue. I wrote up the details if its helpful to anyone else: https://blog.mjjames.co.uk/2018/05/uwp-webview-intermittently-fails-to.html
If easier, the Gist for the solution is available at: https://gist.github.com/mjjames/e0c2e261ba4095ec5a1b51253983a608