[webkit-changes] [WebKit/WebKit] d08bfd: GraphicscContextCG uses memory redundantly for Sou...
Kimmo Kinnunen
noreply at github.com
Tue Jan 16 09:49:06 PST 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d08bfd77fc2346828b9fc49a9dd6e8a8bbc8e320
https://github.com/WebKit/WebKit/commit/d08bfd77fc2346828b9fc49a9dd6e8a8bbc8e320
Author: Kimmo Kinnunen <kkinnunen at apple.com>
Date: 2024-01-16 (Tue, 16 Jan 2024)
Changed paths:
M Source/WebCore/platform/graphics/GraphicsContextState.h
M Source/WebCore/platform/graphics/SourceBrush.cpp
M Source/WebCore/platform/graphics/SourceBrush.h
M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
Log Message:
-----------
GraphicscContextCG uses memory redundantly for SourceBrush
https://bugs.webkit.org/show_bug.cgi?id=267405
rdar://120841202
Reviewed by Said Abou-Hallawa.
SourceBrush would contain std::optional<std::variant<...>>.
This wastes quite a bit of memory to padding and redundant tag field.
Instead, store it just as variant<monostate, ...>
Also store the SourceBrush instances as the first instances,
as SourceBrush has alignof == 8 and ChangeFlags has sizeof == 4.
Before:
Total byte size: 800
Total pad bytes: 60
Padding percentage: 7.50 %
After:
Total byte size: 752
Total pad bytes: 62
Padding percentage: 8.24 %
Some, likely leaky, pages might create thousands of layers or 2d
contexts. GraphicscContextCG for these ImageBuffers end up taking
significant amount of memory, risking GPUP jetsams.
* Source/WebCore/platform/graphics/GraphicsContextState.h:
* Source/WebCore/platform/graphics/SourceBrush.cpp:
(WebCore::SourceBrush::SourceBrush):
(WebCore::SourceBrush::gradientSpaceTransform const):
(WebCore::SourceBrush::gradient const):
(WebCore::SourceBrush::gradientIdentifier const):
(WebCore::SourceBrush::pattern const):
(WebCore::SourceBrush::setGradient):
(WebCore::SourceBrush::setPattern):
* Source/WebCore/platform/graphics/SourceBrush.h:
(WebCore::SourceBrush::SourceBrush):
(WebCore::SourceBrush::patternGradient const):
(WebCore::SourceBrush::isInlineColor const):
(WebCore::SourceBrush::isVisible const):
(WebCore::SourceBrush::hasPatternOrGradient const):
(WebCore::operator==):
(WebCore::SourceBrush::brush const): Deleted.
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
Canonical link: https://commits.webkit.org/273073@main
More information about the webkit-changes
mailing list