MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Problem when changing WebView2 control’s parent visibility

Open
#1,094 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug priority-low tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Our development:
SDK: 1.0.705.50/1.0.774.44
Runtime: Canary 91.0.830.0 x64
Framework: .NET Core 3.1, WPF, x64
OS: Windows 10 Pro x64

We have simple problem when we change visibility of WebView2 control's parent with WebView2 and Edge Canary. In WPF we put Canvas on Grid and on Grid we have WebView2 control. Canvas has Visibility = Hidden, like below:

<Grid Background="Aqua">
    <Canvas Name="Can" Width="500" Height="500" Visibility="Hidden">
        <wpf:WebView2 Name="Web" Width="500" Height="500" />
    </Canvas>
</Grid>

After that we load sample HTML document, when application starts, Canvas is hidden:

public MainWindow()
{
    InitializeComponent();
    Web.Source = new Uri(AppDomain.CurrentDomain.BaseDirectory + "sample.html");
} 

After few seconds, we change Canvas Visibility to true:

Application.Current.Dispatcher.Invoke(() =>
{
    Can.Visibility = Visibility.Visible;
});

Our result:
https://pagspzoo-my.sharepoint.com/:i:/g/personal/lukasz_kozek_pag_com_pl/EabQlEZxS_lFjNZVeXvdIDkBtlQ4MglClzCnfSDpnNRGYQ

We don’t see HTML document, only gray field. When we minimize and maximize main window, HTML shows. Grey field we can see in 1.0.705.50 of WebView2 version.
When we upgarde this control to 1.0.774.44 version, we don’t see grey field, only Grid with Aqua color. We have the same situation like above, after minimize and maximize main window, HTML shows.

Below I share source of sample application. First, with older version WebView2 and grey field, and newest version.

Source with 1.0.705.50 (gray field)
https://pagspzoo-my.sharepoint.com/:u:/g/personal/lukasz_kozek_pag_com_pl/EQMNEObCCsZMmUzm7QztIQcBTxxgkLMRiEgDRuVDVWprkg?e=h8lHBf

Source with 1.0.774.44
https://pagspzoo-my.sharepoint.com/:u:/g/personal/lukasz_kozek_pag_com_pl/ESsadCGN0zJOpTB03KaJ0iYBCJ4LvjjbNwBDNUQ1zwpTqQ?e=GTx0Ns

Thank You for any advice.

AB#32255210

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied WPF XAML and MainWindow constructor, then reproduce the behavior when Canvas.Visibility changes through Dispatcher.Invoke. Compare WebView2 SDK versions 1.0.705.50 and 1.0.774.44, using the linked sample applications and sample.html. Done means the HTML renders after the parent becomes visible without minimizing and maximizing the window.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, html
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.