Bug 201650

Summary: Web Inspector: Canvas: instrument WebGPUDevice instead of GPUCanvasContext
Product: WebKit Reporter: Devin Rousso <hi>
Component: Web InspectorAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, commit-queue, dino, esprehn+autocc, ews-watchlist, hi, inspector-bugzilla-changes, joepeck, jonlee, justin_fan, keith_miller, kondapallykalyan, mark.lam, mmaxfield, msaboff, saam, tsavell, tzagallo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
See Also: https://bugs.webkit.org/show_bug.cgi?id=201714
Bug Depends on:    
Bug Blocks: 201651, 201675    
Attachments:
Description Flags
Patch
none
[Image] After Patch is applied
none
Patch
none
Patch
none
Patch none

Devin Rousso
Reported 2019-09-10 11:08:32 PDT
Most of the actual "work" done with Web GPU actually uses a `WebGPUDevice`. A `GPUCanvasContext` is basically just a display "client" of the device, and isn't even required (e.g. compute pipeline). We should treat the `GPUCanvasContext` almost like a `-webkit-canvas` client of a `WebGPUDevice`. This change should also carry to the frontend (e.g. use "Device" instead of "Canvas"/"Context").
Attachments
Patch (153.69 KB, patch)
2019-09-10 13:32 PDT, Devin Rousso
no flags
[Image] After Patch is applied (584.06 KB, image/png)
2019-09-10 18:09 PDT, Devin Rousso
no flags
Patch (159.30 KB, patch)
2019-09-10 18:12 PDT, Devin Rousso
no flags
Patch (159.31 KB, patch)
2019-09-10 19:36 PDT, Devin Rousso
no flags
Patch (159.25 KB, patch)
2019-09-11 15:53 PDT, Devin Rousso
no flags
Devin Rousso
Comment 1 2019-09-10 13:32:46 PDT
EWS Watchlist
Comment 2 2019-09-10 13:33:49 PDT
This patch modifies the inspector protocol. Please ensure that any frontend changes appropriately use feature checks for new protocol features.
Joseph Pecoraro
Comment 3 2019-09-10 16:36:42 PDT
Comment on attachment 378480 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=378480&action=review r=me - How does this look in the UI? Internals seem good. > Source/JavaScriptCore/ChangeLog:8 > + Most of the actual "work" done with Web GPU actually uses a `WebGPUDevice`. These repeated details only make sense inside of the WebCore ChangeLog. Not JavaScriptCore / WebInspectorUI. > Source/WebCore/Modules/webgpu/WebGPUDevice.h:81 > + ~WebGPUDevice(); virtual? > Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp:124 > + if (context && existsInCurrentPage(context->canvasBase().scriptExecutionContext())) Is this `context` check necessary? It seems unlikely that `CanvasRenderingContext::instances` will ever return a nullptr, and if so that should probably be addressed. > Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp:133 > + if (device && existsInCurrentPage(device->scriptExecutionContext())) Is this `device` check necessary? It seems unlikely that `WebGPUDevice::instances` will ever return a nullptr, and if so that should probably be addressed. > Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp:636 > + // FIXME: notify old device Still relevant? > Source/WebInspectorUI/UserInterface/Models/Canvas.js:117 > + WI.Canvas._nextContextUniqueDisplayNameNumber = 1; > + WI.Canvas._nextDeviceUniqueDisplayNameNumber = 1; Nit: We could drop the `WI.` prefix for these. > Source/WebInspectorUI/UserInterface/Models/Canvas.js:166 > + this._uniqueDisplayNameNumber = this.constructor._nextDeviceUniqueDisplayNameNumber++; Style: Instead of `this.constructor.` I think we can just use `Canvas.`. > Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js:81 > + // COMPATIBILITY (iOS 13): Canvas.events.cssCanvasClientNodesChanged was renamed to Canvas.events.clientNodesChanged. > + cssCanvasClientNodesChanged(canvasId) Nice!
Devin Rousso
Comment 4 2019-09-10 17:23:43 PDT
Comment on attachment 378480 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=378480&action=review >> Source/JavaScriptCore/ChangeLog:8 >> + Most of the actual "work" done with Web GPU actually uses a `WebGPUDevice`. > > These repeated details only make sense inside of the WebCore ChangeLog. Not JavaScriptCore / WebInspectorUI. I personally like including them in the various ChangeLogs, as it provides an overarching context to the changes. This way, when reading JavaScriptCore changes, you can still see what's generally going on. >> Source/WebCore/Modules/webgpu/WebGPUDevice.h:81 >> + ~WebGPUDevice(); > > virtual? YES!!! I think this is partially the reason for some of the test issues I was encountering :D >> Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp:124 >> + if (context && existsInCurrentPage(context->canvasBase().scriptExecutionContext())) > > Is this `context` check necessary? It seems unlikely that `CanvasRenderingContext::instances` will ever return a nullptr, and if so that should probably be addressed. Fair point. >> Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp:636 >> + // FIXME: notify old device > > Still relevant? Yes, but I actually meant to rework this and kinda forgot -.- >> Source/WebInspectorUI/UserInterface/Models/Canvas.js:117 >> + WI.Canvas._nextDeviceUniqueDisplayNameNumber = 1; > > Nit: We could drop the `WI.` prefix for these. I love it <3 >> Source/WebInspectorUI/UserInterface/Models/Canvas.js:166 >> + this._uniqueDisplayNameNumber = this.constructor._nextDeviceUniqueDisplayNameNumber++; > > Style: Instead of `this.constructor.` I think we can just use `Canvas.`. Ditto
Devin Rousso
Comment 5 2019-09-10 18:09:59 PDT
Created attachment 378520 [details] [Image] After Patch is applied (In reply to Joseph Pecoraro from comment #3) > r=me - How does this look in the UI? Internals seem good. The UI is the exact same, except that "Canvas" is replaced with "Device" :P Hovering interactions also work, since we treat the "related" `HTMLCanvasElement` (via `GPUCanvasContext`) as a "client".
Devin Rousso
Comment 6 2019-09-10 18:12:52 PDT
Devin Rousso
Comment 7 2019-09-10 19:36:25 PDT
Created attachment 378530 [details] Patch Fix win build
WebKit Commit Bot
Comment 8 2019-09-10 21:34:41 PDT
Comment on attachment 378530 [details] Patch Clearing flags on attachment: 378530 Committed r249753: <https://trac.webkit.org/changeset/249753>
WebKit Commit Bot
Comment 9 2019-09-10 21:34:43 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 10 2019-09-10 21:35:17 PDT
Truitt Savell
Comment 11 2019-09-11 09:18:09 PDT
Truitt Savell
Comment 12 2019-09-11 14:10:16 PDT
Reverted r249753 for reason: caused inspector/canvas/shaderProgram-add-remove-webgl.html to crash on all Mac platforms. Committed r249776: <https://trac.webkit.org/changeset/249776>
Devin Rousso
Comment 13 2019-09-11 15:53:35 PDT
Created attachment 378590 [details] Patch The values in `WebGLProgram::instances` aren't always set, as `WebGLRenderingContextBase::~WebGLRenderingContextBase` can change it to be `nullptr`. `WebGLRenderingContextBase::~WebGLRenderingContextBase` doesn't want to remove itself from the `WebGLProgram::instances` (as in removing the key `WebGLProgram` too) because otherwise `WebGLProgram::~WebGLProgram` may fail to remove (and we would have a `WebGLProgram` that exists that isn't recorded in the instances list, which we don't want).
WebKit Commit Bot
Comment 14 2019-09-11 16:28:44 PDT
Comment on attachment 378590 [details] Patch Clearing flags on attachment: 378590 Committed r249786: <https://trac.webkit.org/changeset/249786>
WebKit Commit Bot
Comment 15 2019-09-11 16:28:46 PDT
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.