On some ports the printing of WebGL canvases is either broken or extremely inefficient. In the Chromium port, multiple readbacks of the context are being done, some of which are from the wrong source. A rewrite of WebGLRenderingContext::paintRenderingResultsToCanvas is needed. This was discovered during investigation of Chromium issue 99393 (http://crbug.com/99393), although this fix does not fix that issue.
Created attachment 129088 [details] Patch
Comment on attachment 129088 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=129088&action=review > Source/WebCore/html/canvas/WebGLRenderingContext.cpp:-685 > - canvas()->makePresentationCopy(); I believe removing this breaks when accelerated compositing is disabled.
Comment on attachment 129088 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=129088&action=review >> Source/WebCore/html/canvas/WebGLRenderingContext.cpp:-685 >> - canvas()->makePresentationCopy(); > > I believe removing this breaks when accelerated compositing is disabled. It doesn't seem to. I've run Chromium with --disable-accelerated-compositing and WebGL displays fine. Turning off accelerated compositing in Safari causes WebGL to be disabled.
Comment on attachment 129088 [details] Patch jbauman walked me through the code paths offline and it seems clear that the short-circuits I added above don't work in all cases, for example drawing a WebGL canvas into a 2D canvas. Withdrawing this patch from review.
Additionally, I should mention that it looks like printing isn't broken in the common case, though it does look like redundant readbacks are being performed.
After more testing, there are definitely bugs in the current printing code for WebGL-rendered canvases. Minimally, it looks like if the same page is printed multiple times, the contents of the canvas are always that which was on the first copy. Will look into this more after working around related stability issues.
I think the reason it always prints the same content is that in the normal (accelerated compositing disabled) case, the next time it would paint to the screen, layerComposited would be false when calling paintRenderedResultsToCanvas, which means that clearPresentationCopy would be called. When printing twice, the presentation copy isn't cleared (and makePresentationCopy won't do anything), so it'll draw from the old presentation copy.
Inactionable for current WebKit