CommunityToolkit / Microsoft.Toolkit.Win32

ARCHIVE - This repository contained XAML Islands wrapper controls and tooling for XAML Islands with WinUI 2, see readme for more info about XAML Islands with WinUI 3 and the WindowsAppSDK.
https://aka.ms/windowsappsdk
Other
383 stars 89 forks source link

WPF WebView.NavigateToString hangs #47

Open MichaelVach opened 6 years ago

MichaelVach commented 6 years ago

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 )
rjmurillo commented 6 years ago

Might be fixed by #2384

rjmurillo commented 6 years ago

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

MichaelVach commented 6 years ago

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 commented 6 years ago

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

MichaelVach commented 6 years ago

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

rjmurillo commented 6 years ago

@MichaelVach Thanks for the info!

rjmurillo commented 6 years ago

@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 commented 5 years ago

@joshholmes FYI

bbowyersmyth commented 5 years ago

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.

Unknown6656 commented 4 years ago

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