Bug 190525 - Web Inspector: Canvas: previews aren't removed when the parent view is hidden
Summary: Web Inspector: Canvas: previews aren't removed when the parent view is hidden
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks: WebInspectorCanvasTab
  Show dependency treegraph
 
Reported: 2018-10-12 09:55 PDT by Devin Rousso
Modified: 2018-10-12 16:53 PDT (History)
5 users (show)

See Also:


Attachments
Patch (1.95 KB, patch)
2018-10-12 16:17 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (2.79 KB, patch)
2018-10-12 16:35 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Rousso 2018-10-12 09:55:32 PDT
* STEPS TO REPRODUCE:
1. Inspect <https://devinrousso.com/demo/WebKit/canvas.html>
2. Go to the Canvas tab
3. Refresh the page
4. Go to any other tab
5. Refresh the page
6. Go back to the Canvas tab
 => A Canvas preview with "No Preview Available" is shown for each canvas that was on the page before it was refreshed
Comment 1 Devin Rousso 2018-10-12 16:17:37 PDT
Created attachment 352231 [details]
Patch
Comment 2 Matt Baker 2018-10-12 16:22:56 PDT
Comment on attachment 352231 [details]
Patch

r=me
Comment 3 Joseph Pecoraro 2018-10-12 16:23:57 PDT
Comment on attachment 352231 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=352231&action=review

> Source/WebInspectorUI/UserInterface/Views/CanvasTabContentView.js:138
>          for (let canvas of this._canvasCollection) {
> -            if (!canvases.has(canvas))
> +            if (!WI.canvasManager.canvases.includes(canvas))
>                  this._removeCanvas(canvas);
>          }
>  
> -        for (let canvas of canvases) {
> +        for (let canvas of WI.canvasManager.canvases) {
>              if (!this._canvasCollection.has(canvas))
>                  this._addCanvas(canvas);
>          }

Given that `WI.canvasManager.canvases` is a non-simple getter we should only run it once:

    let canvases = WI.canvasManager.canvases;

And use this everywhere instead of `WI.canvasManager.canvases` everywhere.
Comment 4 Devin Rousso 2018-10-12 16:35:46 PDT
Created attachment 352236 [details]
Patch
Comment 5 Matt Baker 2018-10-12 16:44:37 PDT
(In reply to Joseph Pecoraro from comment #3)
> Comment on attachment 352231 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=352231&action=review
> 
> > Source/WebInspectorUI/UserInterface/Views/CanvasTabContentView.js:138
> >          for (let canvas of this._canvasCollection) {
> > -            if (!canvases.has(canvas))
> > +            if (!WI.canvasManager.canvases.includes(canvas))
> >                  this._removeCanvas(canvas);
> >          }
> >  
> > -        for (let canvas of canvases) {
> > +        for (let canvas of WI.canvasManager.canvases) {
> >              if (!this._canvasCollection.has(canvas))
> >                  this._addCanvas(canvas);
> >          }
> 
> Given that `WI.canvasManager.canvases` is a non-simple getter we should only
> run it once:
> 
>     let canvases = WI.canvasManager.canvases;
> 
> And use this everywhere instead of `WI.canvasManager.canvases` everywhere.

Good eye! I didn't think to check the getter.
Comment 6 WebKit Commit Bot 2018-10-12 16:52:18 PDT
Comment on attachment 352236 [details]
Patch

Clearing flags on attachment: 352236

Committed r237090: <https://trac.webkit.org/changeset/237090>
Comment 7 WebKit Commit Bot 2018-10-12 16:52:19 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Radar WebKit Bug Importer 2018-10-12 16:53:31 PDT
<rdar://problem/45241822>