haikuwebkit/LayoutTests/css3
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
..
background Subpixel rendering: Move background images to device pixel boundaries. 2014-04-04 16:30:18 +00:00
blending WebKit doesn't parse "#" as delimiter for fragment identifier in data URIs 2020-10-05 19:36:22 +00:00
calc calc() simplification for a multiplication should apply the multiplication to each value of an addition 2021-04-15 21:07:13 +00:00
color
color-filters Runtime-disabled CSS features still appear enabled via CSS.supports() 2021-02-24 16:45:08 +00:00
filters REGRESSION (Safari 15): Unable to repaint canvases with software filters when GPU Process is enabled 2021-08-02 17:44:26 +00:00
flexbox Place vertical scrollbars at (inline/block)-end edge in all writing modes. 2021-04-16 23:55:14 +00:00
images
masking Make RenderLayer::hitTestLayer not assume its renderer is a RenderBox 2021-06-17 00:27:58 +00:00
resources [LayoutTests] Delete unused LayoutTests/css3 resources 2021-06-11 23:22:59 +00:00
scroll-snap [css-scroll-snap] Triggering a layout during scroll causes jittery scrolling on Mac when dragging the scrollbar 2021-07-05 09:21:05 +00:00
support
touch-action Many CSS js-tests use waitUntilDone 2017-05-19 21:19:00 +00:00
viewport-percentage-lengths font-size with viewport units in calc() doesn't change when viewport resizes 2021-04-17 01:08:45 +00:00
autoclose-braces-and-parentheses-expected.txt Autoclose braces and parentheses at the end of style sheet 2013-06-11 07:10:00 +00:00
autoclose-braces-and-parentheses.html Autoclose braces and parentheses at the end of style sheet 2013-06-11 07:10:00 +00:00
bdi-element-expected.html REGRESSION(r101949): css3/bdi-element.html fails on Lion 2011-12-05 23:57:28 +00:00
bdi-element.html [BiDi] Add support for the BDI element 2011-09-09 00:34:59 +00:00
calculated-word-spacing-expected.txt ASSERTION NOT REACHED because RenderStyle::setWordSpacing() does not handle a Length value of type 'Calculated'. 2014-10-30 03:27:24 +00:00
calculated-word-spacing.html ASSERTION NOT REACHED because RenderStyle::setWordSpacing() does not handle a Length value of type 'Calculated'. 2014-10-30 03:27:24 +00:00
css-supports-document-parser-context-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
css-supports-document-parser-context.html CSS.supports("font-variation-settings", "'wght' 500") erroneously returns false 2016-11-03 03:25:28 +00:00
css-variable-definition-expected.html Enable the CSSVariables setting in css-variable-definition.html test 2013-05-16 17:06:58 +00:00
css-variable-definition.html Enable the CSSVariables setting in css-variable-definition.html test 2013-05-16 17:06:58 +00:00
escape-dom-api-expected.txt WebKit has too much of its own UTF-8 code and should rely more on ICU's UTF-8 support 2019-05-01 17:33:03 +00:00
escape-dom-api.html Implement `CSS.escape` as per CSSOM 2016-08-25 02:40:55 +00:00
font-feature-font-face-local-expected.html [iOS] Fast and complex text codepaths disagree about how to lay out bopomofo with tone marks 2019-07-21 17:23:54 +00:00
font-feature-font-face-local.html [iOS] Fast and complex text codepaths disagree about how to lay out bopomofo with tone marks 2019-07-21 17:23:54 +00:00
font-feature-settings-calc-expected.html Support calc() in font-variation-settings and font-feature-settings 2017-05-23 06:03:24 +00:00
font-feature-settings-calc.html Support calc() in font-variation-settings and font-feature-settings 2017-05-23 06:03:24 +00:00
font-feature-settings-font-face-rendering-expected.html font-variant-* properties in @font-face declarations should be honored 2015-11-03 20:31:33 +00:00
font-feature-settings-font-face-rendering.html font-variant-* properties in @font-face declarations should be honored 2015-11-03 20:31:33 +00:00
font-feature-settings-parsing-expected.txt Omit default value when serializing font-feature-settings 2018-04-20 12:08:45 +00:00
font-feature-settings-parsing.html Omit default value when serializing font-feature-settings 2018-04-20 12:08:45 +00:00
font-feature-settings-rendering-expected.html Test font-variant-* and font-feature-settings on Yosemite and Mavericks 2015-10-12 19:00:47 +00:00
font-feature-settings-rendering.html Test font-variant-* and font-feature-settings on Yosemite and Mavericks 2015-10-12 19:00:47 +00:00
font-feature-settings-stylistic-set-expected-mismatch.html [Cocoa] Use OTF font features instead of AAT font features when possible 2020-09-16 13:45:53 +00:00
font-feature-settings-stylistic-set.html [Cocoa] Use OTF font features instead of AAT font features when possible 2020-09-16 13:45:53 +00:00
font-synthesis-small-caps-expected.html [Cocoa] Implement font-synthesis: small-caps 2016-12-15 22:12:21 +00:00
font-synthesis-small-caps.html [Cocoa] Implement font-synthesis: small-caps 2016-12-15 22:12:21 +00:00
font-variant-all-expected.html font-variant-caps does not work if the font does not support font features 2015-12-10 08:37:03 +00:00
font-variant-all.html font-variant-caps does not work if the font does not support font features 2015-12-10 08:37:03 +00:00
font-variant-font-face-override-expected.html Remove font-variant @font-face descriptor 2019-11-22 03:56:06 +00:00
font-variant-font-face-override.html Remove font-variant @font-face descriptor 2019-11-22 03:56:06 +00:00
font-variant-parsing-expected.txt CSSOM test for serializing font-variant fails 2021-06-21 18:18:55 +00:00
font-variant-parsing.html CSSOM test for serializing font-variant fails 2021-06-21 18:18:55 +00:00
font-variant-petite-caps-synthesis-expected.html [Font Features] TrueType fonts trigger real features even when synthesis is applied 2015-12-15 21:55:34 +00:00
font-variant-petite-caps-synthesis.html [Font Features] TrueType fonts trigger real features even when synthesis is applied 2015-12-15 21:55:34 +00:00
font-variant-small-caps-synthesis-expected.html [Font Features] TrueType fonts trigger real features even when synthesis is applied 2015-12-15 21:55:34 +00:00
font-variant-small-caps-synthesis.html [Font Features] TrueType fonts trigger real features even when synthesis is applied 2015-12-15 21:55:34 +00:00
font-variant-synthesis-jdaggett-expected.html Add John Daggett's font variant synthesis test 2016-05-20 00:59:41 +00:00
font-variant-synthesis-jdaggett.html Add John Daggett's font variant synthesis test 2016-05-20 00:59:41 +00:00
font-weight-expected.txt Match spec for font-weight: bolder|lighter 2014-10-22 11:16:39 +00:00
font-weight-multiple-selectors-expected.txt Match spec for font-weight: bolder|lighter 2014-10-22 11:16:39 +00:00
font-weight-multiple-selectors.html Match spec for font-weight: bolder|lighter 2014-10-22 11:16:39 +00:00
font-weight.html Match spec for font-weight: bolder|lighter 2014-10-22 11:16:39 +00:00
infinite-word-spacing-expected.txt Clamp wordSpacing percentage value. 2014-10-25 02:37:41 +00:00
infinite-word-spacing.html Clamp wordSpacing percentage value. 2014-10-25 02:37:41 +00:00
khtml-background-size-0x0-bmp-expected.txt
khtml-background-size-0x0-bmp.html Use testRunner instead of layoutTestController in css 1, css 2.1, and css3 tests 2012-06-11 18:23:57 +00:00
out-of-memory-in-css-tokenizer-expected.txt Add handling for a case of OOME in CSSTokenizer and CSSParser. 2020-06-30 21:17:01 +00:00
out-of-memory-in-css-tokenizer.html Add handling for a case of OOME in CSSTokenizer and CSSParser. 2020-06-30 21:17:01 +00:00
overwrite-content-alignment-expected.txt [css-align] 'overflow' keyword must precede the self-position and content-position value 2018-01-22 17:01:51 +00:00
overwrite-content-alignment.html [css-align] 'overflow' keyword must precede the self-position and content-position value 2018-01-22 17:01:51 +00:00
overwrite-self-alignment-expected.txt [css-align] 'overflow' keyword must precede the self-position and content-position value 2018-01-22 17:01:51 +00:00
overwrite-self-alignment.html [css-align] 'overflow' keyword must precede the self-position and content-position value 2018-01-22 17:01:51 +00:00
parse-align-content-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
parse-align-content.html [css-align] The 'baseline' value must be invalid for the 'justify-content' property 2018-01-30 16:03:14 +00:00
parse-align-items-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
parse-align-items.html [css-align] 'left' and 'right' should parse as invalid in block/cross-axis alignment 2018-01-23 20:30:21 +00:00
parse-align-self-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
parse-align-self.html [css-align] 'left' and 'right' should parse as invalid in block/cross-axis alignment 2018-01-23 20:30:21 +00:00
parse-alignment-of-root-elements-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
parse-alignment-of-root-elements.html [css-align] Implement the new behavior of 'legacy' for justify-items 2018-02-09 14:57:12 +00:00
parse-justify-content-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
parse-justify-content.html [css-align] The 'baseline' value must be invalid for the 'justify-content' property 2018-01-30 16:03:14 +00:00
parse-place-content-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
parse-place-content.html [css-align] The 'baseline' value must be invalid for the 'justify-content' property 2018-01-30 16:03:14 +00:00
parse-place-items-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
parse-place-items.html [css-align] Implement the new behavior of 'legacy' for justify-items 2018-02-09 14:57:12 +00:00
parse-place-self-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
parse-place-self.html [css-align][css-flex][css-grid] 'auto' values of align-self and justify-self must not be resolved 2017-07-10 23:56:21 +00:00
parsing-css3-nthchild-expected.txt LayoutTests/imported/w3c: 2019-10-28 04:49:52 +00:00
parsing-css3-nthchild.html LayoutTests/imported/w3c: 2019-10-28 04:49:52 +00:00
style-zoomed-image-expected.txt
style-zoomed-image.html Use testRunner instead of layoutTestController in css 1, css 2.1, and css3 tests 2012-06-11 18:23:57 +00:00
supports-crash-expected.txt The bison grammar for @supports should return 0 in case of an error 2013-04-30 17:18:59 +00:00
supports-crash.html The bison grammar for @supports should return 0 in case of an error 2013-04-30 17:18:59 +00:00
supports-cssom-expected.txt DOMException should not have its own toString() 2017-07-19 20:24:15 +00:00
supports-cssom.html [CSS Parser] Stop skipping tests in the css3 LayoutTests subdirectory 2016-12-08 02:01:30 +00:00
supports-dom-api-expected.txt [css-conditional] The one-string version of CSS.supports should be wrapped in implied parentheses. 2017-06-06 18:27:53 +00:00
supports-dom-api.html [css-conditional] The one-string version of CSS.supports should be wrapped in implied parentheses. 2017-06-06 18:27:53 +00:00
supports-expected.txt Handle custom identifiers and strings separately, so we can quote strings correctly consistently 2021-06-07 02:39:33 +00:00
supports-not-selector-cssom-expected.txt REGRESSION: CSS not() selector does not work when it appears after or within @supports 2014-08-21 20:29:43 +00:00
supports-not-selector-cssom.html REGRESSION: CSS not() selector does not work when it appears after or within @supports 2014-08-21 20:29:43 +00:00
supports-not-selector-expected.html REGRESSION: CSS not() selector does not work when it appears after or within @supports 2014-08-21 20:29:43 +00:00
supports-not-selector.html REGRESSION: CSS not() selector does not work when it appears after or within @supports 2014-08-21 20:29:43 +00:00
supports.html Handle custom identifiers and strings separately, so we can quote strings correctly consistently 2021-06-07 02:39:33 +00:00
unicode-bidi-insolate-parse-expected.txt 2011-03-29 Eric Seidel <eric@webkit.org> 2011-03-29 08:55:16 +00:00
unicode-bidi-insolate-parse.html Change LayoutTests' c* files to use pre and post js files in LayoutTests/resources. 2013-09-08 02:07:30 +00:00
unicode-bidi-isolate-aharon-expected.html
unicode-bidi-isolate-aharon-failing-expected.html Convert isolate and plaintext tests to reftests 2011-12-04 08:28:17 +00:00
unicode-bidi-isolate-aharon-failing.html Convert isolate and plaintext tests to reftests 2011-12-04 08:28:17 +00:00
unicode-bidi-isolate-aharon.html Convert isolate and plaintext tests to reftests 2011-12-04 08:28:17 +00:00
unicode-bidi-isolate-basic.html Improve multicol intrinsic width calculation 2013-08-27 23:17:15 +00:00
zoom-coords-expected.txt css3/zoom-coords.xml failing after http://trac.webkit.org/changeset/114811 2012-04-23 17:42:19 +00:00
zoom-coords.xhtml Change LayoutTests' c* files to use pre and post js files in LayoutTests/resources. 2013-09-08 02:07:30 +00:00