Fix artifacting issue with Edge WebView (PR #26566)

15 views
Skip to first unread message

Blake-Madden

unread,
Jun 6, 2026, 2:10:06 PM (2 days ago) Jun 6
to wx-...@googlegroups.com, Subscribed

When an Edge WebView is a child of a more complex control and that control is hidden and then reshown, artifacts from the old window will appear in the wxWebView. This fixes it by calling put_IsVisible when the parent is shown or hidden and also forces a repaint by updating the painting rect (this is the necessary part and the closest I could come to emulating an async refresh).

Here is an example of what I see with a wxWebView in a composite control inside of a split window when I select a different window and come back:

image.png (view on web)

What it should look like:

image.png (view on web)

Here is a reference to parent visibility issues with WebView2:

MicrosoftEdge/WebView2Feedback#1094

and maybe related:

https://groups.google.com/g/wx-dev/c/NoVbVMODDB4

P.S.

I have to use CallAfter here because of the async nature of WebView.


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/26566

Commit Summary

  • cf3b854 Fix artifacting issues with Edge WebView

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26566@github.com>

Blake-Madden

unread,
Jun 6, 2026, 2:17:05 PM (2 days ago) Jun 6
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 1 commit.


View it on GitHub or unsubscribe.


Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26566/before/cf3b854c8cd66b73c0aea80c783b316675ed184e/after/2814ffa1aa961db0c7767f0bad98a277d70703ba@github.com>

VZ

unread,
Jun 6, 2026, 6:29:16 PM (2 days ago) Jun 6
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.

This looks a bit ugly, but if this is the only way to fix the problem, let's do it...


In src/msw/webview_edge.cpp:

> @@ -1157,6 +1161,8 @@ bool wxWebViewEdge::Create(wxWindow* parent,
     wxWindow* topLevelParent = wxGetTopLevelParent(this);
     if (topLevelParent)
         topLevelParent->Bind(wxEVT_ICONIZE, &wxWebViewEdge::OnTopLevelParentIconized, this);
+    if (GetParent())

I think this is unnecessary as it should always have a parent, it shouldn't be possible to create it as a TLW.


In src/msw/webview_edge.cpp:

> @@ -1182,6 +1188,27 @@ void wxWebViewEdge::OnTopLevelParentIconized(wxIconizeEvent& event)
     event.Skip();
 }
 
+void wxWebViewEdge::OnParentShow(wxShowEvent& event)
+{
+    if ( m_impl && m_impl->m_webViewController )
+    {
+        m_impl->m_webViewController->put_IsVisible(event.IsShown());
+        // Force a refresh by refreshing its paint area
+        if ( event.IsShown() )
+        {
+            // put_Bounds is a no-op when the rect is unchanged, so collapse to

There is really no other way to force it to repaint?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26566/review/4443945094@github.com>

Blake-Madden

unread,
Jun 7, 2026, 6:29:35 AM (23 hours ago) Jun 7
to wx-...@googlegroups.com, Subscribed

@Blake-Madden commented on this pull request.


In src/msw/webview_edge.cpp:

> @@ -1157,6 +1161,8 @@ bool wxWebViewEdge::Create(wxWindow* parent,
     wxWindow* topLevelParent = wxGetTopLevelParent(this);
     if (topLevelParent)
         topLevelParent->Bind(wxEVT_ICONIZE, &wxWebViewEdge::OnTopLevelParentIconized, this);
+    if (GetParent())

Got, will remove. I tend to be overly pedantic.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26566/review/4444872384@github.com>

Blake-Madden

unread,
Jun 7, 2026, 6:34:24 AM (23 hours ago) Jun 7
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 2 commits.

  • 36ed3c1 Remove pedantic parent check
  • 79cc9c5 Remove other GetParent check


View it on GitHub or unsubscribe.


Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26566/before/2814ffa1aa961db0c7767f0bad98a277d70703ba/after/79cc9c520c9044675513ab906dce7d045f98c5a1@github.com>

Blake-Madden

unread,
Jun 7, 2026, 6:53:08 AM (22 hours ago) Jun 7
to wx-...@googlegroups.com, Subscribed

@Blake-Madden commented on this pull request.


In src/msw/webview_edge.cpp:

> @@ -1182,6 +1188,27 @@ void wxWebViewEdge::OnTopLevelParentIconized(wxIconizeEvent& event)
     event.Skip();
 }
 
+void wxWebViewEdge::OnParentShow(wxShowEvent& event)
+{
+    if ( m_impl && m_impl->m_webViewController )
+    {
+        m_impl->m_webViewController->put_IsVisible(event.IsShown());
+        // Force a refresh by refreshing its paint area
+        if ( event.IsShown() )
+        {
+            // put_Bounds is a no-op when the rect is unchanged, so collapse to

To my understanding, there is no "invalidate and refresh" mechanism that we can use because the rendering is taking place in a DirectComposition visual, not the HWND, so traditional repaint request methods aren't available:

https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/windowed-vs-visual-hosting

unoplatform/uno#22694

And the only other solutions are full reloads or complicated JScript:

https://weblog.west-wind.com/posts/2026/Feb/04/Reliably-Refreshing-the-WebView2-Control

Setting the drawing rect to {0,0} and then telling the control to get its drawing rect from the client forces it to see that its rendering area changed and should repaint. This seems to be the closest "invalidate and refresh" method that I can find and works well on Windows 11.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26566/review/4444914640@github.com>

Reply all
Reply to author
Forward
0 new messages