DrawTargetWebgl's PathCache can keep SourceSurfaces alive even when they aren't used
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox101 | --- | fixed |
People
(Reporter: lsalzman, Assigned: lsalzman)
Details
Attachments
(1 file)
The PathCache in DrawTargetWebgl uses Patterns are part of the keys for cache entries. Since a SurfacePattern holds a strong reference via RefPtr to a SourceSurface, if it is the only reference to that SourceSurface, it will keep it alive, even though there is no other external way to construct SurfacePattern that would ever point to the same SourceSurface.
| Assignee | ||
Comment 1•3 years ago
|
||
Currently calling Pattern::Clone() produces a heap-allocated Pattern with RefPtrs
to any internal resources such as SourceSurfaces or GradientStops. While this is
okay if the Pattern is transient, this causes problems if the clone is long-lived
and causes via the RefPtr the stored resource to stay alive, even when there are
no other external references to the resource.
In the case of DrawTargetWebgl's PathCache, we need to be able to create Pattern
clones that have internal weak references, while also still supporting the original
use-case of strong references. To this end we template-ize some of the Pattern
derivatives so that we can make either strong or weak versions according to use-case.
This case way we store a weak clone of a Pattern in the PathCache key, the reference
will automatically invalidate itself when all other external strong references to it
go away, without having to do external crawling of the PathCache to constantly prune
the last reference manually.
Comment 3•3 years ago
|
||
| bugherder | ||
Description
•