Bug 200652 - Web Inspector: Debugger: add a global breakpoint for pausing in the next microtask
Summary: Web Inspector: Debugger: add a global breakpoint for pausing in the next micr...
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:
 
Reported: 2019-08-12 18:20 PDT by Devin Rousso
Modified: 2019-08-19 23:59 PDT (History)
11 users (show)

See Also:


Attachments
Patch (64.75 KB, patch)
2019-08-19 00:20 PDT, Devin Rousso
joepeck: review+
Details | Formatted Diff | Diff
[Image] After Patch is applied (49.18 KB, image/png)
2019-08-19 00:49 PDT, Devin Rousso
no flags Details
Patch (64.75 KB, patch)
2019-08-19 23:09 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (64.82 KB, patch)
2019-08-19 23:14 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-08-12 18:20:24 PDT
This would be similar to the "All Animation Frames"/"All Timeouts"/"All Intervals"/"All Events" breakpoints, except that it would also work for JSContext inspection.
Comment 1 Devin Rousso 2019-08-19 00:20:11 PDT
Created attachment 376667 [details]
Patch
Comment 2 EWS Watchlist 2019-08-19 00:21:39 PDT Comment hidden (obsolete)
Comment 3 Devin Rousso 2019-08-19 00:49:12 PDT
Created attachment 376671 [details]
[Image] After Patch is applied
Comment 4 Joseph Pecoraro 2019-08-19 22:27:06 PDT
Comment on attachment 376667 [details]
Patch

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

Nice! Good tests. r=me

Seems like perhaps the only remaining script entry points (that I know of) are:

  (1) API Entry points
    - Ex. JSEvaluteScript / -[JSContext evaluteScript:]
  (2) Normal Script entry points for a Program / Module
    - Ex. <script src="..." async>
    - Ex. eval('...')

  (3) Observer Script handlers
    - Ex. PerformanceObserver, IntersectionObserver, handlers
  (4) APIs with callbacks that aren't events or Observers
    - Ex. geolocation callbacks


(1) and (2) seem useful for users to break on. Maybe a Breakpoint on script entry "All Script Entries" / "All Script Evaluations" would be good.

(3) and (4) cases seem like Events / specific functions akin to setTimeout. Seems overkill to call them out specifically though.

Anything I missed worth considering?

> Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js:152
> +        // COMPATIBILITY (iOS 12): DebuggerAgent.setPauseOnMicrotasks did not exist yet.

Nit: I think we should use (iOS 13) in all of these compatibility comments, as it did not exist in iOS 13.0.

> Source/WebInspectorUI/UserInterface/Images/Microtask.svg:3
> +<svg xmlns="http://www.w3.org/2000/svg" id="root" version="1.1" viewBox="0 0 16 16">

Sometimes we have `id="root"` and other times we don't. Not sure why... I normally remove it if I don't see a need for it.
Comment 5 Devin Rousso 2019-08-19 23:09:05 PDT
Comment on attachment 376667 [details]
Patch

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

> Seems like perhaps the only remaining script entry points (that I know of) are:
> 
>   (1) API Entry points
>     - Ex. JSEvaluteScript / -[JSContext evaluteScript:]
>   (2) Normal Script entry points for a Program / Module
>     - Ex. <script src="..." async>
>     - Ex. eval('...')
> 
>   (3) Observer Script handlers
>     - Ex. PerformanceObserver, IntersectionObserver, handlers
>   (4) APIs with callbacks that aren't events or Observers
>     - Ex. geolocation callbacks
> 
> 
> (1) and (2) seem useful for users to break on. Maybe a Breakpoint on script entry "All Script Entries" / "All Script Evaluations" would be good.
I like it!  I see this being useful along the lines (somewhat) of the Inspector Bootstrap Script concept <https://webkit.org/b/195847>.

> (3) and (4) cases seem like Events / specific functions akin to setTimeout. Seems overkill to call them out specifically though.
Perhaps we should consider these as microtasks.  It looks like `MutationObserver` actually uses a form of microtask, whereas `IntersectionObserver` uses a timer and `PerformanceObserver` uses a task queue (run loop).  I'm not against the idea of creating a "Observer Callback..." breakpoint that can be customized by observer type (like "Event Breakpoint..."), but if we create a "All Script Entries" breakpoint then these would likely be covered by that as well (microtasks and events too).

> Anything I missed worth considering?
I feel like with the addition of the "All Microtasks" breakpoint, all of the various ways to enter script (other than (1) and (2) above) are covered as part of one of the "categories" we already have breakpoints for (e.g. events, timers, etc).  I think the next useful thing to do is to provide breakpoint actions for all of the non-JavaScript breakpoints, as well as getting full stack trace information (where applicable).

I also have been pondering the idea of extending URL breakpoints to work for _any_ situation where network activity is triggered by script (e.g. `img.src = "..."`).

>> Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js:152
>> +        // COMPATIBILITY (iOS 12): DebuggerAgent.setPauseOnMicrotasks did not exist yet.
> 
> Nit: I think we should use (iOS 13) in all of these compatibility comments, as it did not exist in iOS 13.0.

LOL 😂 bad copypasta.  Nice catch!

>> Source/WebInspectorUI/UserInterface/Images/Microtask.svg:3
>> +<svg xmlns="http://www.w3.org/2000/svg" id="root" version="1.1" viewBox="0 0 16 16">
> 
> Sometimes we have `id="root"` and other times we don't. Not sure why... I normally remove it if I don't see a need for it.

This is needed by `WI.ImageUtilities.useSVGSymbol`.
```
    // URL must contain a fragment reference to a graphical element, like a symbol. If none is given
    // append #root which all of our SVGs have on the top level <svg> element.
    if (!url.includes("#"))
        url += "#root";
```
Comment 6 Devin Rousso 2019-08-19 23:09:37 PDT
Created attachment 376748 [details]
Patch
Comment 7 WebKit Commit Bot 2019-08-19 23:12:09 PDT Comment hidden (obsolete)
Comment 8 Devin Rousso 2019-08-19 23:14:51 PDT
Created attachment 376749 [details]
Patch
Comment 9 WebKit Commit Bot 2019-08-19 23:58:21 PDT
Comment on attachment 376749 [details]
Patch

Clearing flags on attachment: 376749

Committed r248894: <https://trac.webkit.org/changeset/248894>
Comment 10 WebKit Commit Bot 2019-08-19 23:58:23 PDT
All reviewed patches have been landed.  Closing bug.
Comment 11 Radar WebKit Bug Importer 2019-08-19 23:59:18 PDT
<rdar://problem/54500837>