WebView2 (TEdgeBrowser) not working in background (if not visible on screen) - only shows as grey rectangle

1.6k views Asked by At

I've confirmed this issue using the standard Delphi 10.4 EdgeBrowser VCL demo with the only difference that I have put the panel with the edgebrowser component on a TPageControl Tabsheet.

Now if my app starts with the Edgebrowser not visible directly on screen (because another tabsheet is active), the Edgebrowser will never fully paint on screen at any later date. It will ever only present itself as a grey rectangle and cannot recover from that, unless I call EdgeBrowser.CloseWebView; EdgeBrowser.CreateWebView; while the Edgebrowser component is visible on screen (it must be visible, or once again nothing happens).

This means I cannot issue "Edgebrowser.Navigate" commands or to anything while the Edgebrowser is in the background, on another tabsheet or while the form is hidden, or it will "go grey" again.

I wonder: Is this a bug or am I missing something major here? I tried calling Edgebrowser.Refresh and Edgebrowser.Repaint but neither help. Once it's grey, only closing and re-creating WebView helps to recover it.

It seems clear to me that this is some kind of canvas issue but I have no clue where to go from here. I hope you can help or at least confirm this strange behaviour.

System Specs: Delphi 10.4 Update 1 in Windows 10 Pro 20H2 in VMware Workstation 16 microsoft.web.webview2.0.9.579 from nuget and latest Edge Runtime from here (installed with bootstrap installer)

To quickly recreate the same scenario on your system: open "C:\Users\Public\Documents\Embarcadero\Studio\21.0\Samples\Object Pascal\VCL\WebBrowser\Edge\EdgeBrowser.dproj"; cut pnlWebViewHost to the clipboard (this is the panel that contains the Edgebrowser component); insert TPageControl; add 2 tabsheets and paste the pnlWebViewHost on one of them. Switch to the other, empty tabsheet, then run the app. At runtime, click on the tabsheet with the browser which should only appear now as a grey rectangle.

1

There are 1 answers

0
Christer Wiklund On

I have a tabpage and I have a browser at all pages. I Have a Webpage in all browsers If I click a tabpage I can switch between the browsers. If I Destroy one browser all will be gray. If I then call ReinitializeWebView at every browsers then it work again. I add a button at the tabpage that ReinitializeWebView, so I only try when the browser is visible. TWebbrower was more stand alone.

If I load a file in the browser ex. a XML, if I then close that browser it has no effect on the others. But it will be gray if I close some other.