Bug 155629 - Web Inspector: Adding a new console message shouldn't modify DOM when the console log is hidden
Summary: Web Inspector: Adding a new console message shouldn't modify DOM when the con...
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: Nikita Vasilyev
URL:
Keywords: InRadar
: 152221 157186 (view as bug list)
Depends on: 157294
Blocks: 136984 142011
  Show dependency treegraph
 
Reported: 2016-03-18 00:34 PDT by Nikita Vasilyev
Modified: 2016-05-03 18:18 PDT (History)
8 users (show)

See Also:


Attachments
WIP (7.23 KB, patch)
2016-03-18 00:40 PDT, Nikita Vasilyev
nvasilyev: review-
nvasilyev: commit-queue-
Details | Formatted Diff | Diff
[Animated GIF] With the patch applied (203.41 KB, image/gif)
2016-03-18 00:45 PDT, Nikita Vasilyev
no flags Details
WIP (8.16 KB, patch)
2016-03-21 22:51 PDT, Nikita Vasilyev
nvasilyev: review-
nvasilyev: commit-queue-
Details | Formatted Diff | Diff
WIP (13.59 KB, patch)
2016-04-22 16:13 PDT, Nikita Vasilyev
nvasilyev: review-
nvasilyev: commit-queue-
Details | Formatted Diff | Diff
Patch (12.79 KB, patch)
2016-04-29 12:58 PDT, Nikita Vasilyev
timothy: review-
Details | Formatted Diff | Diff
Patch (13.31 KB, patch)
2016-04-30 13:42 PDT, Nikita Vasilyev
timothy: review+
timothy: commit-queue-
Details | Formatted Diff | Diff
Patch (13.16 KB, patch)
2016-05-02 11:26 PDT, Nikita Vasilyev
nvasilyev: commit-queue-
Details | Formatted Diff | Diff
Patch (13.26 KB, patch)
2016-05-02 12:59 PDT, Nikita Vasilyev
no flags Details | Formatted Diff | Diff
Patch (14.03 KB, patch)
2016-05-03 14:11 PDT, Nikita Vasilyev
timothy: review+
Details | Formatted Diff | Diff
Patch (14.06 KB, patch)
2016-05-03 14:25 PDT, Nikita Vasilyev
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 2016-03-18 00:34:20 PDT
Steps:
1. Open about:blank
2. Open Web Inspector console
3. Enter the following code:
   setInterval(function() {console.log(Math.random())}, 1)
4. Open Elements tab

Expected:
No repaints in the console prompt area.
Web Inspector UI remains responsive.

Actual:
Console prompt gets repainted every millisecond.
Web Inspector UI quickly becomes unresponsive.
Comment 1 Radar WebKit Bug Importer 2016-03-18 00:34:44 PDT
<rdar://problem/25235470>
Comment 2 Nikita Vasilyev 2016-03-18 00:40:46 PDT
Created attachment 274389 [details]
WIP

Known issues:
1. Clicking on the dashboard error/warning/log icons for
   the first time doesn't filter out console messages.
2. The unread messages dot in the console scope bar selector is broken.
Comment 3 Nikita Vasilyev 2016-03-18 00:45:20 PDT
Created attachment 274390 [details]
[Animated GIF] With the patch applied

No repaints around console prompt area.
Comment 4 Nikita Vasilyev 2016-03-21 22:51:46 PDT
Created attachment 274642 [details]
WIP

> Known issues:
> 1. Clicking on the dashboard error/warning/log icons for
>    the first time doesn't filter out console messages.
> 2. The unread messages dot in the console scope bar selector is broken.

These are fixed.

Known issue:
- Repeat counter sometimes doesn't update.
Comment 5 Nikita Vasilyev 2016-04-22 16:13:07 PDT
Created attachment 277111 [details]
WIP

This WIP doesn't have any known bugs.
It also fixes bug 156484.
Comment 6 Joseph Pecoraro 2016-04-22 16:34:46 PDT
Comment on attachment 277111 [details]
WIP

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

> Source/WebInspectorUI/UserInterface/Models/ConsoleCommand.js:26
> +WebInspector.ConsoleCommand = class ConsoleMessage extends WebInspector.Object

Nit: class name here is wrong.
Comment 7 Nikita Vasilyev 2016-04-26 13:30:02 PDT
(In reply to comment #5)
> Created attachment 277111 [details]
> WIP
> 
> This WIP doesn't have any known bugs.
> It also fixes bug 156484.

Known issues:
Repeat counts don't update if the console message hasn't been rendered.

Steps:
1. Open Elements tab, hide split console.
2. Click on <button onclick="console.log(1)">click</button> twice.
3. Open console tab.

Also, WebInspector.JavaScriptLogViewController#appendImmediateExecutionWithResult
still modifies DOM right away.

I'm working on it.
Comment 8 Nikita Vasilyev 2016-04-29 12:58:00 PDT
Created attachment 277728 [details]
Patch
Comment 9 Timothy Hatcher 2016-04-30 10:48:48 PDT
Comment on attachment 277728 [details]
Patch

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

Looks good, with one comment.

> Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js:269
> +        if (WebInspector.consoleContentView.visible)
> +            requestAnimationFrame(() => this.renderPendingMessages());

You should only need to do this one. As-is it will request multiple animation frames if there are multiple messages appended. You should keep the animation frame identifier around and not request again if we already have a pending request.
Comment 10 Nikita Vasilyev 2016-04-30 13:42:14 PDT
Created attachment 277831 [details]
Patch
Comment 11 Timothy Hatcher 2016-04-30 16:59:19 PDT
Comment on attachment 277831 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js:273
> +    renderPendingMessages()

You should cancel and clear _scheduledRenderIdentifier here, otherwise the call in shown() will still let the rAF fire once.

> Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js:300
> +        let renderOnRequestAnimationFrame = function() {
> +            this._scheduledRenderIdentifier = 0;
> +            this.renderPendingMessages();
> +        }.bind(this);

If you clear in renderPendingMessages() you would not need to do this here.
Comment 12 Timothy Hatcher 2016-05-02 09:10:28 PDT
*** Bug 152221 has been marked as a duplicate of this bug. ***
Comment 13 Nikita Vasilyev 2016-05-02 11:26:07 PDT
Created attachment 277914 [details]
Patch
Comment 14 Nikita Vasilyev 2016-05-02 11:48:38 PDT
*** Bug 157186 has been marked as a duplicate of this bug. ***
Comment 15 Nikita Vasilyev 2016-05-02 12:08:45 PDT
Comment on attachment 277914 [details]
Patch

[Error] TypeError: undefined is not an object (evaluating 'lastMessageView.message.type')
	renderPendingMessages (JavaScriptLogViewController.js:286)
Comment 16 Nikita Vasilyev 2016-05-02 12:59:27 PDT
Created attachment 277926 [details]
Patch
Comment 17 WebKit Commit Bot 2016-05-02 14:00:33 PDT
Comment on attachment 277926 [details]
Patch

Clearing flags on attachment: 277926

Committed r200337: <http://trac.webkit.org/changeset/200337>
Comment 18 WebKit Commit Bot 2016-05-02 14:00:38 PDT
All reviewed patches have been landed.  Closing bug.
Comment 19 Joseph Pecoraro 2016-05-02 17:15:55 PDT
Comment on attachment 277926 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Views/LogContentView.js:127
> +        this._logViewController.renderPendingMessages();

This should probably call super.shown().
Comment 20 WebKit Commit Bot 2016-05-02 19:54:52 PDT
Re-opened since this is blocked by bug 157294
Comment 21 Nikita Vasilyev 2016-05-03 12:36:49 PDT
(In reply to comment #20)
> Re-opened since this is blocked by bug 157294

Steps:
1. Open Elements tab, keep the split console *closed*
2. Type 1+1 in the console prompt
3. Press Enter

Web Inspector freezes

https://github.com/WebKit/webkit/blob/eeda037140553acaab606ed51ed69af023582116/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js#L273

renderPendingMessages calls _didRenderConsoleMessageView,
which opens the split console,
which triggers WebInspector.LogContentView#shown,
which calls renderPendingMessages again.
Comment 22 Nikita Vasilyev 2016-05-03 14:11:44 PDT
Created attachment 278023 [details]
Patch
Comment 23 Timothy Hatcher 2016-05-03 14:20:36 PDT
Comment on attachment 278023 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Views/LogContentView.js:128
> +    shown()
> +    {
> +        this._logViewController.renderPendingMessages();
> +    }

This should call super.shown() to be future proof.
Comment 24 Nikita Vasilyev 2016-05-03 14:22:40 PDT
(In reply to comment #23)
> Comment on attachment 278023 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=278023&action=review
> 
> > Source/WebInspectorUI/UserInterface/Views/LogContentView.js:128
> > +    shown()
> > +    {
> > +        this._logViewController.renderPendingMessages();
> > +    }
> 
> This should call super.shown() to be future proof.

Yes! I saw Joe's comment but forgot about it.
Comment 25 Nikita Vasilyev 2016-05-03 14:25:53 PDT
Created attachment 278024 [details]
Patch

Added super.shown().
Comment 26 WebKit Commit Bot 2016-05-03 18:18:41 PDT
Comment on attachment 278024 [details]
Patch

Clearing flags on attachment: 278024

Committed r200401: <http://trac.webkit.org/changeset/200401>
Comment 27 WebKit Commit Bot 2016-05-03 18:18:46 PDT
All reviewed patches have been landed.  Closing bug.