RESOLVED FIXED Bug 175282
Web Inspector: show warning when recorded Canvas action caused no visual change
https://bugs.webkit.org/show_bug.cgi?id=175282
Summary Web Inspector: show warning when recorded Canvas action caused no visual change
Devin Rousso
Reported 2017-08-07 13:16:03 PDT
Whenever a visual action is applied (e.g. fill, stroke, etc.), a warning should be shown if that action had no visual change on the canvas. As an example, calling `fill` with an empty path will have no effect.
Attachments
Patch (9.38 KB, patch)
2017-08-07 17:39 PDT, Devin Rousso
no flags
[Image] After Patch is applied (527.58 KB, image/png)
2017-08-07 17:40 PDT, Devin Rousso
no flags
[Image] Warnings in sidebar - mockup (137.58 KB, image/png)
2017-08-07 18:43 PDT, Matt Baker
no flags
Patch (9.13 KB, patch)
2017-08-07 18:59 PDT, Devin Rousso
no flags
Patch (7.24 KB, patch)
2017-08-07 19:41 PDT, Devin Rousso
no flags
Patch (14.04 KB, patch)
2017-10-14 02:13 PDT, Devin Rousso
no flags
[Image] After Patch is applied (377.70 KB, image/png)
2017-10-14 02:13 PDT, Devin Rousso
no flags
Archive of layout-test-results from ews100 for mac-elcapitan (1.04 MB, application/zip)
2017-10-14 03:18 PDT, Build Bot
no flags
Archive of layout-test-results from ews105 for mac-elcapitan-wk2 (1.18 MB, application/zip)
2017-10-14 03:25 PDT, Build Bot
no flags
Archive of layout-test-results from ews116 for mac-elcapitan (1.85 MB, application/zip)
2017-10-14 03:34 PDT, Build Bot
no flags
Patch (13.93 KB, patch)
2017-10-14 16:27 PDT, Devin Rousso
no flags
Patch (14.00 KB, patch)
2017-10-15 20:35 PDT, Devin Rousso
no flags
Devin Rousso
Comment 1 2017-08-07 17:39:52 PDT
Devin Rousso
Comment 2 2017-08-07 17:40:11 PDT
Created attachment 317526 [details] [Image] After Patch is applied
Matt Baker
Comment 3 2017-08-07 18:43:46 PDT
Created attachment 317530 [details] [Image] Warnings in sidebar - mockup Warnings in sidebar
Matt Baker
Comment 4 2017-08-07 18:44:55 PDT
(In reply to Devin Rousso from comment #2) > Created attachment 317526 [details] > [Image] After Patch is applied Very cool! How about showing warnings in the sidebar too? Right now it would be difficult to discover this feature. Better yet, an additional filter button to the left of the filter bar to only show those operations with warnings.
Devin Rousso
Comment 5 2017-08-07 18:48:33 PDT
(In reply to Matt Baker from comment #4) > (In reply to Devin Rousso from comment #2) > > Created attachment 317526 [details] > > [Image] After Patch is applied > > Very cool! How about showing warnings in the sidebar too? Right now it would > be difficult to discover this feature. Better yet, an additional filter > button to the left of the filter bar to only show those operations with > warnings. So I thought about doing something like that, but the issue is that we currently don't have a way of determining if an action has an effect until after we apply it to the preview canvas. This is because we don't want to apply each action until it's necessary. If we are OK with the overhead of applying every action and getting/comparing ImageData for each visual one, then it's doable. I don't see it being very performant for large recordings though :(
Matt Baker
Comment 6 2017-08-07 18:58:02 PDT
(In reply to Devin Rousso from comment #5) > (In reply to Matt Baker from comment #4) > > (In reply to Devin Rousso from comment #2) > > > Created attachment 317526 [details] > > > [Image] After Patch is applied > > > > Very cool! How about showing warnings in the sidebar too? Right now it would > > be difficult to discover this feature. Better yet, an additional filter > > button to the left of the filter bar to only show those operations with > > warnings. > So I thought about doing something like that, but the issue is that we > currently don't have a way of determining if an action has an effect until > after we apply it to the preview canvas. This is because we don't want to > apply each action until it's necessary. If we are OK with the overhead of > applying every action and getting/comparing ImageData for each visual one, > then it's doable. I don't see it being very performant for large recordings > though :( That makes sense. Showing the icon in the sidebar once the action has been applied might be a bad idea too, since it would imply that the items without an icon had no issues.
Devin Rousso
Comment 7 2017-08-07 18:59:19 PDT
Devin Rousso
Comment 8 2017-08-07 19:41:52 PDT
Matt Baker
Comment 9 2017-08-07 21:24:21 PDT
Comment on attachment 317533 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=317533&action=review > Source/WebInspectorUI/ChangeLog:13 > + If the selected action is visual, save a copy of the preview canvas' dataURL before Wording: "dataURL" is not a proper name. HTMLCanvasElement.prototype.toDataURL returns a data URI. Use that, or "data URL" in your comments. > Source/WebInspectorUI/UserInterface/Models/RecordingAction.js:44 > + this._hasEffect = undefined; Maybe a more descriptive name? What about `causesVisibleChange`? > Source/WebInspectorUI/UserInterface/Views/RecordingContentView.js:232 > + If RecordingAction was responsible for applying itself to the context, you could remove the `hasEffect` setter, and the variable ``. It should simplify the logic here, and should have minimal ripple effect (this._applyAction calls will need to be changed): // RecordingContentView let checkForChange = i === to && actions[I].isVisual; actions[I].apply(snapshot.context, {checkForChange}); if (checkForChange && actions[i].hasEffect) { let warningIcon = this._messageElement.appendChild(useSVGSymbol("Images/Warning.svg", "glyph")); warningIcon.classList.add("icon"); this._messageElement.appendChild(document.createTextNode(WI.UIString("This action causes no visual change"))); } // RecordingAction _apply(context, options = {}) { if (!this.valid) return; if (this.parameters.includes(WI.Recording.Swizzle.Invalid)) return; let contentBefore; let shouldCheckForChange = options.checkForChange && this._hasEffect === undefined; if (shouldCheckForChange) contentBefore = context.canvas.toDataURL(); try { let name = options.nameOverride || this.name; if (this.isFunction) context[name](...this.parameters); else { if (this.isGetter) context[name]; else context[name] = action.parameters[0]; } if (shouldCheckForChange) this._hasEffect = contentBefore !== context.canvas.toDataURL(); } catch (e) { WI.Recording.synthesizeError(WI.UIString("“%s” threw an error.").format(action.name)); action.valid = false; } }
Matt Baker
Comment 10 2017-08-07 21:26:02 PDT
(In reply to Matt Baker from comment #9) > Comment on attachment 317533 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=317533&action=review ... > If RecordingAction was responsible for applying itself to the context, you > could remove the `hasEffect` setter, and the variable ``. It should simplify the variable `alreadyCheckedHasEffect`.
Radar WebKit Bug Importer
Comment 11 2017-08-23 15:11:35 PDT
Blaze Burg
Comment 12 2017-10-09 11:38:27 PDT
Comment on attachment 317533 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=317533&action=review r- based on Matt's comments, which I think are a nicer direction. > Source/WebInspectorUI/UserInterface/Views/RecordingContentView.css:65 > + margin-right: 4px; This needs RTL treatment.
Devin Rousso
Comment 13 2017-10-14 02:13:30 PDT
Devin Rousso
Comment 14 2017-10-14 02:13:47 PDT
Created attachment 323804 [details] [Image] After Patch is applied
Build Bot
Comment 15 2017-10-14 03:18:43 PDT
Comment on attachment 323803 [details] Patch Attachment 323803 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/4855386 New failing tests: inspector/canvas/recording-2d.html
Build Bot
Comment 16 2017-10-14 03:18:44 PDT
Created attachment 323806 [details] Archive of layout-test-results from ews100 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews100 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 17 2017-10-14 03:25:04 PDT
Comment on attachment 323803 [details] Patch Attachment 323803 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/4855392 New failing tests: inspector/canvas/recording-2d.html
Build Bot
Comment 18 2017-10-14 03:25:05 PDT
Created attachment 323807 [details] Archive of layout-test-results from ews105 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews105 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Build Bot
Comment 19 2017-10-14 03:34:17 PDT
Comment on attachment 323803 [details] Patch Attachment 323803 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/4855398 New failing tests: inspector/canvas/recording-2d.html
Build Bot
Comment 20 2017-10-14 03:34:19 PDT
Created attachment 323808 [details] Archive of layout-test-results from ews116 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews116 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Devin Rousso
Comment 21 2017-10-14 16:27:36 PDT
Joseph Pecoraro
Comment 22 2017-10-15 15:46:45 PDT
Comment on attachment 323830 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=323830&action=review r=me > Source/WebInspectorUI/UserInterface/Models/Recording.js:58 > - WI.Recording.synthesizeError(WI.UIString("â%sâ is invalid.").format(action.name)); > + WI.Recording.synthesizeError(WI.UIString("â%sâ is invalid.").format(this._name)); Nit: This is not in the ChangeLog. > Source/WebInspectorUI/UserInterface/Models/RecordingAction.js:144 > + } catch (e) { Style: Could drop the (e) variable since it is not used: `} catch {`
Devin Rousso
Comment 23 2017-10-15 20:35:23 PDT
WebKit Commit Bot
Comment 24 2017-10-15 21:46:24 PDT
Comment on attachment 323867 [details] Patch Clearing flags on attachment: 323867 Committed r223335: <https://trac.webkit.org/changeset/223335>
WebKit Commit Bot
Comment 25 2017-10-15 21:46:26 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.