dotnet / dotnet/maui

WPF WebView2CompositionControl - Latest state of blazor not being always shown/refreshed

Open
#35,494 5 comments 1 reaction 0 assignees View on GitHub
area-blazor blazor-webview2-regression platform/windows s/triaged s/verified t/bug
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 14h
Merged PRs (30d)
296

Description

### Description

We have application where we have hybrid of WPF controls and Blazor hosted via WebView2CompositionControl.

There seems to be random issue, I assume with D3DImage that's being used to copy WebView2 visual content to the WPF control. It looks as if latest frame from WebView2 is not being shown/refreshed in WPF control at some point.

I've attached repro project where it can be reproduced in quite stable manner, yet issue is quite random. There are 2 sets of 5 BlazorWebView controls showing the same value (red'ish background). There's also WPF label showing what values should be there (green background). Both sets of Blazor Components are switching over when clicking Toggle Visibility. There's Increment button which is incrementing value that is emitted by Reactive Subject class and subscribed in Blazor Component. That value should be the same in all of the controls. The issue is sometimes it's as if it's out of sync, or it shows previous state.

I've confirmed that DOM is being updated correctly. What's funniest, we have Blazor view with input and if that issue occurs while loading that view (meaning only spinner is shown before it loads fully) then mouse hovering over area where Input box supposed to be, it shows 'edit mouse icon' as if Input physically is under mouse cursor. Once clicked on that alleged Input, Blazor View is shown correctly. Hovering doesn't trigger refresh, clicking does in some parts.
Same with repro project, if value is incorrect, once component is clicked then value shown is correct. Note that Component doesn't have any click handling.

One more thing, I've noticed that if BitmapEffect is used by Parent control, then this issue is happening even without Visibility change, but it seems that latest version is making it harder to reproduce (I have noticed that on 10.0.1 at first, then moved to latest which is 10.0.60). I know that BitmapEffect is obsolete and shouldn't be used but I mention that in case it's going to help to narrow issue down.

### Steps to Reproduce

Build and run project (repro project)

1. Click 'Increment' button which will increment value of counter
2. Click 'Toggle Visibility' button which will switch to other set of BlazorWebView controls.

Do first and second step few times and notice that one or two of the values sometimes are out of sync.

### Link to public reproduction project repository

https://github.com/wgala-tomra/wv2-d3d-update-issue/tree/main/WvUpdateIssue

### Version with bug

10.0.60

### Is this a regression from previous behavior?

Not sure, did not test other versions

### Last version that worked well

_No response_

### Affected platforms

Windows

### Affected platform versions

Win11, Win10

### Did you find any workaround?

_No response_

### Relevant log output

```shell

```

Contributor guide

Open the contributing guide

Research direction

Start by building and running the linked WvUpdateIssue reproduction project on Windows with .NET MAUI 10.0.60. Repeat Increment and Toggle Visibility while comparing the five BlazorWebView values with the WPF label, then investigate the WebView2CompositionControl rendering path and the D3DImage behavior described in the issue. Done means every control consistently displays the latest value, including with a parent BitmapEffect.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.