Bug 198855 - Web Inspector: Debugger: support pattern blackboxing
Summary: Web Inspector: Debugger: support pattern blackboxing
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: 17240
Blocks: 203666
  Show dependency treegraph
 
Reported: 2019-06-14 01:30 PDT by Devin Rousso
Modified: 2019-10-31 00:24 PDT (History)
14 users (show)

See Also:


Attachments
Patch (77.10 KB, patch)
2019-09-06 10:59 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (77.10 KB, patch)
2019-09-06 11:00 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
[Image] After Patch is applied (Settings) (564.50 KB, image/png)
2019-09-06 11:01 PDT, Devin Rousso
no flags Details
[Image] After Patch is applied (WI.SourceCodeTreeElement) (117.50 KB, image/png)
2019-09-06 11:04 PDT, Devin Rousso
no flags Details
Patch (82.68 KB, patch)
2019-09-19 01:19 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
[Image] After Patch is applied (Settings Tab) (463.68 KB, image/png)
2019-09-19 01:20 PDT, Devin Rousso
no flags Details
Patch (82.70 KB, patch)
2019-09-19 01:22 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (89.27 KB, patch)
2019-09-25 19:04 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
[Image] After Patch is applied (183.27 KB, image/png)
2019-09-25 19:05 PDT, Devin Rousso
no flags Details
Patch (89.32 KB, patch)
2019-09-25 19:09 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (89.20 KB, patch)
2019-10-11 19:53 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 2019-06-14 01:30:00 PDT
(In reply to Emanuele Feliziani from <https://webkit.org/b/17240#c8>)
> I'm jumping in to suggest folder-level blackboxing or even pattern-based, just as you have in Chrome. With today's JavaScript stacks, it's more convenient to just blackbox everything within node_modules.
Comment 1 Devin Rousso 2019-09-06 10:59:28 PDT
Created attachment 378207 [details]
Patch
Comment 2 EWS Watchlist 2019-09-06 11:00:10 PDT Comment hidden (obsolete)
Comment 3 Devin Rousso 2019-09-06 11:00:13 PDT
Created attachment 378208 [details]
Patch

oops, one minor fix
Comment 4 Devin Rousso 2019-09-06 11:01:12 PDT
Created attachment 378209 [details]
[Image] After Patch is applied (Settings)

I'm open to suggestions for where we should put the blackbox pattern table, or if there's a different/better UI for it.
Comment 5 Devin Rousso 2019-09-06 11:04:08 PDT
Created attachment 378210 [details]
[Image] After Patch is applied (WI.SourceCodeTreeElement)

I'm tempted to switch the UI so that regular URL blackboxing uses the "boxed" eye [<(*)>] and pattern blackboxing just has the greyed out eye <(*)>, as the "boxed" one looks more like a click target than the regular eye.  Many other apps just use an eye though, so that may be more familiar (precedent).

Any ideas of how to distinguish a between toggle-able URL blackbox (e.g. for a specific resource) vs a matched pattern blackbox (which can't be turned off for a specific resource, and instead matches an indeterminate number of URLs) are welcome :)
Comment 6 EWS Watchlist 2019-09-06 13:13:52 PDT Comment hidden (obsolete)
Comment 7 Sam Weinig 2019-09-08 14:04:09 PDT
From the screenshots, it's not clear to me what this feature does. Can we make the UI in the settings more clear about what "blackboxing" is? Can we use a term that perhaps more folks are familiar with?
Comment 8 Devin Rousso 2019-09-10 20:13:37 PDT
(In reply to Sam Weinig from comment #7)
> From the screenshots, it's not clear to me what this feature does. Can we make the UI in the settings more clear about what "blackboxing" is? Can we use a term that perhaps more folks are familiar with?
I'll add some explanatory text above the table that gives an idea of what blackboxing is, but I'm not sure there is a more applicable/accurate term (at least using just one word) than "blackboxing".  If you search for "blackboxing" on the internet, one of the first results that appears is the Chrome DevTools page about script blackboxing.  Once the Sources Tab becomes non-experimental, I'm also planning on writing a blog post about this feature so there will be more explanation available online as well.
Comment 9 Sam Weinig 2019-09-10 22:29:46 PDT
(In reply to Devin Rousso from comment #8)
> (In reply to Sam Weinig from comment #7)
> > From the screenshots, it's not clear to me what this feature does. Can we make the UI in the settings more clear about what "blackboxing" is? Can we use a term that perhaps more folks are familiar with?
> I'll add some explanatory text above the table that gives an idea of what
> blackboxing is, but I'm not sure there is a more applicable/accurate term
> (at least using just one word) than "blackboxing".  If you search for
> "blackboxing" on the internet, one of the first results that appears is the
> Chrome DevTools page about script blackboxing.  Once the Sources Tab becomes
> non-experimental, I'm also planning on writing a blog post about this
> feature so there will be more explanation available online as well.

What's the text you plan on adding, maybe it will help me understand, provide feedback.
Comment 10 Devin Rousso 2019-09-18 20:07:17 PDT
(In reply to Sam Weinig from comment #9)
> (In reply to Devin Rousso from comment #8)
> > (In reply to Sam Weinig from comment #7)
> > > From the screenshots, it's not clear to me what this feature does. Can we make the UI in the settings more clear about what "blackboxing" is? Can we use a term that perhaps more folks are familiar with?
> > I'll add some explanatory text above the table that gives an idea of what blackboxing is, but I'm not sure there is a more applicable/accurate term (at least using just one word) than "blackboxing".  If you search for "blackboxing" on the internet, one of the first results that appears is the Chrome DevTools page about script blackboxing.  Once the Sources Tab becomes non-experimental, I'm also planning on writing a blog post about this feature so there will be more explanation available online as well.
> 
> What's the text you plan on adding, maybe it will help me understand, provide feedback.
I think something along the lines of:
"""
    If the url of any script matches one of the regular expression patterns below, the debugger will defer any pauses that would've happened in that script until execution has continued outside of that script.
"""

That's the basic idea of what blackboxing is.

Our implementation has one nice feature in that we "carry forward" the pause reason and data (as much as we can) from the original pause in the script (which was deferred) to the new pause location outside of the script.

FWIW, individual script blackboxing (e.g. based on a specific load/instance of a specific resource, not just the URL) was added in r249450 <https://webkit.org/b/17240>.  This patch allows for URL based pattern blackboxing, which could be useful for situations where the URL slightly changes between sessions (e.g. a timestamp as a query parameter).
Comment 11 Devin Rousso 2019-09-19 01:19:30 PDT
Created attachment 379110 [details]
Patch

Add explanatory text and fixed an issue where CodeMirror wouldn't show initial content due to being added to the DOM tree before the tree was attached to the main document.
Comment 12 Devin Rousso 2019-09-19 01:20:04 PDT
Created attachment 379111 [details]
[Image] After Patch is applied (Settings Tab)
Comment 13 Devin Rousso 2019-09-19 01:22:15 PDT
Created attachment 379112 [details]
Patch

Slightly adjusted explanation text content grammar and formatting.
Comment 14 Devin Rousso 2019-09-25 19:04:42 PDT
Created attachment 379603 [details]
Patch
Comment 15 Devin Rousso 2019-09-25 19:05:57 PDT
Created attachment 379604 [details]
[Image] After Patch is applied
Comment 16 Devin Rousso 2019-09-25 19:09:26 PDT
Created attachment 379605 [details]
Patch

Rebase
Comment 17 Timothy Hatcher 2019-10-11 18:24:54 PDT
Comment on attachment 379605 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js:168
> +            const shouldBlackbox = true;
> +            {
> +                const caseSensitive = true;

Nit: This style bothers me more than it likely should… but I'd add an empty line after const shouldBlackbox.

> Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js:173
> +            }
> +            {
> +                const isRegex = true;

Ditto. I would at least ad an empty line between these blocks (for my sanity.)

> Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js:447
> +        console.assert(shouldBlackbox !== ((this.blackboxDataForSourceCode(sourceCode) || {}).type === DebuggerManager.BlackboxType.URL));

Nit: Group the assert with the asserts before and put the blank line below it instead?

> Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js:471
> +            let data = {
> +                url: regex.source,
> +                caseSensitive: !regex.ignoreCase,
> +            };

Nit: Blank lines before and after..

> Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js:478
> +        }
> +        this._blackboxedPatternsSetting.save();

Nit: Blank line between.

> Source/WebInspectorUI/UserInterface/Images/Hide.svg:27
> +        <symbol id="hide">

"hide" is an odd name, and could be confused. Maybe "eye"?

> Source/WebInspectorUI/UserInterface/Images/Hide.svg:36
> +    <svg id="currentColor"><use xlink:href="#hide"/></svg>
> +    <svg id="white"><use xlink:href="#hide"/></svg>
> +    <svg id="black"><use xlink:href="#hide"/></svg>

Clever use of vars, symbols and currentColor! Awesome that all works.

> Source/WebInspectorUI/UserInterface/Views/BlackboxSettingsView.js:129
> +        });
> +        this._blackboxPatternCodeMirrorMap.set(regex, urlCodeMirror);

Nit: Blank line between.

> Source/WebInspectorUI/UserInterface/Views/BlackboxSettingsView.js:176
> +        };
> +        urlCodeMirror.addKeyMap({

Nit: Blank line between.

> Source/WebInspectorUI/UserInterface/Views/BlackboxSettingsView.js:180
> +        });
> +        urlCodeMirror.on("blur", update);

Nit: Blank line between.

> Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js:183
> +        if (WI.DebuggerManager.supportsBlackboxingScripts()) {
> +            this._blackboxSettingsView = new WI.BlackboxSettingsView;
> +            this.addSettingsView(this._blackboxSettingsView);
> +        }

Nit: Blank lines before and after.

> Source/WebInspectorUI/UserInterface/Views/SourceCodeTreeElement.js:226
> +            }
> +            console.assert(this._toggleBlackboxedImageElement.title);

Nit: Blank line between.
Comment 18 Devin Rousso 2019-10-11 19:42:31 PDT
Comment on attachment 379605 [details]
Patch

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

>> Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js:471
>> +            };
> 
> Nit: Blank lines before and after..

I'd put one before, but I'd personally not add one after cause it's used right after and only right after, so it's "related".

>> Source/WebInspectorUI/UserInterface/Views/BlackboxSettingsView.js:129
>> +        this._blackboxPatternCodeMirrorMap.set(regex, urlCodeMirror);
> 
> Nit: Blank line between.

This is a pretty common pattern we have for adding objects we just created to some sort of collection.  I'd also "ditto" my last response.

>> Source/WebInspectorUI/UserInterface/Views/BlackboxSettingsView.js:176
>> +        urlCodeMirror.addKeyMap({
> 
> Nit: Blank line between.

Ditto

>> Source/WebInspectorUI/UserInterface/Views/BlackboxSettingsView.js:180
>> +        urlCodeMirror.on("blur", update);
> 
> Nit: Blank line between.

Ditto
Comment 19 Devin Rousso 2019-10-11 19:53:27 PDT
Created attachment 380811 [details]
Patch
Comment 20 WebKit Commit Bot 2019-10-11 20:57:51 PDT
Comment on attachment 380811 [details]
Patch

Clearing flags on attachment: 380811

Committed r251039: <https://trac.webkit.org/changeset/251039>
Comment 21 WebKit Commit Bot 2019-10-11 20:57:53 PDT
All reviewed patches have been landed.  Closing bug.
Comment 22 Ling Ho 2019-10-15 14:45:00 PDT
<rdar://problem/56213014>