Repository navigation
fix: free a hidden plugin's graphics devices while its panel isn't showing - #43
Merged
Merged
Conversation
…owing Each WebView2CompositionControl builds a Direct3D image of its own to copy its page's frames into WPF: a D3D11 device, a D3D9Ex device and a capture session. That costs this process about 80 MB, 66 threads and 1,700 handles for every view, including the 2x2 invisible ones of parked plugins. A parked plugin's view now disposes that image and builds it again when its panel is shown. The page keeps running, visible to itself, at full timer speed. Measured with 7 plugins hosted by the real WebPlugin, all parked: before 663 MB private, 481 threads, 13,808 handles after 143 MB private, 33 threads, 2,328 handles (the same window with no plugins: 146 MB, 20 threads, 2,093 handles)
CodySimonds65
added a commit
that referenced
this pull request
Oct 7, 2026
fix: free a hidden plugin's graphics devices while its panel isn't showing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A community plugin whose panel isn't showing now costs the app process under 1 MB instead of about 80 MB. Plugins keep running while hidden: they still receive events and update their cards, and page timers run at full speed.
Why
Every
WebView2CompositionControlbuilds a Direct3D image of its own to copy its page's frames into WPF: a D3D11 device, a D3D9Ex device and a capture session, whatever the control's size. In the app process that is about 80 MB private, 66 threads and 1,700 handles per view, including the 2x2 invisible views of parked plugins. With 6-7 plugins the app sat above 1.2 GB and Windows logged a RADAR_PRE_LEAK_64 warning.How
In
WebPlugin, a parked view disposes that image and builds it again when its panel is shown.GC.Collect(). Without it the devices and their threads stay alive: 12 released views still held 405 threads a minute later.UnhookWindowClose. If a WebView2 SDK update renames them, the plugin refuses to start, so the lost saving is noticed at once.Options measured
Standalone WPF harness, 6 views each. The empty window is 150 MB / 24 threads / 2,099 handles.
CoreWebView2Controller.IsVisible = falserequestAnimationFramestopsMemoryUsageTargetLevel = LowIsVisible = falseand the low memory target save nothing in the app process. The windowless controller saves the same amount, but showing a panel would mean rewriting the control's rendering and input handling.Before and after
7 plugins hosted by the real
WebPluginclass in a harness window with a temp data folder.In every phase the slowest plugin's card updated at the full 2 events per second sent, and page timers ran at 20 per second. Screenshots confirmed a panel paints correctly after being hidden, including a page that wasn't changing. Hit-testing still reaches the web view; a real click was not sent.
Costs
Tests
None added: nothing here meets the real-damage bar. Core (323) and Desktop (37) suites pass. The 8 Leaderboard store tests need Docker, which wasn't running locally.