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:
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.
https://github.com/wxWidgets/wxWidgets/pull/26566
(2 files)
—
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.![]()
@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.![]()
@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...
> @@ -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.
> @@ -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.![]()
@Blake-Madden commented on this pull request.
> @@ -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.![]()
@Blake-Madden pushed 2 commits.
—
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.![]()
> @@ -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
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.![]()