Skip to content
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

On Startup the WebBrowser renders a gray surface (WPF) #196

Closed
RickStrahl opened this issue May 22, 2020 · 7 comments
Closed

On Startup the WebBrowser renders a gray surface (WPF) #196

RickStrahl opened this issue May 22, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@RickStrahl
Copy link

RickStrahl commented May 22, 2020

This is kind of a nit-picky report, but I noticed that when using the control (in WPF) it briefly displays a gray background before content is rendered. Startup is relatively slow (compared to the IE WB control anyway) and the grey flash is pretty noticeable.

In the screen capture I have a small form with a full form docked WebView2 that is set to about:blank (just to do the quickest loading things possible) on a green background:

WPF-Window-White

Notice how the page never shows the green background, but launches into a grey background then after initialization (or whatever) shows the white of the about:blank.

This is even more noticeable for my initial scenario which is loading an editor with a black background:

WPF-Window-Editor-Greyload

At first I though it was part of my slow loading content, but even when loading about:blank there still was the grey flash before the control displays content. I also experimented with hiding the WebBrowser or the docking container and making it visible later, but even then I still get the grey flash.

Expected behavior:

  • Control should show transparent until it's ready to display the browser canvas or failing that provide a way to set the background color.

AB#28898913

@david-risney
Copy link
Contributor

Thanks, I'll open a bug and look into that. I expect its something related to how we're using HwndHost.

Generally though wouldn't you want to show a progress control or otherwise hide the control until some event like NavigationComplete or a WebMessage from your web content to let you know its ready to show to the end user?

@david-risney david-risney added .NET bug Something isn't working labels May 22, 2020
@RickStrahl
Copy link
Author

RickStrahl commented May 23, 2020

No not really - I'm expecting content to load almost instantly and I'm OK with seeing whatever browser natural load behavior that you would expect when a document first loads because I can control that.

The content I'm rendering (or even about:config) should be instantly rendering and by the time the form actually becomes visible via UI (which is delayed as is) the content should already long be there and ready to render. But that doesn't seem to be happening here. You can see about:blank still showing that delay with the grey background...

I realize transparency is not so easy with this control since it's a Windowed control mapped into the WPF canvas, but this worked in previous iterations of the Web Browser control. It seems to me the rendering internally needs to be delayed until navigation starts. But I guess the control could be not visible internally until the navigation has started.

You're probably right I could handle this with InitializeAsync() but do we really want to require that for every application to do that especially since it's not very obvious where the grey render comes from?

@TooYoungTooSimp
Copy link

Same problem.
I tried

public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            webView.Initialized += (s, e) =>
            {
                MessageBox.Show("inited");
            };
            webView.NavigationStarting += (s, e) =>
            {
                MessageBox.Show("start navigate");
            };
        }
    }

and neither msgbox shows.
It just keeps a grey window like above.

@chriswhitehead
Copy link

+1 the load is noticeably ~1 second too slow, and the grey on load is jarring when trying to ensure a seamless experience. In fact this led me to abandon moving forward for now with testing the control in an existing project.

@billhenn
Copy link

I was just experimenting with WebView2 in a new WPF app I'm writing and came across the same thing. My app is in a dark theme and when loading WebView2, I see a bright silver flicker which is very jarring before the actual content loads.

I agree that we need the control to be transparent until the first content is actually rendered, for this control to be serviceable in themed apps.

Another thing I noticed is that when you resize the control, even if the now-rendered HTML background is dark, you still see that silver flicker on the edges before rendering "catches up" to the new size. That also is extremely visually jarring and needs to be resolved.

If you can't fix this, then maybe at least give us the ability to set the default background color to something other than this silver color. This way we could adjust it to match the rest of our app's theme and it wouldn't be nearly as noticeable.

@johna-ms
Copy link
Contributor

johna-ms commented Jan 12, 2021

EDIT: Actually, my API does not address this issue. Please disregard!

Left and deleted a comment last night because I wasn't sure I'd made the announcement at the appropriate time. Turns out I was fine so I'm reposting. For those who did, thanks for taking a look!

Hi all, I'm working on a background color API to address this. Would appreciate if any of you could take a look and give your feedback!

#809

@champnic
Copy link
Member

This should be fixed in the latest package, 1.0.781-prerelease. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants