RESOLVED FIXED 109345
Create the SharedGraphicsContext3D through its own method.
https://bugs.webkit.org/show_bug.cgi?id=109345
Summary Create the SharedGraphicsContext3D through its own method.
Dana Jansens
Reported 2013-02-08 21:44:19 PST
Create the SharedGraphicsContext3D through its own method.
Attachments
Patch (7.66 KB, patch)
2013-02-08 21:49 PST, Dana Jansens
no flags
Patch (7.66 KB, patch)
2013-02-08 21:55 PST, Dana Jansens
no flags
Patch (7.94 KB, patch)
2013-02-08 21:58 PST, Dana Jansens
no flags
Patch (4.05 KB, patch)
2013-02-08 22:33 PST, Dana Jansens
no flags
Patch (4.08 KB, patch)
2013-02-08 23:01 PST, Dana Jansens
no flags
Patch (6.95 KB, patch)
2013-02-12 22:30 PST, Dana Jansens
no flags
Patch (9.99 KB, patch)
2013-02-12 23:01 PST, Dana Jansens
no flags
Patch (10.36 KB, patch)
2013-02-13 11:09 PST, Dana Jansens
no flags
Patch (10.47 KB, patch)
2013-02-13 11:13 PST, Dana Jansens
no flags
Patch (11.95 KB, patch)
2013-02-25 10:32 PST, Dana Jansens
no flags
Patch (11.96 KB, patch)
2013-02-25 14:41 PST, Dana Jansens
no flags
Patch (11.97 KB, patch)
2013-02-26 08:20 PST, Dana Jansens
no flags
Dana Jansens
Comment 1 2013-02-08 21:49:15 PST
WebKit Review Bot
Comment 2 2013-02-08 21:52:28 PST
Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI.
Dana Jansens
Comment 3 2013-02-08 21:53:07 PST
This won't pass tests until the TestWebKitPlatformSupport implements the method to provide a shared context. It'll crash in any test that uses the shared context until then. I'll intend to land that piece first. This adds an API to GraphicsContext3D to get the shared context in an explicit way, so that we can get that context from the embedder along a different code path. On Chromium, we could get rid of the SharedContext3D class other than a call to the Platform API, but that wouldn't work for other platforms, so the class is left alone except to call through GraphicsContext3D::createSharedContext instead of GraphicsContext3D::create.
Dana Jansens
Comment 4 2013-02-08 21:55:14 PST
Created attachment 187413 [details] Patch Fix typo
Dana Jansens
Comment 5 2013-02-08 21:58:34 PST
Created attachment 187414 [details] Patch Fix QT build
James Robinson
Comment 6 2013-02-08 22:08:43 PST
Comment on attachment 187414 [details] Patch I don't understand the compile guards - do you need those?
James Robinson
Comment 7 2013-02-08 22:11:42 PST
Comment on attachment 187414 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=187414&action=review > Source/WebCore/platform/graphics/GraphicsContext3D.h:491 > + static PassRefPtr<GraphicsContext3D> createSharedContext(); I think it would be better to provide chromium-specific implementations of SharedGraphicsContext3D functions and not modify the GraphicsContext3D interface itself
Dana Jansens
Comment 8 2013-02-08 22:33:24 PST
Dana Jansens
Comment 9 2013-02-08 22:34:18 PST
(In reply to comment #7) > I think it would be better to provide chromium-specific implementations of SharedGraphicsContext3D functions and not modify the GraphicsContext3D interface itself Done.
James Robinson
Comment 10 2013-02-08 22:53:27 PST
Comment on attachment 187416 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=187416&action=review R=me but needs an if > Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp:75 > + m_context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), false); i don't think this call is safe to do if webContext is null
Dana Jansens
Comment 11 2013-02-08 23:01:25 PST
Created attachment 187419 [details] Patch With an if
Build Bot
Comment 12 2013-02-09 16:33:47 PST
Comment on attachment 187419 [details] Patch Attachment 187419 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://queues.webkit.org/results/16475530 New failing tests: compositing/checkerboard.html accessibility/anchor-linked-anonymous-block-crash.html http/tests/cache/cancel-multiple-post-xhrs.html animations/3d/state-at-end-event-transform.html animations/animation-add-events-in-handler.html animations/3d/replace-filling-transform.html http/tests/cache/history-only-cached-subresource-loads.html compositing/bounds-in-flipped-writing-mode.html accessibility/accessibility-node-reparent.html animations/animation-border-overflow.html accessibility/accessibility-object-detached.html accessibility/anonymous-render-block-in-continuation-causes-crash.html animations/animation-controller-drt-api.html compositing/absolute-position-changed-with-composited-parent-layer.html compositing/absolute-position-changed-in-composited-layer.html http/tests/cache/iframe-304-crash.html animations/3d/transform-perspective.html http/tests/cache/cancel-during-failure-crash.html canvas/philip/tests/2d.clearRect+fillRect.alpha0.5.html canvas/philip/tests/2d.clearRect.basic.html animations/3d/transform-origin-vs-functions.html animations/animation-css-rule-types.html canvas/philip/tests/2d.clearRect+fillRect.basic.html canvas/philip/tests/2d.clearRect+fillRect.alpha0.html
WebKit Review Bot
Comment 13 2013-02-10 15:32:50 PST
Comment on attachment 187419 [details] Patch Attachment 187419 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/16478911 New failing tests: css3/filters/effect-blur-hw.html platform/chromium/virtual/gpu/fast/canvas/canvas-bg.html platform/chromium/virtual/gpu/fast/canvas/canvas-as-image.html compositing/culling/filter-occlusion-alpha.html css3/filters/effect-invert-hw.html platform/chromium/virtual/gpu/fast/canvas/canvas-as-image-incremental-repaint.html inspector/audits/audits-panel-functional.html css3/filters/effect-reference-ordering-hw.html css3/filters/filter-repaint-composited-fallback-crash.html fast/loader/text-document-wrapping.html compositing/layer-creation/spanOverlapsCanvas.html compositing/culling/filter-occlusion-alpha-large.html inspector-protocol/heap-profiler/heap-snapshot-with-event-listener.html css3/filters/effect-sepia-hw.html css3/filters/effect-opacity-hw.html css3/filters/filter-change-repaint-composited.html css3/filters/effect-hue-rotate-hw.html css3/filters/effect-drop-shadow-hw.html css3/filters/filtered-compositing-descendant.html compositing/culling/filter-occlusion-blur.html platform/chromium/virtual/gpu/fast/canvas/canvas-bg-zoom.html css3/filters/filter-repaint-composited-fallback.html css3/filters/effect-grayscale-hw.html css3/filters/effect-reference-hw.html css3/filters/filter-change-repaint.html compositing/culling/filter-occlusion-blur-large.html fast/loader/javascript-url-in-object.html css3/filters/effect-contrast-hw.html css3/filters/effect-saturate-hw.html css3/filters/composited-reflected.html
Dana Jansens
Comment 14 2013-02-12 22:30:24 PST
WebKit Review Bot
Comment 15 2013-02-12 22:37:00 PST
Comment on attachment 188014 [details] Patch Attachment 188014 [details] did not pass cr-linux-debug-ews (chromium-xvfb): Output: http://queues.webkit.org/results/16517579
Peter Beverloo (cr-android ews)
Comment 16 2013-02-12 22:42:53 PST
Comment on attachment 188014 [details] Patch Attachment 188014 [details] did not pass cr-android-ews (chromium-android): Output: http://queues.webkit.org/results/16454688
WebKit Review Bot
Comment 17 2013-02-12 22:44:08 PST
Comment on attachment 188014 [details] Patch Attachment 188014 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/16521606
Dana Jansens
Comment 18 2013-02-12 23:01:50 PST
Dana Jansens
Comment 19 2013-02-12 23:03:28 PST
New patch to not try take ownership of the WGC3D or GrContext provided by the embedder.
James Robinson
Comment 20 2013-02-12 23:20:10 PST
Comment on attachment 188017 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=188017&action=review > Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp:75 > + GrContext* grContext = WebKit::Platform::current()->sharedOffscreenGrContext(); to stage this, perhaps this should fall back on the current path if the embedder fails to provide a context? or will you just make sure to land an implementation of this function in chromium before landing this?
Dana Jansens
Comment 21 2013-02-13 00:36:37 PST
(In reply to comment #20) > (From update of attachment 188017 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=188017&action=review > > > Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp:75 > > + GrContext* grContext = WebKit::Platform::current()->sharedOffscreenGrContext(); > > to stage this, perhaps this should fall back on the current path if the embedder fails to provide a context? or will you just make sure to land an implementation of this function in chromium before landing this? I'm intending to land the chromium implementation of the path first. We'll end up in a temporary state where we can have a context3d for the compositor owned by chromium, and for canvas owned by webkit. It's still correct, just potentially wasteful, until this lands and then the canvas one will be owned by chromium as well.
Build Bot
Comment 22 2013-02-13 01:45:48 PST
Comment on attachment 188017 [details] Patch Attachment 188017 [details] did not pass mac-ews (mac): Output: http://queues.webkit.org/results/16543026 New failing tests: platform/mac/fast/forms/attributed-strings.html
Dana Jansens
Comment 23 2013-02-13 11:09:58 PST
Created attachment 188124 [details] Patch Moved to getOrCreate so this is used for the main thread context, and don't hold onto the GC3D if the WGC3D from the embedder changed
Dana Jansens
Comment 24 2013-02-13 11:13:20 PST
Created attachment 188125 [details] Patch Do pushGroupMarkerEXT("SharedGraphicsContext") on the context from the embedder
James Robinson
Comment 25 2013-02-14 16:51:51 PST
Comment on attachment 188125 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=188125&action=review > Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp:51 > + if (m_context && GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_context.get()) == webContext) > + return m_context; where's the check for "is this context lost" ? is that on the implementation side? > Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp:58 > + if (m_context) > + m_context->getExtensions()->pushGroupMarkerEXT("SharedGraphicsContext"); you have to be careful only to add this marker on the first creation for a new context, not every instantiation or it'll be a big memory leak
Dana Jansens
Comment 26 2013-02-14 16:55:17 PST
Comment on attachment 188125 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=188125&action=review >> Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp:51 >> + return m_context; > > where's the check for "is this context lost" ? is that on the implementation side? The other side does check for loss. What I'm not sure about yet is how this side is supposed to hear about the loss before the WGC3D is deleted, so that it doesn't try to use a deleted WGC3D*. Currently, since WebKit owns the WGC3D, it doesn't have to worry about this. How do you think I should have the embedder notify WebKit that the WGC3D it's using no longer exists? Should I instead have the shared GC3D query the playform for the WGC3D* on every operation instead of holding onto the pointer internally? >> Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp:58 >> + m_context->getExtensions()->pushGroupMarkerEXT("SharedGraphicsContext"); > > you have to be careful only to add this marker on the first creation for a new context, not every instantiation or it'll be a big memory leak Oh okay, thanks.
Dana Jansens
Comment 27 2013-02-14 16:56:25 PST
(In reply to comment #26) > (From update of attachment 188125 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=188125&action=review > > >> Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp:51 > >> + return m_context; > > > > where's the check for "is this context lost" ? is that on the implementation side? > > The other side does check for loss. What I'm not sure about yet is how this side is supposed to hear about the loss before the WGC3D is deleted, so that it doesn't try to use a deleted WGC3D*. > > Currently, since WebKit owns the WGC3D, it doesn't have to worry about this. How do you think I should have the embedder notify WebKit that the WGC3D it's using no longer exists? Should I instead have the shared GC3D query the playform for the WGC3D* on every operation instead of holding onto the pointer internally? FWIW I'm solving this in the compositor by refcounting the thing that the embedder gives, and I null out the stuff inside that struct. I don't think I can do that for the Platform API tho, can I?
WebKit Review Bot
Comment 28 2013-02-18 09:52:59 PST
Comment on attachment 188125 [details] Patch Attachment 188125 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/16617198 New failing tests: css3/filters/effect-blur-hw.html fast/forms/datalist/update-range-with-datalist.html compositing/culling/filter-occlusion-alpha.html css3/filters/effect-invert-hw.html css3/filters/effect-reference-ordering-hw.html css3/filters/filter-repaint-composited-fallback-crash.html fast/loader/text-document-wrapping.html fast/layers/no-clipping-overflow-hidden-added-after-transition.html compositing/layer-creation/spanOverlapsCanvas.html compositing/culling/filter-occlusion-alpha-large.html css3/filters/effect-brightness-hw.html css3/filters/effect-sepia-hw.html css3/filters/effect-opacity-hw.html css3/filters/effect-combined-hw.html css3/filters/filter-change-repaint-composited.html css3/filters/effect-hue-rotate-hw.html css3/filters/effect-drop-shadow-hw.html css3/filters/filtered-compositing-descendant.html compositing/culling/filter-occlusion-blur.html css3/filters/effect-brightness-clamping-hw.html css3/filters/filter-repaint-composited-fallback.html css3/filters/effect-grayscale-hw.html fast/layers/no-clipping-overflow-hidden-added-after-transform.html css3/filters/filter-change-repaint.html compositing/culling/filter-occlusion-blur-large.html fast/loader/javascript-url-in-object.html css3/filters/effect-contrast-hw.html css3/filters/effect-saturate-hw.html css3/filters/composited-reflected.html fast/layers/no-clipping-overflow-hidden-hardware-acceleration.html
James Robinson
Comment 29 2013-02-22 17:03:08 PST
Still need this?
Dana Jansens
Comment 30 2013-02-22 17:04:14 PST
Comment on attachment 188125 [details] Patch Yes, but it needs a refresh.
Dana Jansens
Comment 31 2013-02-25 10:32:01 PST
Created attachment 190089 [details] Patch New patch with a fallback to the legacy code path, and added a parameter to the API to tell when a new context was created (to avoid pointer comparisons for this).
Dana Jansens
Comment 32 2013-02-25 14:41:09 PST
Created attachment 190131 [details] Patch wasCreated for the WGC3D should cause a new m_context to be made
James Robinson
Comment 33 2013-02-25 17:52:35 PST
(In reply to comment #31) > Created an attachment (id=190089) [details] > Patch > > New patch with a fallback to the legacy code path, and added a parameter to the API to tell when a new context was created (to avoid pointer comparisons for this). What's the problem with pointer comparisons this is intended to resolve?
Dana Jansens
Comment 34 2013-02-25 18:05:31 PST
(In reply to comment #33) > (In reply to comment #31) > > Created an attachment (id=190089) [details] [details] > > Patch > > > > New patch with a fallback to the legacy code path, and added a parameter to the API to tell when a new context was created (to avoid pointer comparisons for this). > > What's the problem with pointer comparisons this is intended to resolve? I'd say its a bad practice. You could delete and allocate and get the same pointer address. Or someone else could delete and create then you do the same and get back the old address. It just seems flaky and not robust.
James Robinson
Comment 35 2013-02-25 18:08:00 PST
(In reply to comment #34) > (In reply to comment #33) > > (In reply to comment #31) > > > Created an attachment (id=190089) [details] [details] [details] > > > Patch > > > > > > New patch with a fallback to the legacy code path, and added a parameter to the API to tell when a new context was created (to avoid pointer comparisons for this). > > > > What's the problem with pointer comparisons this is intended to resolve? > > I'd say its a bad practice. You could delete and allocate and get the same pointer address. Or someone else could delete and create then you do the same and get back the old address. It just seems flaky and not robust. Well, it matters who has ownership. Who's responsible for deleting the WGC3D when it becomes lost?
Dana Jansens
Comment 36 2013-02-25 18:16:29 PST
(In reply to comment #35) > (In reply to comment #34) > > (In reply to comment #33) > > > (In reply to comment #31) > > > > Created an attachment (id=190089) [details] [details] [details] [details] > > > > Patch > > > > > > > > New patch with a fallback to the legacy code path, and added a parameter to the API to tell when a new context was created (to avoid pointer comparisons for this). > > > > > > What's the problem with pointer comparisons this is intended to resolve? > > > > I'd say its a bad practice. You could delete and allocate and get the same pointer address. Or someone else could delete and create then you do the same and get back the old address. It just seems flaky and not robust. > > Well, it matters who has ownership. Who's responsible for deleting the WGC3D when it becomes lost? Ownership works like: WebKitPlatformSupport on the chromium side owns a refptr to a ContextProvider. ContextProvider owns the WGC3D. When SharedContext3D asks for a WGC3D, the WebKitPlatformSupport may replace its ContextProvider with a new one if the old one held a lost context. Then the WGC3D is deleted immediately, or after the compositor also drops its ContextProvider if it has a reference. WebKitPlatformSupport returns the new WGC3D out of its ContextProvider. WebKit side the assumption is that calling this function may cause the last thing it returned to be deleted. Thus only one person should ever be calling it.
Dana Jansens
Comment 37 2013-02-25 18:23:24 PST
(In reply to comment #36) > (In reply to comment #35) > > (In reply to comment #34) > > > (In reply to comment #33) > > > > (In reply to comment #31) > > > > > Created an attachment (id=190089) [details] [details] [details] [details] [details] > > > > > Patch > > > > > > > > > > New patch with a fallback to the legacy code path, and added a parameter to the API to tell when a new context was created (to avoid pointer comparisons for this). > > > > > > > > What's the problem with pointer comparisons this is intended to resolve? > > > > > > I'd say its a bad practice. You could delete and allocate and get the same pointer address. Or someone else could delete and create then you do the same and get back the old address. It just seems flaky and not robust. > > > > Well, it matters who has ownership. Who's responsible for deleting the WGC3D when it becomes lost? > > Ownership works like: > > WebKitPlatformSupport on the chromium side owns a refptr to a ContextProvider. > ContextProvider owns the WGC3D. > > When SharedContext3D asks for a WGC3D, the WebKitPlatformSupport may replace its ContextProvider with a new one if the old one held a lost context. Then the WGC3D is deleted immediately, or after the compositor also drops its ContextProvider if it has a reference. WebKitPlatformSupport returns the new WGC3D out of its ContextProvider. > > > WebKit side the assumption is that calling this function may cause the last thing it returned to be deleted. Thus only one person should ever be calling it. https://codereview.chromium.org/12217099 is a reasonably simple example of this ownership I think. It implements the behaviour for DRT.
James Robinson
Comment 38 2013-02-25 18:42:25 PST
(In reply to comment #36) > (In reply to comment #35) > > (In reply to comment #34) > > > (In reply to comment #33) > > > > (In reply to comment #31) > > > > > Created an attachment (id=190089) [details] [details] [details] [details] [details] > > > > > Patch > > > > > > > > > > New patch with a fallback to the legacy code path, and added a parameter to the API to tell when a new context was created (to avoid pointer comparisons for this). > > > > > > > > What's the problem with pointer comparisons this is intended to resolve? > > > > > > I'd say its a bad practice. You could delete and allocate and get the same pointer address. Or someone else could delete and create then you do the same and get back the old address. It just seems flaky and not robust. > > > > Well, it matters who has ownership. Who's responsible for deleting the WGC3D when it becomes lost? > > Ownership works like: > > WebKitPlatformSupport on the chromium side owns a refptr to a ContextProvider. > ContextProvider owns the WGC3D. > > When SharedContext3D asks for a WGC3D, the WebKitPlatformSupport may replace its ContextProvider with a new one if the old one held a lost context. Then the WGC3D is deleted immediately, or after the compositor also drops its ContextProvider if it has a reference. WebKitPlatformSupport returns the new WGC3D out of its ContextProvider. > > > WebKit side the assumption is that calling this function may cause the last thing it returned to be deleted. Thus only one person should ever be calling it. I see. So it sounds like a precondition for calling this function is that the WGC3D is a valid not-deallocated object. If that's the case then its address cannot collide with a newly allocated one, assuming the implementation decides to make a new one. So I'm not sure I see the issue with pointer comparisons in this instance.
Dana Jansens
Comment 39 2013-02-25 19:57:18 PST
(In reply to comment #38) > (In reply to comment #36) > > (In reply to comment #35) > > > (In reply to comment #34) > > > > (In reply to comment #33) > > > > > (In reply to comment #31) > > > > > > Created an attachment (id=190089) [details] [details] [details] [details] [details] [details] > > > > > > Patch > > > > > > > > > > > > New patch with a fallback to the legacy code path, and added a parameter to the API to tell when a new context was created (to avoid pointer comparisons for this). > > > > > > > > > > What's the problem with pointer comparisons this is intended to resolve? > > > > > > > > I'd say its a bad practice. You could delete and allocate and get the same pointer address. Or someone else could delete and create then you do the same and get back the old address. It just seems flaky and not robust. > > > > > > Well, it matters who has ownership. Who's responsible for deleting the WGC3D when it becomes lost? > > > > Ownership works like: > > > > WebKitPlatformSupport on the chromium side owns a refptr to a ContextProvider. > > ContextProvider owns the WGC3D. > > > > When SharedContext3D asks for a WGC3D, the WebKitPlatformSupport may replace its ContextProvider with a new one if the old one held a lost context. Then the WGC3D is deleted immediately, or after the compositor also drops its ContextProvider if it has a reference. WebKitPlatformSupport returns the new WGC3D out of its ContextProvider. > > > > > > WebKit side the assumption is that calling this function may cause the last thing it returned to be deleted. Thus only one person should ever be calling it. > > I see. So it sounds like a precondition for calling this function is that the WGC3D is a valid not-deallocated object. If that's the case then its address cannot collide with a newly allocated one, assuming the implementation decides to make a new one. So I'm not sure I see the issue with pointer comparisons in this instance. That is true. I'm worried about multiple sites calling this function, but then I guess all bet are off and undefined behaviour is somewhat unavoidable. I'll drop the bool.
Dana Jansens
Comment 40 2013-02-26 08:20:57 PST
Created attachment 190289 [details] Patch Dropped the wasCreated flag
WebKit Review Bot
Comment 41 2013-02-26 10:37:19 PST
Comment on attachment 190289 [details] Patch Clearing flags on attachment: 190289 Committed r144072: <http://trac.webkit.org/changeset/144072>
WebKit Review Bot
Comment 42 2013-02-26 10:37:24 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.