Skip to content

[Problem/Bug]: Massive GDI (region) leak via RDP #5266

Open
@kirsan31

Description

@kirsan31

What happened?

Somewhere in January 2024 we suddenly started recording massive GDI leaks in our winforms app. After a more than a year of investigations we finally figured out that the problem is in webview2.
We have a form with only 3 controls SplitContainer, WebView2, ListView. It's displays release notes of new versions - simple html nothing special. Currently this is the only form that uses WebView2. When a new version comes out, we display this form. From the logs, we found out that during GDI leaks, this form was always open. No other form had such a dependency.
Next, to check, I disabled the initialization of WebView2 on this form (the control is present, but does not initialize). And for several months now we have not had a single leak.

That's what we have for now:

  • The leaking GDI objects are regions.

  • This is not managed leak - we have no leaking managed objects in dumps.

  • The leak is related to elements redraw because of regions of course and most of the time it's happens around rdp connect/disconnect.

  • Leaks are completely related to the RDP session; they occur during connection, disconnection and also when manipulating the RDP window; one of the leaks happened simply when minimizing the RDP window.

  • Leaks do not depend on the RDP client application.

  • Leaks do not depend on the client OS.

  • Two of our applications were launched - leaks were observed simultaneously in both.

  • It feels like absolutely everything related to redrawing is starting to leak. Moreover, this is not a constant process - not every connection/disconnect/change in the RDP window entails a leak.

  • Updating WebView2 package to latest version not fix the problem.

  • We subscribed to all possible events (updates, errors, etc.) from WebView2 - no clues before or during leaks. See a screen and description below.

  • This is not specific PC bug. On other PC with Win 10 pro we have same problems.

  • There is a high probability that this is a OS wide problem. Because after leaks started and we take no actions for some time. The PC interface starts to visibly slow down over RDP. And in applications event log such records appear:

    • Event ID 1001, Event Name: GDIObjectLeak, Problem signature: P1: explorer.exe
    • Event ID 1000, Faulting application name: Explorer.EXE, Faulting module name: KERNELBASE.dll.

    Rebooting fix the problems till next leaks.

  • Since at the time when the problems started (start of 2024) we was not updating the WebView2 package, then most likely the problems started after one of WebView2 runtime auto updates.

Every time when leak happens WebView2 on the form was like it hangs - gray out and not working without any errors:

Image

On the screen above you must see a release notes when clicking on nodes in the list. But WebView2 in this case will always be gray out. As I pointed above no errors (or updates of WebView2 sdk/runtime) in the log for all period of time. Close and open the form will fix this problem.

Original WinForms issue (with some technical details): dotnet/winforms#11334

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

Problems started somewhere in January 2024.

SDK Version

any

Framework

Winforms

Operating System

Windows 10

OS Version

Windows 10 Pro for Workstations 22H2 and Windows 10 Pro 10.0.19045

Repro steps

Can't create a repro :(

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

Regression in newer Runtime

Last working version (if regression)

Problems started somewhere in January 2024.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingregressionSomething used to work but doesn't anymoretrackedWe are tracking this work internally.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions