-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Google Photos will not allow preview of editing in Safari.
https://bugs.webkit.org/show_bug.cgi?id=259263 <rdar://107687640> Reviewed by Dean Jackson. OffscreenCanvas can asynchronously push frames to the layer associated with the HTMLCanvasElement that is being controlled. This happens using a GraphicsLayerAsyncContentsDisplayDelegate, created by the GraphicsLayer for the HTMLCanvasElement. If style changes that result in the recreation of the GraphicsLayer, the OffscreenCanvas continues to push frames to the original delegate, and they get dropped. This makes ImageBufferPipe always ask the current GraphicsLayer to make sure we have a valid delegate, providing the delegate that was used last time. If the GraphicsLayer has changed, it can reconfigure the delegate to make sure it's targetting the right layer. We need to reconfigure the delegate, rather than recreating one, since the delegate owns the 'current' frame and we need to ensure this is retained. Otherwise compositing wouldn't have a frame until the next time the OffscreenCanvas draws (which could be never). * LayoutTests/fast/canvas/offscreen-toggle-display-expected.html: Added. * LayoutTests/fast/canvas/offscreen-toggle-display.html: Added. * Source/WebCore/platform/graphics/GraphicsLayer.cpp: (WebCore::GraphicsLayer::createAsyncContentsDisplayDelegate): * Source/WebCore/platform/graphics/GraphicsLayer.h: * Source/WebCore/platform/graphics/GraphicsLayerContentsDisplayDelegate.h: * Source/WebCore/platform/graphics/ImageBufferPipe.cpp: * Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::GraphicsLayerCA::contentsLayerIDForModel const): * Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h: * Source/WebCore/platform/graphics/ca/cocoa/GraphicsLayerAsyncContentsDisplayDelegateCocoa.h: * Source/WebCore/platform/graphics/ca/cocoa/GraphicsLayerAsyncContentsDisplayDelegateCocoa.mm: (WebCore::GraphicsLayerAsyncContentsDisplayDelegateCocoa::updateGraphicsLayerCA): * Source/WebKit/WebProcess/WebPage/RemoteLayerTree/GraphicsLayerCARemote.h: * Source/WebKit/WebProcess/WebPage/RemoteLayerTree/GraphicsLayerCARemote.mm: (WebKit::GraphicsLayerCARemote::createAsyncContentsDisplayDelegate): Canonical link: https://commits.webkit.org/266120@main
- Loading branch information
1 parent
a5aad74
commit cbd73ab
Showing
12 changed files
with
95 additions
and
13 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
LayoutTests/fast/canvas/offscreen-toggle-display-expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<canvas id="onscreen" width="200" height="200"></canvas> | ||
<script> | ||
const canvas = document.getElementById('onscreen'); | ||
|
||
const context = canvas.getContext('2d'); | ||
|
||
const square = new Path2D(); | ||
square.rect(50, 50, 100, 100); | ||
context.fillStyle = 'green'; | ||
context.fill(square); | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="fuzzy" content="maxDifference=63; totalPixels=400" /> | ||
</head> | ||
<body> | ||
<canvas id="offscreen" width="200" height="200"></canvas> | ||
<script> | ||
const canvas = document.getElementById('offscreen'); | ||
|
||
const offscreenCanvas = canvas.transferControlToOffscreen(); | ||
const offscreenContext = offscreenCanvas.getContext('2d'); | ||
|
||
|
||
if (window.testRunner) | ||
testRunner.waitUntilDone(); | ||
|
||
requestAnimationFrame(function() { | ||
const square = new Path2D(); | ||
square.rect(50, 50, 100, 100); | ||
offscreenContext.fillStyle = 'green'; | ||
offscreenContext.fill(square); | ||
offscreenContext.commit(); | ||
|
||
requestAnimationFrame(function() { | ||
canvas.style.display = "none"; | ||
|
||
requestAnimationFrame(function() { | ||
canvas.style.display = "inline"; | ||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
}); | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters