Bug 242879
Summary: | REGRESSION(r294536): Drawing the ImageBuffer should not invalidate its cached copied images | ||
---|---|---|---|
Product: | WebKit | Reporter: | Said Abou-Hallawa <sabouhallawa> |
Component: | Layout and Rendering | Assignee: | Said Abou-Hallawa <sabouhallawa> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | bfulgham, simon.fraser, webkit-bug-importer, zalan |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Said Abou-Hallawa
When copying the IOSurface to a CGImage, the memory of this CGImage is allocated as copy-on-write. Before any draws committed to the IOSurface, the all copied CGImages are invalidated such that they have their memory copied so they are not affected by the new changes. Because changing the pixels of the IOSurface directly through putPixelBuffer() does not invalidate the IOSurface image cache, ImageBufferIOSurfaceBackend::invalidateCachedNativeImage() handles this case by a simple hack: draw an empty rect to the IOSurface context. invalidateCachedNativeImage() relies on the flag m_mayHaveOutstandingBackingStoreReferences which is set to true when a CGImage is copied from the backend.
When drawing an accelerated ImageBuffer, the backend IOSurface is copied to a CGImage then this it is drawn to the context and finally it is destroyed. But creating it causes the flag m_mayHaveOutstandingBackingStoreReferences to be set to true. Any subsequent calls to putPixelBuffer() will be preceded by invalidating the cache of the copied images. This invalidation is not needed because the copied image is volatile. It will be destroyed before any subsequent draws or putPixelBuffer() calls.
Consider this sequence:
ImageBuffer::getPixelBuffer()
ImageBuffer::putPixelBuffer()
ImageBuffer::draw(); // Calls copyNativeImage(), sets m_mayHaveOutstandingBackingStoreReferences = true
ImageBuffer::getPixelBuffer()
ImageBuffer::putPixelBuffer(); // Because m_mayHaveOutstandingBackingStoreReferences, IOSurface image cache is invalidated.
ImageBuffer::draw(); // Calls copyNativeImage(), sets m_mayHaveOutstandingBackingStoreReferences = true
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Said Abou-Hallawa
rdar://93775177
Said Abou-Hallawa
Pull request: https://github.com/WebKit/WebKit/pull/2533
EWS
Committed 252813@main (c7880bea0dca): <https://commits.webkit.org/252813@main>
Reviewed commits have been landed. Closing PR #2533 and removing active labels.