Bug 144681 - Web Inspector: Activity Viewer does not update on "clear all console messages"
Summary: Web Inspector: Activity Viewer does not update on "clear all console messages"
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-05-06 04:59 PDT by Tobias Reiss
Modified: 2015-05-29 16:08 PDT (History)
8 users (show)

See Also:


Attachments
patch (2.39 KB, patch)
2015-05-29 14:45 PDT, Tobias Reiss
no flags Details | Formatted Diff | Diff
patch (2.45 KB, patch)
2015-05-29 15:08 PDT, Tobias Reiss
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Reiss 2015-05-06 04:59:12 PDT
* SUMMARY
Clearing all console messages does not affect the Activity Viewer.

* STEPS TO REPRODUCE
1. Go to Console Tab
2. Type: console.error("error");
3. Activity Viewer shows one error
4. Clear log
5. Activity Viewer still shows one error
Comment 1 Radar WebKit Bug Importer 2015-05-06 04:59:29 PDT
<rdar://problem/20834726>
Comment 2 Nikita Vasilyev 2015-05-07 03:34:23 PDT
I was able to reproduce this bug by pressing the trash icon on the right top corner of the console.

Clearing the console by Control L works as expected.
Comment 3 Tobias Reiss 2015-05-08 11:08:54 PDT
Looks like a regression that was introduced with
- http://trac.webkit.org/changeset/180721
- https://github.com/WebKit/webkit/commit/b4acedf6
Comment 4 Tobias Reiss 2015-05-08 16:07:22 PDT
LogManager listens on "Console.messagesCleared" events from Backend. A typical stack of events looks like this on a page reload:

- load page that contains a console.log("test")
- "WebInspector.ConsoleObserver.messageAdded" // from Backend, prints "test"
- reload page
- "WebInspector.ConsoleObserver.messagesCleared" // from Backend
- "WebInspector.Frame.Event.MainResourceDidChange" // from ?, indicates "session start"
- "WebInspector.ConsoleObserver.messageAdded" // from Backend, prints "test"
- "WebInspector.ConsoleObserver.messagesCleared" // from Backend, why??

Conclusion
The former "messagesCleared" can be instrumented to clear on reload or not.
The latter "messagesCleared" breaks our logic and should be avoided.
Comment 5 Tobias Reiss 2015-05-26 16:51:53 PDT
APIs that let you clear the Console:

- clear() and console.clear() are handled by Backend only [1]. WORKS
- Button and Context Menu are handled Frontend only [2] & [3]. DOES NOT WORK
- Clear/Keep on reload are handled by both. [1] & [4]. DOES NOT WORK
- Shortcuts are handled by both [5] & [1]. WORKS

WORKS means that the Console was cleared and Activity Viewer was updated correctly
DOES NOT WORK means that the Activity Viewer wasn't updated correctly.

I don't see a clear pattern here. Either the Backend should call "messagesCleared" more often and Frontend should get ride of some duplicated event handlers or the other way round. Right now the strategy looks inconsistent and order of event handlers is important.

[1] https://github.com/WebKit/webkit/blob/91ba8734ceadd8fd3b73942008358ef8a4a81715/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp#L107

[2] https://github.com/WebKit/webkit/blob/f647f216a7e9a781ba96bc823787fdf667f868ea/Source/WebInspectorUI/UserInterface/Views/LogContentView.js#L72

[3] https://github.com/WebKit/webkit/blob/f647f216a7e9a781ba96bc823787fdf667f868ea/Source/WebInspectorUI/UserInterface/Views/LogContentView.js#L344

[4] https://github.com/WebKit/webkit/blob/f647f216a7e9a781ba96bc823787fdf667f868ea/Source/WebInspectorUI/UserInterface/Views/LogContentView.js#L306

[5] https://github.com/WebKit/webkit/blob/846f78432c3b5b041177716350dc1335c8d45097/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js#L52-L53
Comment 6 Tobias Reiss 2015-05-29 14:45:56 PDT
Created attachment 253917 [details]
patch
Comment 7 Joseph Pecoraro 2015-05-29 14:57:49 PDT
Comment on attachment 253917 [details]
patch

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

r=me! One step forward, good catch.

> Source/WebInspectorUI/UserInterface/Views/LogContentView.js:634
> +    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=145466

I prefer writing bug links with their title. So:

    // FIXME: <https://webkit.org/b/145466> Web Inspector: Activity Viewer does not update on "Clear Log on reload"
Comment 8 Tobias Reiss 2015-05-29 15:08:53 PDT
Created attachment 253922 [details]
patch
Comment 9 Joseph Pecoraro 2015-05-29 15:17:05 PDT
Comment on attachment 253922 [details]
patch

r=me
Comment 10 WebKit Commit Bot 2015-05-29 16:08:02 PDT
Comment on attachment 253922 [details]
patch

Clearing flags on attachment: 253922

Committed r185015: <http://trac.webkit.org/changeset/185015>
Comment 11 WebKit Commit Bot 2015-05-29 16:08:11 PDT
All reviewed patches have been landed.  Closing bug.