Bug 225907 - ASSERTION FAILED: m_imageBufferResult->colorSpace() == m_resultColorSpace in FilterEffect::copyPremultipliedResult
Summary: ASSERTION FAILED: m_imageBufferResult->colorSpace() == m_resultColorSpace in ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Fujii Hironori
URL:
Keywords: InRadar
Depends on: 225841
Blocks:
  Show dependency treegraph
 
Reported: 2021-05-17 22:52 PDT by Fujii Hironori
Modified: 2021-05-21 13:35 PDT (History)
8 users (show)

See Also:


Attachments
invalidate-sourceAlpha-crash-log.txt (WinCairo WK1 Debug) (71.55 KB, text/plain)
2021-05-17 23:05 PDT, Fujii Hironori
no flags Details
WIP patch (1.32 KB, patch)
2021-05-18 15:03 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
color-interpolation-filters-crash-log.txt (WinCairo WK1 Debug with attachment#428983) (352.94 KB, text/plain)
2021-05-19 13:52 PDT, Fujii Hironori
no flags Details
WIP patch (2.20 KB, patch)
2021-05-19 21:52 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
WIP patch (3.66 KB, patch)
2021-05-19 22:32 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (6.13 KB, patch)
2021-05-20 22:59 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 2021-05-17 22:52:09 PDT
ASSERTION FAILED: m_imageBufferResult->colorSpace() == m_resultColorSpace in FilterEffect::copyPremultipliedResult

WinCairo WK1/WK2 Debug

ASSERTION FAILED: m_imageBufferResult->colorSpace() == m_resultColorSpace
C:\home\webkit\gb\Source\WebCore\platform/graphics/filters/FilterEffect.cpp(547) : WebCore::FilterEffect::copyPremultipliedResult

  css3/filters/color-interpolation-filters.html [ Crash ]
  css3/filters/effect-reference.html [ Crash ]
  css3/filters/invalidate-sourceAlpha.html [ Crash ]
  css3/filters/reference-filter-set-filter-regions.html [ Crash ]
Comment 2 Fujii Hironori 2021-05-17 23:05:42 PDT
Created attachment 428914 [details]
invalidate-sourceAlpha-crash-log.txt (WinCairo WK1 Debug)
Comment 3 Fujii Hironori 2021-05-18 15:02:12 PDT
FilterEffect::transformResultColorSpace does nothing if USE(CG). It calls ImageBuffer::transformColorSpace otherwise.
https://github.com/WebKit/WebKit/blob/3de6f842827f19bb0b6de1068d88026e8868cf26/Source/WebCore/platform/graphics/filters/FilterEffect.cpp#L641

There are three problems.

1. ImageBuffer::colorSpace() returns the old color space even after ImageBuffer::transformColorSpace.
2. ImageBufferBackend::colorSpace() returns the old color space even after ImageBuffer::transformColorSpace.
3. convertImagePixels doesn't support color space conversion yet for USE(ACCELERATE) && USE(CG).
   https://github.com/WebKit/WebKit/blob/3de6f842827f19bb0b6de1068d88026e8868cf26/Source/WebCore/platform/graphics/PixelBufferConversion.cpp#L254
Comment 4 Fujii Hironori 2021-05-18 15:03:49 PDT
Created attachment 428983 [details]
WIP patch
Comment 5 Sam Weinig 2021-05-18 16:10:34 PDT
(In reply to Fujii Hironori from comment #3)
> 3. convertImagePixels doesn't support color space conversion yet for
> USE(ACCELERATE) && USE(CG).
>   
> https://github.com/WebKit/WebKit/blob/
> 3de6f842827f19bb0b6de1068d88026e8868cf26/Source/WebCore/platform/graphics/
> PixelBufferConversion.cpp#L254

Is convertImagePixels() actually being used for any color space conversions on non-CoreGraphics ports? My intent was that it wouldn't be, but I could have easily looked over something?

I think it would be great if we could converge on a single color space transformation tactic for both CoreGraphics and non-CoreGraphics platforms. I happen to like the CoreGraphics approach which is that ImageBuffers have a color space that is immutable, and if you want to change the color space, you draw into another ImageBuffer which has the right color space and the conversion is done during the drawing.
Comment 6 Fujii Hironori 2021-05-19 13:52:11 PDT
Created attachment 429094 [details]
color-interpolation-filters-crash-log.txt (WinCairo WK1 Debug with attachment#428983 [details])

(In reply to Sam Weinig from comment #5)
> Is convertImagePixels() actually being used for any color space conversions
> on non-CoreGraphics ports? My intent was that it wouldn't be, but I could
> have easily looked over something?

Even after comment#4 patch, the assertion in convertImagePixels fails by running css3/filters tests.

FEColorMatrix::platformApplySoftware is explicitly specifying DestinationColorSpace::SRGB.
https://github.com/WebKit/WebKit/blob/3de6f842827f19bb0b6de1068d88026e8868cf26/Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp#L288
Comment 7 Fujii Hironori 2021-05-19 21:52:03 PDT
Created attachment 429132 [details]
WIP patch
Comment 8 Fujii Hironori 2021-05-19 22:32:53 PDT
Created attachment 429137 [details]
WIP patch
Comment 9 Fujii Hironori 2021-05-20 18:18:43 PDT
Bug 226061 – [WinCairo] Disable DESTINATION_COLOR_SPACE_LINEAR_SRGB temporarily until Bug 225907 is fixed
Comment 10 Fujii Hironori 2021-05-20 22:59:48 PDT
Created attachment 429266 [details]
Patch
Comment 11 Said Abou-Hallawa 2021-05-20 23:12:34 PDT
Comment on attachment 429266 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429266&action=review

> Source/WebCore/platform/graphics/cairo/ImageBufferCairoBackend.cpp:103
> +    m_parameters.colorSpace = destColorSpace;
> +

This change suggests that transformColorSpace() should take only destColorSpace. I checked the callers of this function and I found they all pass the same colorSpace they used to create the ImageBuffer with. So I would suggest:
1. Change the name of this function to transformToColorSpace
2. Make it take only a newColorSpace.
Comment 12 Fujii Hironori 2021-05-20 23:21:38 PDT
Comment on attachment 429266 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429266&action=review

>> Source/WebCore/platform/graphics/cairo/ImageBufferCairoBackend.cpp:103
>> +
> 
> This change suggests that transformColorSpace() should take only destColorSpace. I checked the callers of this function and I found they all pass the same colorSpace they used to create the ImageBuffer with. So I would suggest:
> 1. Change the name of this function to transformToColorSpace
> 2. Make it take only a newColorSpace.

Sounds a good idea. But, I want to fix this crashing problem ASAP. Can I do that it as a separate patch?
Comment 13 Fujii Hironori 2021-05-21 13:17:39 PDT
Comment on attachment 429266 [details]
Patch

Clearing flags on attachment: 429266

Committed r277878 (238016@main): <https://commits.webkit.org/238016@main>
Comment 14 Fujii Hironori 2021-05-21 13:17:43 PDT
All reviewed patches have been landed.  Closing bug.
Comment 15 Radar WebKit Bug Importer 2021-05-21 13:18:22 PDT
<rdar://problem/78324805>
Comment 16 Fujii Hironori 2021-05-21 13:35:26 PDT
Comment on attachment 429266 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429266&action=review

>>> Source/WebCore/platform/graphics/cairo/ImageBufferCairoBackend.cpp:103
>>> +
>> 
>> This change suggests that transformColorSpace() should take only destColorSpace. I checked the callers of this function and I found they all pass the same colorSpace they used to create the ImageBuffer with. So I would suggest:
>> 1. Change the name of this function to transformToColorSpace
>> 2. Make it take only a newColorSpace.
> 
> Sounds a good idea. But, I want to fix this crashing problem ASAP. Can I do that it as a separate patch?

Filed: Bug 226108 – Rename ImageBuffer::transformColorSpace to transformToColorSpace, and it should take a single argument