Repository navigation
fix(2d): free GPU resources a canvas has stopped using (GL, Metal, Vulkan) - #193
Merged
Merged
Conversation
Skia's GPU resource cache on the GL path was never trimmed, so everything a canvas had ever drawn stayed in GPU memory up to Skia's 256 MB default. After each flush (at most once a second per canvas) the GL path now frees resources unused for 5 s, as the D3D path already does; Chrome trims the same way. Anything drawn every frame stays cached, so steady rendering pays nothing. In apps/demo-leak (8192 sprites from two sheets, then only one), the unused 8 MB sheet left the cache about 7 s after its last draw while the sheet still in use stayed.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
The 5 s trim moves from the GL surface to Context, so it runs after the flushes of GL, Metal and Vulkan canvases alike. D3D canvases keep their own (present_d3d). On an Android emulator (GL), an unused 8 MB sheet left the cache about 6 s after its last draw, as before. Metal and Vulkan are not exercised here: no iOS build, and Android only gives 2D a Vulkan context for Vulkan versions above 1.
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.
Skia's GPU resource cache was never trimmed on the GL, Metal and Vulkan paths. Everything a canvas had drawn stayed in GPU memory, up to Skia's 256 MB default.
After each flush (at most once a second per canvas), these canvases now free resources unused for 5 s, as the D3D path already does. Anything drawn every frame stays cached, so steady rendering pays nothing. A resource that comes back after more than 5 s unused is uploaded again. D3D canvases keep their own trim in
present_d3d.Verified
GL, on an Android emulator, with a temporary log of
resource_cache_usage()(not part of this PR): sprites drawn from two sheets, then from one. The unused 8 MB sheet left the cache about 6 s after its last draw, and the sheet still in use stayed.The emulator's process stats show no GPU memory, so the effect was checked through Skia's counter rather than
dumpsys meminfo.Not tested
Both reach the same code after their flushes.