haikuwebkit/LayoutTests/css3/filters
Wenson Hsieh 08017a6bbb REGRESSION (Safari 15): Unable to repaint canvases with software filters when GPU Process is enabled
https://bugs.webkit.org/show_bug.cgi?id=228682
rdar://79699997

Reviewed by Simon Fraser.

Source/WebCore:

In the case where GPU process is enabled for canvas rendering but is not enabled for DOM rendering, canvas
elements with software CSS filters fail to repaint as the canvas' backing image buffer changes. In this
particular scenario, we first paint the canvas' remotely-backed image buffer into the filter's input buffer,
which is backed by an unaccelerated graphics context. The filter is then applied, producing an output image
buffer which we then paint into the page. The bug occurs during the initial step of painting the contents of the
canvas' remote image buffer into the filter's input context, which involves creating a CGImageRef from the
`ImageBufferCGBackend::draw`.

When asking for a CGImageRef from the canvas' image buffer (which is backed by an IOSurface that's drawn into in
the GPU process), QuartzCore caches the resulting CGImageRef corresponding to the IOSurface handle in the web
process. Subsequently, when we try to repaint the canvas, we'll end up using this same initial cached CGImageRef
because the graphics context of the IOSurface handle in the web process hasn't been drawn into (because all the
actual draw calls are made in the GPU process). As such, regardless of the current state of the canvas' image
buffer, the input to the filter will always be the initial native image created from the canvas' image buffer.

We avoid this problem when GPU process is disabled because the calls to update the canvas' 2D context in the
web process will clear out the cached CGImageRef in QuartzCore. Additionally, we avoid this problem when drawing
into accelerated contexts because QuartzCore will draw the cached CGImageRef using a codepath that reads back
the up-to-date contents from the IOSurface. However, in the QuartzCore's unaccelerated (ripc) image drawing
codepath, we copy the contents of the cached image right away, causing us to end up with stale image data that
does not reflect the current state of the IOSurface.

To work around this in Safari 15 (in both Monterey as well as downlevel versions of macOS), we deploy a similar
technique as we'd previously used in r201334 to invalidate QuartzCore's cached image, but only:

1. If the seed value of the backing IOSurface has changed since the last time we've drawn the image buffer, and
2. The destination context we're painting the image buffer into is unaccelerated.

Test: css3/filters/canvas-with-filter-after-repaint.html

* platform/graphics/cg/ImageBufferCGBackend.cpp:
(WebCore::ImageBufferCGBackend::draw):
(WebCore::ImageBufferCGBackend::drawPattern):

Call into `prepareToDrawIntoContext` (see below).

* platform/graphics/cg/ImageBufferCGBackend.cpp:
(WebCore::ImageBufferCGBackend::prepareToDrawIntoContext):
* platform/graphics/cg/ImageBufferCGBackend.h:
* platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
(WebCore::ImageBufferIOSurfaceBackend::prepareToDrawIntoContext):

Add a new subclassable method on ImageBufferCGBackend that's invoked before drawing the contents of the image
buffer into a given destination GraphicsContext. We use this opportunity in ImageBufferIOSurfaceBackend to
notice if the IOSurface seed count has updated since we've last drawn the image buffer, and intentionally emit a
no-op drawing command (i.e. filling an empty rect) in the graphics context to invalidate QuartzCore's cached
CGImageRef. Note that we only deploy this workaround when drawing into unaccelerated contexts (see above for
more details).

(WebCore::ImageBufferIOSurfaceBackend::invalidateCachedNativeImage const):

Pull the no-op drawing command out into a separate helper method, with a comment describing why this exists.

(WebCore::ImageBufferIOSurfaceBackend::drawConsuming):
(WebCore::ImageBufferIOSurfaceBackend::copyCGImageForEncoding const):
* platform/graphics/cg/ImageBufferIOSurfaceBackend.h:
* platform/graphics/cocoa/IOSurface.h:
* platform/graphics/cocoa/IOSurface.mm:
(WebCore::IOSurface::seed const):

Add a helper method to grab the seed value of an IOSurface.

LayoutTests:

* css3/filters/canvas-with-filter-after-repaint-expected.html: Added.
* css3/filters/canvas-with-filter-after-repaint.html: Added.


Canonical link: https://commits.webkit.org/240170@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-02 17:44:26 +00:00
..
backdrop Add a mechanism to dump the PlatformCALayer subtree of a GraphicsLayer, for testing 2021-04-15 23:32:04 +00:00
resources
add-filter-rendering-expected.png
add-filter-rendering-expected.txt
add-filter-rendering.html
animation-from-initial-values-with-color-matrix-expected.html
animation-from-initial-values-with-color-matrix.html
blur-clipped-by-ancestor-expected.html
blur-clipped-by-ancestor.html
blur-clipped-with-overflow-expected.html
blur-clipped-with-overflow.html
blur-filter-page-scroll-expected.txt
blur-filter-page-scroll-parents-expected.txt
blur-filter-page-scroll-parents.html
blur-filter-page-scroll-self-expected.txt
blur-filter-page-scroll-self.html
blur-filter-page-scroll.html
blur-various-radii-expected.html
blur-various-radii.html
canvas-with-filter-after-repaint-expected.html REGRESSION (Safari 15): Unable to repaint canvases with software filters when GPU Process is enabled 2021-08-02 17:44:26 +00:00
canvas-with-filter-after-repaint.html REGRESSION (Safari 15): Unable to repaint canvases with software filters when GPU Process is enabled 2021-08-02 17:44:26 +00:00
clipping-overflow-scroll-with-pixel-moving-effect-on-expected.html
clipping-overflow-scroll-with-pixel-moving-effect-on-parent-expected.html
clipping-overflow-scroll-with-pixel-moving-effect-on-parent.html
clipping-overflow-scroll-with-pixel-moving-effect-on.html
color-interpolation-filters-expected.html
color-interpolation-filters.html
composited-during-animation-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
composited-during-animation-layertree-expected.txt [GTK] Test css3/filters/composited-during-animation-layertree.html is flaky since r214292 2021-06-11 12:00:15 +00:00
composited-during-animation-layertree.html
composited-during-animation.html
composited-during-transition-layertree.html
composited-reflected-expected.png
composited-reflected-expected.txt
composited-reflected.html
crash-filter-animation-invalid-url-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
crash-filter-animation-invalid-url.html
crash-filter-change-expected.png
crash-filter-change-expected.txt
crash-filter-change.html
crash-hw-sw-switch-expected.txt
crash-hw-sw-switch.html
crash-invalid-url-expected.txt
crash-invalid-url.html
css-opacity-with-drop-shadow-expected.html
css-opacity-with-drop-shadow.html
drop-shadow-blur-radius-expected-mismatch.html
drop-shadow-blur-radius.html
drop-shadow-expected.html
drop-shadow-with-overflow-hidden-expected.html
drop-shadow-with-overflow-hidden.html
drop-shadow.html
effect-blur-expected.png
effect-blur-expected.txt
effect-blur-hw-expected.png
effect-blur-hw-expected.txt
effect-blur-hw.html
effect-blur.html
effect-brightness-clamping-hw.html
effect-brightness-clamping.html
effect-brightness-expected.png
effect-brightness-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-brightness-hw-expected.png
effect-brightness-hw-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-brightness-hw.html
effect-brightness-square-expected.html CoreImage Implementation of CSS Filters invert(), opacity(), brightness(), contrast() 2020-09-08 19:25:13 +00:00
effect-brightness-square.html CoreImage Implementation of CSS Filters invert(), opacity(), brightness(), contrast() 2020-09-08 19:25:13 +00:00
effect-brightness.html
effect-combined-expected.png
effect-combined-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-combined-hw-expected.png
effect-combined-hw-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-combined-hw.html
effect-combined.html
effect-contrast-expected.png
effect-contrast-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-contrast-hw-expected.png
effect-contrast-hw-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-contrast-hw.html
effect-contrast-square-expected.html CoreImage Implementation of CSS Filters invert(), opacity(), brightness(), contrast() 2020-09-08 19:25:13 +00:00
effect-contrast-square.html CoreImage Implementation of CSS Filters invert(), opacity(), brightness(), contrast() 2020-09-08 19:25:13 +00:00
effect-contrast.html
effect-drop-shadow-expected.png
effect-drop-shadow-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-drop-shadow-hw-expected.png
effect-drop-shadow-hw-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-drop-shadow-hw.html
effect-drop-shadow-negative-radius-expected.html
effect-drop-shadow-negative-radius.html
effect-drop-shadow.html
effect-grayscale-expected.png
effect-grayscale-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-grayscale-hw-expected.png
effect-grayscale-hw-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-grayscale-hw.html
effect-grayscale-square-expected.html CoreImage Implementation of SourceGraphic and saturate(), hue-rotate(), grayscale() and sepia() 2020-09-03 21:04:05 +00:00
effect-grayscale-square.html CoreImage Implementation of SourceGraphic and saturate(), hue-rotate(), grayscale() and sepia() 2020-09-03 21:04:05 +00:00
effect-grayscale.html
effect-hue-rotate-expected.png
effect-hue-rotate-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-hue-rotate-hw-expected.png
effect-hue-rotate-hw-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-hue-rotate-hw.html
effect-hue-rotate-square-expected.html CoreImage Implementation of SourceGraphic and saturate(), hue-rotate(), grayscale() and sepia() 2020-09-03 21:04:05 +00:00
effect-hue-rotate-square.html CoreImage Implementation of SourceGraphic and saturate(), hue-rotate(), grayscale() and sepia() 2020-09-03 21:04:05 +00:00
effect-hue-rotate.html
effect-invert-expected.png
effect-invert-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-invert-hw-expected.png
effect-invert-hw-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-invert-hw.html
effect-invert-square-expected.html CoreImage Implementation of CSS Filters invert(), opacity(), brightness(), contrast() 2020-09-08 19:25:13 +00:00
effect-invert-square.html CoreImage Implementation of CSS Filters invert(), opacity(), brightness(), contrast() 2020-09-08 19:25:13 +00:00
effect-invert.html
effect-opacity-expected.png
effect-opacity-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-opacity-hw-expected.png
effect-opacity-hw-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-opacity-hw.html
effect-opacity-square-expected.html CoreImage Implementation of CSS Filters invert(), opacity(), brightness(), contrast() 2020-09-08 19:25:13 +00:00
effect-opacity-square.html CoreImage Implementation of CSS Filters invert(), opacity(), brightness(), contrast() 2020-09-08 19:25:13 +00:00
effect-opacity.html
effect-reference-after-expected.html
effect-reference-after.html
effect-reference-composite-hw.html
effect-reference-composite.html
effect-reference-delete-crash-expected.txt
effect-reference-delete-crash.html
effect-reference-delete-expected.html
effect-reference-delete.html
effect-reference-expected.txt
effect-reference-external-expected.txt
effect-reference-external.html
effect-reference-hw-expected.txt
effect-reference-hw.html
effect-reference-local-url-with-base-expected.html
effect-reference-local-url-with-base.html
effect-reference-ordering-hw.html
effect-reference-ordering.html
effect-reference-removed-while-pending-resources-expected.html
effect-reference-removed-while-pending-resources.html
effect-reference-rename-expected.html
effect-reference-rename.html
effect-reference-reset-style-delete-crash-expected.txt
effect-reference-reset-style-delete-crash.html
effect-reference.html
effect-saturate-expected.png
effect-saturate-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-saturate-hw-expected.png
effect-saturate-hw-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-saturate-hw.html
effect-saturate-square-expected.html CoreImage Implementation of SourceGraphic and saturate(), hue-rotate(), grayscale() and sepia() 2020-09-03 21:04:05 +00:00
effect-saturate-square.html CoreImage Implementation of SourceGraphic and saturate(), hue-rotate(), grayscale() and sepia() 2020-09-03 21:04:05 +00:00
effect-saturate.html
effect-sepia-expected.png
effect-sepia-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-sepia-hw-expected.png
effect-sepia-hw-expected.txt [LFC][Integration] Enable inline image support 2020-11-09 21:41:43 +00:00
effect-sepia-hw.html
effect-sepia-square-expected.html CoreImage Implementation of SourceGraphic and saturate(), hue-rotate(), grayscale() and sepia() 2020-09-03 21:04:05 +00:00
effect-sepia-square.html CoreImage Implementation of SourceGraphic and saturate(), hue-rotate(), grayscale() and sepia() 2020-09-03 21:04:05 +00:00
effect-sepia.html
filter-animation-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
filter-animation-from-none-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
filter-animation-from-none-hw-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
filter-animation-from-none-hw.html
filter-animation-from-none-multi-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
filter-animation-from-none-multi-hw-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
filter-animation-from-none-multi-hw.html
filter-animation-from-none-multi.html
filter-animation-from-none.html
filter-animation-hw-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
filter-animation-hw.html
filter-animation-multi-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
filter-animation-multi-hw-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
filter-animation-multi-hw.html
filter-animation-multi.html
filter-animation.html
filter-change-repaint-composited-expected.png
filter-change-repaint-composited-expected.txt
filter-change-repaint-composited.html
filter-change-repaint-expected.png
filter-change-repaint-expected.txt
filter-change-repaint.html
filter-empty-element-crash-expected.txt
filter-empty-element-crash.html
filter-is-on-subpixel-position-expected.html
filter-is-on-subpixel-position.html
filter-mask-clip-order-expected.html
filter-mask-clip-order.html
filter-on-overflow-hidden-expected.html
filter-on-overflow-hidden.html
filter-property-computed-style-expected.txt
filter-property-computed-style.html
filter-property-expected.txt
filter-property-parsing-expected.txt [WebIDL] Interface prototype objects should define @@toStringTag 2020-05-01 09:48:33 +00:00
filter-property-parsing-invalid-expected.txt
filter-property-parsing-invalid.html
filter-property-parsing.html [WebIDL] Interface prototype objects should define @@toStringTag 2020-05-01 09:48:33 +00:00
filter-property.html
filter-region-expected.png
filter-region-expected.txt
filter-region.html
filter-repaint-blur-expected.png
filter-repaint-blur-expected.txt
filter-repaint-blur.html
filter-repaint-child-layers-expected.png
filter-repaint-child-layers-expected.txt
filter-repaint-child-layers.html
filter-repaint-composited-fallback-crash-expected.png
filter-repaint-composited-fallback-crash-expected.txt
filter-repaint-composited-fallback-crash.html
filter-repaint-composited-fallback-expected.png
filter-repaint-composited-fallback-expected.txt
filter-repaint-composited-fallback.html
filter-repaint-expected.png
filter-repaint-expected.txt
filter-repaint-sepia-expected.png
filter-repaint-sepia-expected.txt
filter-repaint-sepia.html
filter-repaint-shadow-clipped-expected.png
filter-repaint-shadow-clipped-expected.txt
filter-repaint-shadow-clipped.html
filter-repaint-shadow-expected.png
filter-repaint-shadow-expected.txt
filter-repaint-shadow-layer-child-expected.html
filter-repaint-shadow-layer-child.html
filter-repaint-shadow-rotated-expected.png
filter-repaint-shadow-rotated-expected.txt
filter-repaint-shadow-rotated.html
filter-repaint-shadow.html
filter-repaint.html
filter-with-opacity-and-children-expected.txt
filter-with-opacity-and-children.html
filter-with-transform-expected.png
filter-with-transform-expected.txt
filter-with-transform.html
filtered-compositing-descendant-expected.png
filtered-compositing-descendant-expected.txt
filtered-compositing-descendant.html
filtered-inline-expected.png
filtered-inline-expected.txt
filtered-inline.html
filters-on-svg-element-expected.html
filters-on-svg-element.html
filters-on-svg-root-expected.html
filters-on-svg-root.html
hidpi-feConvolveMatrix-expected.html
hidpi-feConvolveMatrix.html
hidpi-feDisplacementMap-expected.html
hidpi-feDisplacementMap.html
hidpi-filter-is-on-subpixel-position-expected.html
hidpi-filter-is-on-subpixel-position.html
huge-blur-value-expected.txt
huge-blur-value.html
huge-region-composited-expected.txt
huge-region-composited.html
huge-region-expected.txt
huge-region.html
invalid-reference-filter-expected.html SVG reference filter chain with errors applies only some of the filters, producing incorrect output 2021-01-25 00:28:45 +00:00
invalid-reference-filter-in-chain-expected.html SVG reference filter chain with errors applies only some of the filters, producing incorrect output 2021-01-25 00:28:45 +00:00
invalid-reference-filter-in-chain.html SVG reference filter chain with errors applies only some of the filters, producing incorrect output 2021-01-25 00:28:45 +00:00
invalid-reference-filter.html SVG reference filter chain with errors applies only some of the filters, producing incorrect output 2021-01-25 00:28:45 +00:00
invalidate-sourceAlpha-expected.html
invalidate-sourceAlpha.html
large-background-size-crash-expected.txt Null check CSSFilter::output() 2021-01-12 09:34:57 +00:00
large-background-size-crash.html Null check CSSFilter::output() 2021-01-12 09:34:57 +00:00
multiple-filters-invalidation-expected.txt
multiple-filters-invalidation.html
nested-filter-expected.png
nested-filter-expected.txt
nested-filter.html
nested-filters-expected.png
nested-filters-expected.txt
nested-filters.html
null-effect-check-expected.html
null-effect-check.html
offscreen-filters-memory-usage-expected.txt
offscreen-filters-memory-usage.html
reference-filter-set-filter-regions-expected.html
reference-filter-set-filter-regions.html
reference-filter-update-on-attribute-change-expected.html
reference-filter-update-on-attribute-change.html
regions-expanding-expected.png
regions-expanding-expected.txt
regions-expanding.html
remove-filter-rendering-expected.png
remove-filter-rendering-expected.txt
remove-filter-rendering.html
remove-filter-repaint-expected.html
remove-filter-repaint.html
should-not-have-compositing-layer-expected.txt
should-not-have-compositing-layer.html
simple-filter-rendering-expected.png
simple-filter-rendering-expected.txt
simple-filter-rendering.html
svg-blur-filter-clipped-expected.html Outsets for referenced SVG filters are always zero 2019-10-15 02:00:37 +00:00
svg-blur-filter-clipped.html Outsets for referenced SVG filters are always zero 2019-10-15 02:00:37 +00:00
unprefixed-expected.txt
unprefixed.html