MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
453 stars 55 forks source link

Server 2012 R2 Test project not working with Citrix #675

Open mercethereal opened 3 years ago

mercethereal commented 3 years ago

Description Can't get a small test WPF project to work on server 2012. Comes up in a blank window. It works fine in windows 10 Here is the XAML: ` <Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf" xmlns:local="clr-namespace:WpfApp1" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800">

`

and here is the c# code

using System.Windows; namespace WpfApp1 { ///

/// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } } }

Version SDK: 1.0.674-prerelease Runtime: using the runtime 87.0.664.47 Framework: .NET 4.8 OS: Server 2012 no service pack

Repro Steps -set up a minimal WPF project in visual studio with the code listed above along with .net framework 8 -deploy the solution along with the runtime(version listed above) to server 2012 R2 -should display a window with the embedded browser that navigates to www.microsoft.com -What we are getting is a blank window. No error messages

Screenshots

Additional context

AB#31697767

champnic commented 3 years ago

@mercethereal Thanks for the report! If you debug with Visual Studio, could you try enabling all exceptions (VS > Debug menu > Windows > Exception Settings)? Or could you try explicitly initializing the control using EnsureCoreWebView2Async? Both of those help to surface errors that otherwise can be suppressed.

cgeier commented 3 years ago

@mercethereal Perhaps it's an issue with your antivirus. Not sure if you use Symantec Endpoint Protection (SEP), but someone found an issue when using an older version of it (see #443).

Symantec Endpoint Protection (SEP) issue Chrome and Chromium are also impacted when installed on any Operating System (OS) with a SEP version older than 14.2 RU2 MP1

In versions of Google Chrome (chrome.exe) and versions of Microsoft Edge Chromium, Microsoft's Code Integrity feature is enabled. SEP Application Control technology is not compatible with this feature in Chrome/Chromium.

Please update to 14.2 RU2 MP1 build 14.2.5569.2100

_If upgrading SEP is not an option, or the OS is one of those listed above, the incompatibility can be worked around by adding an Application Control exception for Chrome (Chrome.exe) and/or Microsoft Edge Chromium (MSEdge.exe).__

mercethereal commented 3 years ago

@cgeier No, we don't have Symantec Endpoint Protection. We use ESET according to my sysadmin.

mercethereal commented 3 years ago

@champnic Ok, I enabled all the exceptions, and added this code under InitializeComponent

CoreWebView2Environment env = CoreWebView2Environment.CreateAsync("", System.IO.Path.GetTempPath(), null).GetAwaiter().GetResult(); webView.EnsureCoreWebView2Async(env);

We still have the same issue... A blank pops up, no exceptions raised, nothing happens.

champnic commented 3 years ago

Hm, this is strange. Given there are no errors during initialization, I wonder if it's something to do with the Server 2012 configuration, blocking the network request for microsoft.com or something? Could you try navigating to a local html file or html string after it's initialized:

webView.NavigateToString(@"<!DOCTYPE html><html><body><h1>Hello world!</h1></body></html>");
mercethereal commented 3 years ago

@champnic Thanks for your reply. even in Windows 10, that NavigateToString line is throwing the exception (below). The exception doesn't make sense since I am both setting the source and initializing with EnsureCoreWebView2Async.

I don't think the server is blocking www.microsoft.com. The main application I'm trying to push into production is reading from a local file. The same thing is happening, i.e. blank screen.

System.InvalidOperationException HResult=0x80131509 Message=Attempted to use WebView2 functionality which requires its CoreWebView2 prior to the CoreWebView2 being initialized. Call EnsureCoreWebView2Async or set the Source property first. Source=Microsoft.Web.WebView2.Wpf StackTrace: at Microsoft.Web.WebView2.Wpf.WebView2.VerifyCoreWebView2() at Microsoft.Web.WebView2.Wpf.WebView2.NavigateToString(String htmlContent) at WpfApp1.MainWindow..ctor() in C:\Users\whitne\source\repos\WpfApp1\MainWindow.xaml.cs:line 20

cgeier commented 3 years ago

@mercethereal, @champnic l I was able to able to reproduce the issue -- the blank screen. The issue is occurring because you're not using await with webView.EnsureCoreWebView2Async(env);, so execution is continuing without waiting for the initialization to complete. webView.EnsureCoreWebView2Asyc is a Task not void. If the Task needs to complete before continuing, it's necessary to use await. In order to use await one needs to specify async, which isn't possible with a constructor. Therefore, if one wishes to perform WebView2 initialization, it needs to happen in Window-Loaded.

MainWindow.xaml

                              ...

Window x:Class="WebView2Testv10674.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
        xmlns:local="clr-namespace:WebView2Testv10674"
        mc:Ignorable="d"
        Loaded="Window_Loaded"
        Title="MainWindow" Height="450" Width="800">

                              ...

MainWindow.xaml.cs

Incorrect:

public MainWindow()
{
    InitializeComponent();

    webView21.EnsureCoreWebView2Async();
}

Correct:

private async void Window_Loaded(object sender, RoutedEventArgs e)
{
     //wait for CoreWebView2 initialization
    await webView21.EnsureCoreWebView2Async();
}

WebView2Testv10674 - correct.zip WebView2Testv10674 - incorrect.zip

Here's the result of running the incorrect version:

Webview2-Output-Incorrect

Here's the result of running the correct version:

Webview2-Output-Correct

In the incorrect version, notice that Window loaded message appears before webview21_CoreWebView2Ready message.

In the correct version, Window loaded message appears after webview21_CoreWebView2Ready message.

cgeier commented 3 years ago

@champnic It appears that the WebView2 - GettingStarted documentation is incorrect under Step 7 - Communication between host and web content . The documentation shows:

public MainWindow()
{
    InitializeComponent();
    webView.NavigationStarting += EnsureHttps;
    InitializeAsync();
}

async void InitializeAsync()
{
    await webView.EnsureCoreWebView2Async(null);
}

It should be:

public MainWindow()
{
    InitializeComponent();
}

private async void Window_Loaded(object sender, RoutedEventArgs e)
{
    await InitializeAsync();
    webView.NavigationStarting += EnsureHttps;
}

async Task InitializeAsync()
{
    await webView.EnsureCoreWebView2Async(null);
}
mercethereal commented 3 years ago

@cgeier I took your WebView2Testv10674 - correct.zip https://github.com/MicrosoftEdge/WebView2Feedback/files/5645226/WebView2Testv10674.-.correct.zip solution verbatim and made the following change:

        //set Source property - navigate to URL
        //webView21.Source = new Uri("https://www.microsoft.com",

UriKind.Absolute); webView21.NavigateToString(@"<!DOCTYPE html>

Hello world!

");

Once again it works great in windows 10, but in Server 2012, it's just a blank window....

On Fri, Dec 4, 2020 at 1:17 PM cgeier notifications@github.com wrote:

I was able to able to reproduce your result. The issue is occurring because you're not using await with webView.EnsureCoreWebView2Async(env);, so execution is continuing without waiting for the initialization to complete. In order to use await one needs to specify async, which isn't possible with a constructor. Therefore, if one wishes to perform WebView2 initialization, it needs to happen in Window-Loaded.

Incorrect:

public MainWindow() { InitializeComponent();

webView21.EnsureCoreWebView2Async();

}

Correct:

private async void Window_Loaded(object sender, RoutedEventArgs e) { //wait for CoreWebView2 initialization await webView21.EnsureCoreWebView2Async(); }

WebView2Testv10674 - correct.zip https://github.com/MicrosoftEdge/WebView2Feedback/files/5645226/WebView2Testv10674.-.correct.zip WebView2Testv10674 - incorrect.zip https://github.com/MicrosoftEdge/WebView2Feedback/files/5645229/WebView2Testv10674.-.incorrect.zip

Here's the result of running the incorrect version:

[image: Webview2-Output-Incorrect] https://user-images.githubusercontent.com/34412039/101210391-66c7a200-3643-11eb-9c80-bb0b3708b43e.JPG

Here's the result of running the correct version:

[image: Webview2-Output-Correct] https://user-images.githubusercontent.com/34412039/101210428-76df8180-3643-11eb-9bd5-f1f4ff97af76.JPG

In the incorrect version, notice that Window loaded message appears before webview21_CoreWebView2Ready message. In the correct version, Window loaded message appears after webview21_CoreWebView2Ready message.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MicrosoftEdge/WebView2Feedback/issues/675#issuecomment-738996828, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4JR4UJR6I3MONU57P3PODSTE7VFANCNFSM4UCQRBTA .

cgeier commented 3 years ago

@mercethereal Find the MS Edge version that WebView2 is trying to use. Add the following line of code to Window_Loaded:

MessageBox.Show(Microsoft.Web.WebView2.Core.CoreWebView2Environment.GetAvailableBrowserVersionString(), "MS Edge Version", MessageBoxButton.OK, MessageBoxImage.Information);

So you'll have:

private async void Window_Loaded(object sender, RoutedEventArgs e)
{
    //wait for CoreWebView2 initialization
    await webView21.EnsureCoreWebView2Async();
    MessageBox.Show(Microsoft.Web.WebView2.Core.CoreWebView2Environment.GetAvailableBrowserVersionString(), "MS Edge Version", MessageBoxButton.OK, MessageBoxImage.Information);

}

Mine shows: 88.0.705.9 dev

mercethereal commented 3 years ago

@cgeier The messagebox worked on the server 2012. It came up with 87.0.664.55

cgeier commented 3 years ago

@mercethereal After testing (on a fresh install of Windows Server 2012 Standard), I found that the issue exists when using MS Edge Chromium v.87.0.664.55 on Windows Server 2012 Standard -- the msedgewebview2.exe processes seem to crash. However, it works if MS Edge Chromium v. 88.0.673.0 (or 88.0.705.9) is installed. I didn't test any other versions.

You can download later versions of MS Edge Chromium from MS Edge Business

mercethereal commented 3 years ago

@cgeier Thanks a lot for doing all of that testing and setup work..

That version, v.87.0.664.55, is the runtime version which we got from Here:, https://developer.microsoft.com/en-us/microsoft-edge/webview2/. I believe that is the latest version of the runtime.

We are looking to see if we can install the full blown browser on the server and if it will impact any other applications installed on there. If we could find a more recent version of the runtime, we would try it out..

aseme commented 3 years ago

@mercethereal

I am having a similar issue as you describe here. I installed the desktop chrome beta branch and was not able to get that to work either. Similar blank screen and mild locking up the PC. I followed the steps in this article and was able to get the desktop version working, but not runtime in my app. I'm using version 87.0.664.75 of the runtime. I've also attempted to use a beta branch of chromium and get the same blank page. So both runtime and edge beta have the same issue.

After some digging I see that msedgeview2.exe is logging some security errors related to SeTcbPrivilege.

Process: Process ID: 0x4bf4 Process Name: C:\Program Files (x86)\Microsoft\EdgeWebView\Application\87.0.664.75\msedgewebview2.exe

Service Request Information: Privileges: SeTcbPrivilege

This seems to be the reason for the failure, but I cannot confirm. Just wanted to chime in here since I am at a loss as to what to do now.

champnic commented 3 years ago

@aseme Can you share what versions of the SDK you are using? And when you say "desktop version" is working, what are you referring to? All WebView2 apps will need a runtime, either a prerelease Microsoft Edge (Canary, Dev, or Beta), or the WebView2 Runtime.

aseme commented 3 years ago

@champnic

Sorry my word choice was poor. I attempted to use the standalone evergreen runtime from this page and I also attempted to use the beta channel of MS Edge.

WebView2 SDK: 1.0.721-prerelease WebView Runtime: 88.0.705.50 MS Edge Beta: 89.0.767.0 .Net Framework 4.7 - Winforms

Here is some more context. So we distribute our application through a Citirx storefront. I can also directly RDP into the server to run the application. The app will not load the browser control on the server, but will load it when running locally. I'm using explicit initialization of the WebView2 objects and I am doing that before any calls to Navigate or the Source property. To me this seems to be related to a config on the MS server 2012 R2 machine, but I cannot manage that server directly so I cannot be 100% sure.

champnic commented 3 years ago

Thanks for the clarification. Sounds like it is limited to the server and possibly linked to the configuration of that server. Are you able to test on a different server machine/VM? One that you have control over, to see if it affects all servers or just the configuration of that particular one?

aseme commented 3 years ago

@champnic

Another update!

Took a bit, but I was able to get a clean install of Windows server 2012 R2 provisioned and did my testing. The control works up until we install the Citrix components on the server. After that I the control will not start and I get the same errors mentioned above. I've also seen a few other stackoverflow posts about the control not working on Citrix.

So at this point I'm unsure what to do and unsure if you would be able to help me or if I need to reach out to someone else.

Thanks

champnic commented 3 years ago

That's a great find, thanks @aseme! I've opened this issue as a bug on our backlog to track.

dguisinger commented 3 years ago

We too are experiencing this problem on a server with Citrix installed. Works fine installed on local machines, as soon as we promoted it to an environment to be deployed, upon opening it just freezes when we try to display the window with the WebView2 control

We are using WinForms, so this is more than a WPF issue

dguisinger commented 3 years ago

@champnic I don't suppose there is any thought at this point as to the root cause of issues on a Citrix server? We got caught extremely flat footed by this, we just moved a 8-month long project into user acceptance testing when we found this. Since we have to operate in Citrix with a massive 20-yr old WebForms application for our users, we can't jump to a pure web application anytime soon. If this is some sort of Citrix configuration or COM security issue or something like that and can be worked around, I'd love to hear it... likewise, if this is not a short-term priority in your backlog and there is no work around, then we need to know so we can engineer a new solution that doesn't use WebView2.

champnic commented 3 years ago

We haven't taken a look yet, but I'll up the priority and try to get someone looking at this next week. Our team doesn't have experience deploying Citrix so that may slow down our investigation a bit while we get ramped up.

champnic commented 3 years ago

@aseme Looking at the article: https://www.petenetlive.com/KB/Article/0001657

Can you try the described workaround but use msedgewebview2.exe instead of msedge.exe?

open the registry Editor (regedit) and navigate to;

HKEY_LOCAL_MACHINE > System > CurrentControlSet > Services > CtxUvi Locate the UviProcesExcludes REG_SZ value, edit it and add ~‘msedge.exe;‘~ 'msedgewebview2.exe' to the end.

image

Theres probably one service you can restart, but I simply rebooted the server, (problem solved).

champnic commented 3 years ago

Here are the same instructions from Citrix support: https://support.citrix.com/article/CTX286837

dguisinger commented 3 years ago

https://support.citrix.com/article/CTX286837

We tried this and it doesn't seem to make a difference for us

Screen Shot 2021-03-05 at 7 14 15 PM

champnic commented 3 years ago

Per #1082, can you try these instructions? https://support.citrix.com/article/CTX107825

AndersAlfredsson commented 3 years ago

@dguisinger There is a 14 char limit for process names, try removing .exe from msedgewebview2.exe.

aseme commented 3 years ago

@champnic @dguisinger

Wow sorry for such a late reply on this issue. We got our solution working with the provided above solution and updating the Citrix VDA. So with the regedit solution and an update to our Citrix Agent we were able to get WebView2 working on our servers.

Update:

Here is a brief summary of that our Citrix team did to fix this issue:

Upgraded the Citrix VDA to 1912 Cumulative Update 2, then added the CTXUvi processes in the registry

dguisinger commented 3 years ago

Thanks @aseme for adding the details, I'm reaching out to our Citrix team on this. I had mentioned it to them 2 days ago and they said there was a constraint as to why the cluster wasn't running the latest and greatest, so I'll find out what they have to say with these details.

@champnic using "msedgewebview2" instead of "msedgewebview2.exe" didn't make a difference.

groege commented 2 years ago

That's a great find, thanks @aseme! I've opened this issue as a bug on our backlog to track.

@champnic This is a very urgent issue for us, is the bug on your backlog public (for us to track as well)? Any recent update on the issue?

champnic commented 2 years ago

@groege Can you add some info on what's not working for you? What version of Citrix are you using, and have you reached out to Citrix about a conflict with WebView2?

groege commented 2 years ago

Webview2 was not working until adding "msedgewebview2" to "UviProcesExcludes". Generally we do not know what Versions our are customers are using (not even sure how many use Citrix at all) If there is a minimum Citrix Version recommended, please inform us so we can at least add it to our system requirements for our software. We have testet it with Version "7.15 LTSR" Can you tell us if the Bug you created is publicly available? We didn't reach out to Citrix yet, since we assumed its a problem of WebView2 because of your post about tracking the problem internally.

champnic commented 2 years ago

@groege In this case the bug is on Citrix's end. We're trying to reach out to Citrix as well to have them update the default list in "UviProcessExcludes". The bug is not publicly available - this issue is our external facing tracking item.

AcharyaSandeep111 commented 2 years ago

@groege @dguisinger @AndersAlfredsson @aseme Hi, thanks for bringing up the issue to Citrix. May I know what version of XenDesktop / CVAD, OS and webview2 runtime are you using ? I saw someone commented this issue is reproducible with webView2 runtime v.87.0.664.55. Is it still reproducible in newer webView2 runtimes as well ?

groege commented 2 years ago

@groege @dguisinger @AndersAlfredsson @aseme Hi, thanks for bringing up the issue to Citrix. May I know what version of XenDesktop / CVAD, OS and webview2 runtime are you using ? I saw someone commented this issue is reproducible with webView2 runtime v.87.0.664.55. Is it still reproducible in newer webView2 runtimes as well ?

The problem hasn't been solved so far in Version: 98.0.1108.56 Adding the Registry Entry is still the way to go so far... Please contact the citrix Support ==> we asked them to do it but it seems they will only do something themselves if enough people are complaining about the issue...

AcharyaSandeep111 commented 2 years ago

Hi @groege , thanks for your reply. I work at Citrix HDX Engineering team and we were notified by Microsoft about this case.

Could you please describe more about your environment details like OS version and patch level, Xendesktop / CVAD version, .NET runtime version and any other relevant information that can help us reproduce the issue on our end (so far, we couldn't reproduce this).

I am using the following simple WebView2 app for testing. https://github.com/MicrosoftEdge/WebView2Samples/tree/master/GettingStartedGuides/WPF_GettingStarted

Can you test this app and see if you get similar blank screen ?