-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebView2 windows are blank when created in the background #1077
Comments
you may try if |
Ok, how is that better than my workaround of re-creating the view? It would be great if there would be a way to
Best |
We'll work on getting the underlying bug fixed. In the meantime, if the workaround suggested by @cuiliang works, it is probably simpler and more performant than recreating the whole WebView2. |
We set webview2 to be always visible for simplicity. This is more of a workaround. Microsoft is also working to fix it: MicrosoftEdge/WebView2Feedback#1077
* Fix visibility on webview2 when window was invisible previously We set webview2 to be always visible for simplicity. This is more of a workaround. Microsoft is also working to fix it: MicrosoftEdge/WebView2Feedback#1077 * Add changes file
@dominicletz Can you share some code around where you create the WebView2 when in the background, parenting the HWNDs, and then making it visible? A repro app would be ideal if possible. Thanks! |
I was about to submit a new issue, but looking at this #1077 I think that the root cause could be the same as mine. Could you please confirm as I describe below? Many thanks, I'm attaching a simple repro app - MFCApplication1-Source.zip, that works as follows:
When the app is opened:
Inspecting with Spy++ we can see that:
Let me know if more input is needed. |
I am encountering this too. I create WPF windows containing a WebView component in hidden state. When making the windows visible they are blank. Only way round this is to show the window just before I create and initialise the WebView instance and then hide. |
Thanks @topozepe for the great repro app! I think I was able to root cause the issue, and we should hopefully have a fix soon. One workaround for now is to manually toggle WebView2.Visible after the control has navigated. This should cause OnVisibleChanged to fire again and we'll correctly set the visibility on the controller. For example, the following code change fixed the "Add tab without focus" case: private void webView21_NavigationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e)
{
listBox1.Items.Add($"{DateTime.Now.ToLongTimeString()} nav completed");
webView21.Visible = false;
webView21.Visible = true;
} |
Thanks @champnic for the great workaround! 👍 |
This is now fixed in 1.0.902-prerelease SDK. Thanks! |
FWIW, I was encountering this same issue using WinForms with SDK 1.0.705.50, RT 91.0.864.41. The 2nd and subsequent WebView2 instances that I created (all sharing the same User Data Folder), just rendered a gray background. I tried the workaround of toggling the visibility of the WinForm WebView2 to False then back to True before rendering content (NavigateToString) for the first time in each instance. That works: I now see the expected content instead of the gray background. |
Attempted fix for displaying nothing on some computers. Mentioned: MicrosoftEdge/WebView2Feedback#1077. Unfortunately these did not work...
Can someone else confirm that it's really fixed? Because for me it still doesn't work. I still have to set visibility to false and true before WebView2 shows up. |
@Symbai What SDK and Runtime are you using where you still see this? |
@champnic .NET5 and 1.0.902-prerelease SDK. I have Edge Canary Version 94.0.979.0 installed and Webview2 runtime Version 92.0.902.67 The exact order is:
Without step 4 all I see are white/blank screens. Please keep in mind that webview2 controls do exist and work, otherwise the So yeah I have to explicit refresh the visibility otherwise I get a blank screen. |
@Symbai Let me see if I can reproduce the problem using those steps! |
I've confirmed that use case has not been fixed, reactivating this item. Thanks! |
What API am I supposed to call if I am using C++ ? |
@zeltrax00 This particular bug was specific to our .NET controls. If you are seeing an issue with the C++ Win32 control, please open that as a new issue and we can dig into it. Thanks! |
@zeltrax00 Did you find or create a similar issue for C++? I didn't find anything, but @champnic's comment1 made me go looking for something similar in the C++ interfaces. I found that if I call ICoreWebView2Controller::put_IsVisible(BOOL) with TRUE in my OnCreateWebViewControllerCompleted code, the problem may be fixed (we're still testing it here). |
Can anyone confirm if this is still an issue with the win32 API? I see 2 linked tickets that are open. |
Version
SDK: 1.0.705.50 (NuGet Microsoft.Web.WebView2 package)
Runtime: Microsoft Edge Version 89.0.774.45
Toolset: Visual Studio 2019 (v16.8.4)
Framework: Win32
OS: Win10
Description
I'm having the same issue and it's not related to #1044. What I was able to find so far is that the issue seems to happen most frequently when I create the WebView in a window that is not shown.
The fun thing is that even on the bug side Edge is running in the background and I can interact with the API. E.g. fetch the page source code, even eval a script but it won't ever render anything on the screen nor react to right mouse clicks.
Workaround
My current workaround is to re-create the WebView once my application is shown and visible on-screen with a 500ms delay. That seems to do it. So I think there is something wrong with creating a webview in the background.
Originally posted by @dominicletz in #1042 (comment)
AB#32169221
The text was updated successfully, but these errors were encountered: