RESOLVED FIXED 167968
Disallow accelerated rendering for ginormous 2D canvases.
https://bugs.webkit.org/show_bug.cgi?id=167968
Summary Disallow accelerated rendering for ginormous 2D canvases.
Andreas Kling
Reported 2017-02-07 16:52:33 PST
Allowing gargantuan canvases to have accelerated backing stores creates an opportunity for some lame pathologies. <rdar://problem/30119483>
Attachments
Proposed patch (6.50 KB, patch)
2017-02-07 17:22 PST, Andreas Kling
buildbot: commit-queue-
Archive of layout-test-results from ews101 for mac-elcapitan (963.11 KB, application/zip)
2017-02-07 18:29 PST, Build Bot
no flags
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 (899.50 KB, application/zip)
2017-02-07 18:33 PST, Build Bot
no flags
Archive of layout-test-results from ews114 for mac-elcapitan (1.68 MB, application/zip)
2017-02-07 18:37 PST, Build Bot
no flags
Archive of layout-test-results from ews122 for ios-simulator-wk2 (788.52 KB, application/zip)
2017-02-07 18:54 PST, Build Bot
no flags
Proposed patch (7.03 KB, patch)
2017-02-07 19:59 PST, Andreas Kling
no flags
Proposed patch (11.50 KB, patch)
2017-02-08 07:19 PST, Andreas Kling
buildbot: commit-queue-
Archive of layout-test-results from ews122 for ios-simulator-wk2 (785.48 KB, application/zip)
2017-02-08 08:54 PST, Build Bot
no flags
Proposed patch (12.81 KB, patch)
2017-02-08 11:17 PST, Andreas Kling
buildbot: commit-queue-
Archive of layout-test-results from ews123 for ios-simulator-wk2 (874.64 KB, application/zip)
2017-02-08 12:41 PST, Build Bot
no flags
Proposed patch (12.82 KB, patch)
2017-02-08 12:49 PST, Andreas Kling
no flags
Andreas Kling
Comment 1 2017-02-07 17:22:20 PST
Created attachment 300864 [details] Proposed patch
Simon Fraser (smfr)
Comment 2 2017-02-07 17:48:56 PST
Please split this into 2 patches.
Alex Christensen
Comment 3 2017-02-07 18:05:28 PST
Comment on attachment 300864 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=300864&action=review > Source/WebCore/page/Settings.in:28 > minimumAccelerated2dCanvasSize type=int, initial=257*256 > > +maximumAccelerated2dCanvasSize type=unsigned, initial=5120*2880 Why are these different types?
Build Bot
Comment 4 2017-02-07 18:29:45 PST
Comment on attachment 300864 [details] Proposed patch Attachment 300864 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/3022503 New failing tests: inspector/layers/layers-compositing-reasons.html
Build Bot
Comment 5 2017-02-07 18:29:50 PST
Created attachment 300873 [details] Archive of layout-test-results from ews101 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 6 2017-02-07 18:33:00 PST
Comment on attachment 300864 [details] Proposed patch Attachment 300864 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/3022510 New failing tests: inspector/layers/layers-compositing-reasons.html
Build Bot
Comment 7 2017-02-07 18:33:05 PST
Created attachment 300874 [details] Archive of layout-test-results from ews104 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Build Bot
Comment 8 2017-02-07 18:36:57 PST
Comment on attachment 300864 [details] Proposed patch Attachment 300864 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/3022506 New failing tests: inspector/layers/layers-compositing-reasons.html
Build Bot
Comment 9 2017-02-07 18:37:01 PST
Created attachment 300875 [details] Archive of layout-test-results from ews114 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews114 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 10 2017-02-07 18:54:04 PST
Comment on attachment 300864 [details] Proposed patch Attachment 300864 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/3022524 New failing tests: compositing/canvas/accelerated-canvas-compositing-size-limit.html
Build Bot
Comment 11 2017-02-07 18:54:09 PST
Created attachment 300876 [details] Archive of layout-test-results from ews122 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews122 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Andreas Kling
Comment 12 2017-02-07 19:59:57 PST
Created attachment 300879 [details] Proposed patch
Andreas Kling
Comment 13 2017-02-07 20:00:47 PST
(In reply to comment #2) > Please split this into 2 patches. k! (In reply to comment #3) > Comment on attachment 300864 [details] > Proposed patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=300864&action=review > > > Source/WebCore/page/Settings.in:28 > > minimumAccelerated2dCanvasSize type=int, initial=257*256 > > > > +maximumAccelerated2dCanvasSize type=unsigned, initial=5120*2880 > > Why are these different types? They should both be unsigned. I'm trying to keep this change minimal, so didn't touch it now.
Simon Fraser (smfr)
Comment 14 2017-02-07 20:28:45 PST
Comment on attachment 300879 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=300879&action=review > LayoutTests/compositing/canvas/accelerated-canvas-compositing-size-limit.html:27 > +<p>Verifies that 2D canvases with higher than 5120x2880 resolution don't create accelerated backing stores.</p> So this test is actually detecting whether we create compositing layers for big canvases, not whether we're accelerating the canvas backing store. This are correlated (but you may break this correlation in your next patch). > LayoutTests/platform/ios-simulator/TestExpectations:2855 > +compositing/canvas/accelerated-canvas-compositing-size-limit.html [ Failure ] I think this is the wrong way to handle this. Why not just land iOS-specific results, so we can tell if we broke the limits in future?
Andreas Kling
Comment 15 2017-02-08 06:38:34 PST
(In reply to comment #14) > Comment on attachment 300879 [details] > Proposed patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=300879&action=review > > > LayoutTests/compositing/canvas/accelerated-canvas-compositing-size-limit.html:27 > > +<p>Verifies that 2D canvases with higher than 5120x2880 resolution don't create accelerated backing stores.</p> > > So this test is actually detecting whether we create compositing layers for > big canvases, not whether we're accelerating the canvas backing store. This > are correlated (but you may break this correlation in your next patch). Duh. Let me add a way to include the accelerates drawing flag in layer tree dumps.. > > LayoutTests/platform/ios-simulator/TestExpectations:2855 > > +compositing/canvas/accelerated-canvas-compositing-size-limit.html [ Failure ] > > I think this is the wrong way to handle this. Why not just land iOS-specific > results, so we can tell if we broke the limits in future? That would be better, let's do that.
Andreas Kling
Comment 16 2017-02-08 07:19:19 PST
Created attachment 300895 [details] Proposed patch With "acceleratesDrawing" in layer tree dumps (optional). I don't have a test baseline for iOS at the moment, but I'm sure EWS is gonna give me one.
WebKit Commit Bot
Comment 17 2017-02-08 07:21:25 PST
Attachment 300895 [details] did not pass style-queue: ERROR: Source/WebCore/testing/Internals.h:263: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] ERROR: Source/WebCore/testing/Internals.h:264: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] Total errors found: 2 in 13 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 18 2017-02-08 08:54:37 PST
Comment on attachment 300895 [details] Proposed patch Attachment 300895 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/3025466 New failing tests: compositing/canvas/accelerated-canvas-compositing-size-limit.html
Build Bot
Comment 19 2017-02-08 08:54:43 PST
Created attachment 300904 [details] Archive of layout-test-results from ews122 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews122 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Andreas Kling
Comment 20 2017-02-08 11:17:48 PST
Created attachment 300926 [details] Proposed patch My machine doesn't seem to care about the maxActivePixelMemory change I wanted to make anymore. This one is still very relevant though.
WebKit Commit Bot
Comment 21 2017-02-08 11:20:50 PST
Attachment 300926 [details] did not pass style-queue: ERROR: Source/WebCore/testing/Internals.h:263: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] ERROR: Source/WebCore/testing/Internals.h:264: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] Total errors found: 2 in 14 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 22 2017-02-08 12:41:24 PST
Comment on attachment 300926 [details] Proposed patch Attachment 300926 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/3026595 New failing tests: compositing/canvas/accelerated-canvas-compositing-size-limit.html
Build Bot
Comment 23 2017-02-08 12:41:29 PST
Created attachment 300936 [details] Archive of layout-test-results from ews123 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews123 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Andreas Kling
Comment 24 2017-02-08 12:49:46 PST
Created attachment 300939 [details] Proposed patch
WebKit Commit Bot
Comment 25 2017-02-08 12:51:47 PST
Attachment 300939 [details] did not pass style-queue: ERROR: Source/WebCore/testing/Internals.h:263: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] ERROR: Source/WebCore/testing/Internals.h:264: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] Total errors found: 2 in 14 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Commit Bot
Comment 26 2017-02-09 05:57:14 PST
Comment on attachment 300939 [details] Proposed patch Clearing flags on attachment: 300939 Committed r211949: <http://trac.webkit.org/changeset/211949>
WebKit Commit Bot
Comment 27 2017-02-09 05:57:22 PST
All reviewed patches have been landed. Closing bug.
Simon Fraser (smfr)
Comment 28 2017-02-09 08:44:42 PST
Comment on attachment 300939 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=300939&action=review > Source/WebCore/platform/graphics/GraphicsLayer.cpp:789 > + if (behavior & LayerTreeAsTextIncludeAcceleratesDrawing && m_acceleratesDrawing) { > + writeIndent(ts, indent + 1); > + ts << "(acceleratesDrawing " << m_acceleratesDrawing << ")\n"; > + } This has no relation to whether the canvas itself is using accelerated drawing. This is just about the compositing layers, and will always be 1 on Mac, and 0 in the iOS simulator. So I don't think this is giving you accurate information about the behavior of HTMLCanvasElement::shouldAccelerate().
Andreas Kling
Comment 29 2017-02-09 08:50:38 PST
(In reply to comment #28) > Comment on attachment 300939 [details] > Proposed patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=300939&action=review > > > Source/WebCore/platform/graphics/GraphicsLayer.cpp:789 > > + if (behavior & LayerTreeAsTextIncludeAcceleratesDrawing && m_acceleratesDrawing) { > > + writeIndent(ts, indent + 1); > > + ts << "(acceleratesDrawing " << m_acceleratesDrawing << ")\n"; > > + } > > This has no relation to whether the canvas itself is using accelerated > drawing. This is just about the compositing layers, and will always be 1 on > Mac, and 0 in the iOS simulator. So I don't think this is giving you > accurate information about the behavior of > HTMLCanvasElement::shouldAccelerate(). Are you sure? The only thing we do with the return value from shouldAccelerate() is call GraphicsLayer::setAcceleratesDrawing() if it's true.
Andreas Kling
Comment 30 2017-02-09 08:55:46 PST
iOS simulator doesn't enable USE_IOSURFACE_CANVAS_BACKING_STORE so I think shouldAccelerate() will always return false there, unless we're building with ENABLE(ACCELERATED_2D_CANVAS)? If you look at the expected results from my new test, you'll see that acceleratesDrawing is not present for the over-5K canvas's layer.
Simon Fraser (smfr)
Comment 31 2017-02-09 10:58:20 PST
(In reply to comment #29) > (In reply to comment #28) > > Comment on attachment 300939 [details] > > Proposed patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=300939&action=review > > > > > Source/WebCore/platform/graphics/GraphicsLayer.cpp:789 > > > + if (behavior & LayerTreeAsTextIncludeAcceleratesDrawing && m_acceleratesDrawing) { > > > + writeIndent(ts, indent + 1); > > > + ts << "(acceleratesDrawing " << m_acceleratesDrawing << ")\n"; > > > + } > > > > This has no relation to whether the canvas itself is using accelerated > > drawing. This is just about the compositing layers, and will always be 1 on > > Mac, and 0 in the iOS simulator. So I don't think this is giving you > > accurate information about the behavior of > > HTMLCanvasElement::shouldAccelerate(). > > Are you sure? The only thing we do with the return value from > shouldAccelerate() is call GraphicsLayer::setAcceleratesDrawing() if it's > true. GraphicsLayer::acceleratesDrawing() is true by default on Mac and iOS device, so this line is mostly a no-op. I'm actually not sure why it was added (maybe before we turned on accel. drawing by default?). What really matters for canvas backing store is the code in HTMLCanvasElement::createImageBuffer().
Note You need to log in before you can comment on or make changes to this bug.