Microsoft.Toolkit.Win32 icon indicating copy to clipboard operation
Microsoft.Toolkit.Win32 copied to clipboard

WPF WebView.NavigateToString hangs

Open MichaelVach opened this issue 7 years ago • 10 comments

I'm submitting a...

Bug report (I searched for similar issues and did not find one)

Current behavior

WPF WebView.NavigateToString() does not return;

Expected behavior

WPF WebView.NavigateToString() completes successfully

Minimal reproduction of the problem with instructions

In WPF XAML:

<wpf:WebView Name="WebView" Loaded="WebView_OnLoaded" />

Code:

private void WebView_OnLoaded(object sender, RoutedEventArgs e)
{
    WebView.NavigateToString("<html><body><h2>This is an HTML fragment</h2></body></html>");
}

Environment

Nuget Package(s): 
Microsoft.Toolkit.Win32.UI.Controls v4.0.1

Package Version(s): 

Windows 10 Build Number:
- [ ] Creators Update (15063)
- [ ] Fall Creators Update (16299)
- [X ] April 2018 Update (17134)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Creators Update (15063)
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] Insider Build (xxxxx)

WPF App targeting .NET Framework 4.7.2

Device form factor:
- [X] Desktop
- [ ] Mobile
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ ] 2017 (version: )
- [X ] 2017 Preview (version: 15.8.0 Preview 5 )

MichaelVach avatar Aug 20 '18 15:08 MichaelVach

Might be fixed by #2384

rjmurillo avatar Aug 22 '18 00:08 rjmurillo

@MichaelVach Please try the latest version of the package from https://dotnet.myget.org/gallery/uwpcommunitytoolkit to see if your issue is resolved.

rjmurillo avatar Aug 23 '18 23:08 rjmurillo

No, the issue is still present with v4.1.0-build.20.

Running against the compiled source on an Insider Build 17744 (I could not compile the source on the current release 17134) I could follow the code to:

Line 97 in WebViewControlProcess.cs var wvc = await await Task.Run(() => CreateWebViewControlAsync(hostWindowHandle, bounds)).ConfigureAwait(false);

where it hangs.

MichaelVach avatar Aug 24 '18 09:08 MichaelVach

Everything works fine if I replace the above mentioned line with: var wvc = await CreateWebViewControlAsync(hostWindowHandle, bounds);

MichaelVach avatar Aug 24 '18 11:08 MichaelVach

However the above mentioned solution only works for the Insider Build 17744 and not for the current release 17134.

MichaelVach avatar Aug 24 '18 11:08 MichaelVach

@MichaelVach Thanks for the info!

rjmurillo avatar Aug 24 '18 16:08 rjmurillo

@MichaelVach I've prepared a fix based on the investigation you did (thanks for that!). I've added a conditional check for RS4 to use the old initialization method, and newer builds to use the simpler await you describe. Please review #2426 if you could and verify the issue is resolved. Thanks again for your help!

rjmurillo avatar Aug 25 '18 01:08 rjmurillo

@joshholmes FYI

rjmurillo avatar Oct 24 '18 18:10 rjmurillo

Not sure if related but we had the same symptoms if VS was running "As administrator". Running VS normally or running the app exe directly worked fine.

bbowyersmyth avatar Mar 29 '19 00:03 bbowyersmyth

This issue is still reproducable in the newest version (v. 6.0.1).

Unknown6656 avatar May 05 '20 10:05 Unknown6656