MicrosoftEdge / WebView2Feedback

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

[Problem/Bug]: Blank window after navigate in hidden state #4763

Open alervd opened 1 month ago

alervd commented 1 month ago

What happened?

In our app, we are trying to start using WebView2 instead of CEF for displaying our main window's UI. At app start, we show a splash screen, calling navigate and waiting for the navigate to complete. The browser window is hidden (SW_HIDE) while navigating. Once navigation is complete, we show the browser window (SW_SHOW). Result: its window is blank. It shows nothing. It also does not react on mouse clicks in any way (e.g. does not show context menus).

Is it an expected behavior? Can it be disabled then? What are possible workarounds?

Importance

Blocking. My app's basic functions are not working due to this issue.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

No response

SDK Version

No response

Framework

Win32

Operating System

Windows 10

OS Version

No response

Repro steps

You can easily reproduce this behavior on sample apps (e.g. Win32_GettingStarted). For this, you need to modify Win32_GettingStarted project code in the following way:

  1. Add a call to CoInitialize(0).
  2. Change ShowWindow's mode to SW_HIDE.
  3. Add NavigationCompleted handler and show window in it (SW_SHOW).

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

victorhuangwq commented 4 weeks ago

@champnic could this be somewhat related to this issue https://github.com/MicrosoftEdge/WebView2Feedback/issues/1077?

mhdshameel commented 4 weeks ago

I too am facing the same issue. Did you find any workarounds for this? @alervd

alervd commented 3 weeks ago

@mhdshameel Yes, I temporarily show the window outside of the visible screen space and then hide it again once I get my callback with webview2 called.

mhdshameel commented 3 weeks ago

@mhdshameel Yes, I temporarily show the window outside of the visible screen space and then hide it again once I get my callback with webview2 called.

I have fixed it by using the webviewcontroller::put_IsVisible(true). Basically all the logistics stuffs are handled by the controller, so you can hide and let the navigation complete and show using this api of the wv2 controller

alervd commented 3 weeks ago

@mhdshameel put_IsVisible(true) works? Well, it's a something I should try too :)