MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Control flicks a lot and cpu gets very high due to excessive paint messages - WS_EX_COMPOSITED

Open
#1,096 17 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description
Windows WM_PAINT messages are consecutively being sent (infinite loop) when the top parent window uses the WS_EX_COMPOSITED extended style.
The problem is demonstrated in this post:
https://stackoverflow.com/questions/65713336/c-sharp-excessive-repainting-of-webview2-control-after-applying-nativewinapi-sty/66678044#66678044
It has an Windows Forms simple example on how to reproduce.

I've answered it with a solution to avoid the flicker on the controls, but it doesn't avoid the paint messages infinite loop / high cpu; the solution was to set the DoubleBuffered property in all the form child controls.

Additionally and regarding the flicker effect, with the WS_EX_COMPOSITED style set in the top window and with the DoubleBuffered property in the child controls, in the versions that I've tested the WebView2 control from versions 1.0.664.37 and 1.0.705.50 doesn't flick, but from version 1.0.774.44 and more recent prereleases the controls flicks a lot, in all versions, the infinite paint messages and high cpu is always present.

I've no ideas on how to fix this, but I think it should be fixed on WebView2 control as it is the source of the paint messages infinite loop.

Version
SDK: 1.0.664.37 and beyond
Runtime: 89.0.774.57
Framework: WinForms
OS: Win Server 2019 v1809

Repro Steps
Use the example (ZIP) from the StackOverflow link above, optionally applying the solution from my answer (from António Cunha) to avoid the flicks on the other form controls.
With Spy++ it can be observed that WM_PAINT messages are always being triggered; high cpu can also be observed in Task Manager or in VS Diagnostic Tools pane.
I expect that the WebView2 control supports correctly a parent window with the WS_EX_COMPOSITED style.

Let me know if this problem is already known and when it is expected to be fixed.
I'm available to help as needed, as I'm with a bit urgency to deliver a feature in an application that will start using the WebView2 control.

Many Thanks,
António

AB#32255733

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 Windows Forms reproduction linked in the StackOverflow post and test it with the listed WebView2 SDK and Runtime versions. Use Spy++ and Task Manager or Visual Studio Diagnostic Tools to confirm the repeated WM_PAINT messages and high CPU with WS_EX_COMPOSITED. Done means the control no longer causes the paint loop or excessive CPU, while flicker is also addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.