Bug 140090

Summary: Web Inspector: Timeline: when Network Requests view is selected, in progress requests are absent.
Product: WebKit Reporter: Jonathan Wells <jonowells>
Component: Web InspectorAssignee: Jonathan Wells <jonowells>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, graouts, joepeck, jonowells, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
[SCREENSHOT] Incorrect behavior.
none
[PATCH] Proposed fix.
joepeck: review-, joepeck: commit-queue-
[SCREENSHOT] Correct behavior after patch.
none
[PATCH] Proposed fix 2.
timothy: review-
[PATCH] Proposed fix, different approach.
timothy: review-
[PATCH] Proposed fix, adjusted.
timothy: review-
[PATCH] Proposed fix 3. none

Description Jonathan Wells 2015-01-05 12:44:46 PST
Created attachment 243991 [details]
[SCREENSHOT] Incorrect behavior.

When a network request is in progress and the timeline is recording, the request shows in the table if the combined (default) view state is active. However if Network Requests is selected, the request will not appear until/unless the request finishes.
Comment 1 Radar WebKit Bug Importer 2015-01-05 12:45:02 PST
<rdar://problem/19377211>
Comment 2 Jonathan Wells 2015-01-05 13:02:21 PST
Created attachment 243994 [details]
[PATCH] Proposed fix.
Comment 3 Jonathan Wells 2015-01-05 13:02:52 PST
Created attachment 243995 [details]
[SCREENSHOT] Correct behavior after patch.
Comment 4 Joseph Pecoraro 2015-01-05 15:25:32 PST
Comment on attachment 243994 [details]
[PATCH] Proposed fix.

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

> Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js:134
> +        WebInspector.timelineSidebarPanel.updateFilter();

updateFilter is a big hammer. Putting and updateFilter in updateLayout, means the filter compares every tree element on every rAF. I wonder if there is a more performant way to fix this. We don't need to constantly check every request.

> Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js:138
>          this._processPendingRecords();

I would expect something along the lines of _processPendingRecords, e.g. a new _updateOngoingRequests which would make something visible if an ongoing request enters the selected time range.

We could keep a small list of all the ongoing network requests, and just iterate through that list in each updateLayout to see if we should show a record or not.
Comment 5 Jonathan Wells 2015-01-06 19:43:05 PST
Created attachment 244127 [details]
[PATCH] Proposed fix 2.

Updated patch with a drive-by fix. Leaving the code as is per conversation with Joe and per the pattern set up in OverviewTimelineView.js. Will look to optimize in the future.
Comment 6 Timothy Hatcher 2015-01-06 22:11:47 PST
Comment on attachment 244127 [details]
[PATCH] Proposed fix 2.

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

> Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js:134
> +        WebInspector.timelineSidebarPanel.updateFilter();

This still seems heavy handed. Can you try hooking up this to a new event listener? Yes, OverviewTimelineView does it, but only if the current time changed, not during any other layout. updateLayout is called in many other cases, like resizing the Inspector. And calling updateFilter during those cases would be wrong and cause slowness in the UI.

Listen for WebInspector.Timeline.Event.TimesUpdated in the NetworkTimelineView constructor (next to the Event.RecordAdded listener). I suspect that will fire when we need to update the filters. Only the network timeline has dynamic timeline records, so it is the only one that needs to listen for that event.

Maybe even set a temp property flag in the TimesUpdated listener, that causes updateLayout to call updateFilter() next time. That way the updateFilter() happens during layout and not counter to the layout.
Comment 7 Jonathan Wells 2015-01-07 17:26:00 PST
Created attachment 244228 [details]
[PATCH] Proposed fix, different approach.

This approach was recommended by Timothy.
Comment 8 Timothy Hatcher 2015-01-07 17:44:48 PST
Comment on attachment 244228 [details]
[PATCH] Proposed fix, different approach.

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

> Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js:-123
> -                this.dispatchEventToListeners(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange);

We need to find a new home for this code.

> Source/WebInspectorUI/UserInterface/Views/TimelineContentView.js:369
> +        WebInspector.timelineSidebarPanel.updateFilter();

My gut says this should happen before the updateLayoutIfNeeded calls.
Comment 9 Jonathan Wells 2015-01-08 12:38:44 PST
Comment on attachment 244228 [details]
[PATCH] Proposed fix, different approach.

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

>> Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js:-123
>> -                this.dispatchEventToListeners(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange);
> 
> We need to find a new home for this code.

I'm wondering if this shouldn't just stay put, but with the updateFilter() line removed?
Comment 10 Jonathan Wells 2015-01-08 12:54:06 PST
Comment on attachment 244228 [details]
[PATCH] Proposed fix, different approach.

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

>>> Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js:-123
>>> -                this.dispatchEventToListeners(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange);
>> 
>> We need to find a new home for this code.
> 
> I'm wondering if this shouldn't just stay put, but with the updateFilter() line removed?

Actually I think the whole piece should probably stay. I'll submit with this back in place.
Comment 11 Jonathan Wells 2015-01-08 13:07:40 PST
Created attachment 244288 [details]
[PATCH] Proposed fix, adjusted.

Added back lines to OverviewTimelineView.js
Comment 12 Timothy Hatcher 2015-01-08 13:18:12 PST
Comment on attachment 244228 [details]
[PATCH] Proposed fix, different approach.

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

>>>> Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js:-123
>>>> -                this.dispatchEventToListeners(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange);
>>> 
>>> We need to find a new home for this code.
>> 
>> I'm wondering if this shouldn't just stay put, but with the updateFilter() line removed?
> 
> Actually I think the whole piece should probably stay. I'll submit with this back in place.

Then updateFilter would happen twice. This updateLayout is happening because of the time change in _updateTimes, where you added updateFilter below.

The filtering can hide or show the selected row. In that case we need to update the navigation bar selection. I'm thinking updateFilter() should do that itself.
Comment 13 Timothy Hatcher 2015-01-08 13:20:46 PST
Comment on attachment 244288 [details]
[PATCH] Proposed fix, adjusted.

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

> Source/WebInspectorUI/UserInterface/Views/TimelineContentView.js:365
> +        WebInspector.timelineSidebarPanel.updateFilter();

OverviewTimelineView will do two updateFilter calls now. See previous comment.
Comment 14 Jonathan Wells 2015-01-08 15:40:59 PST
(In reply to comment #12)
> Comment on attachment 244228 [details]
> [PATCH] Proposed fix, different approach.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=244228&action=review
> 
> >>>> Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js:-123
> >>>> -                this.dispatchEventToListeners(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange);
> >>> 
> >>> We need to find a new home for this code.
> >> 
> >> I'm wondering if this shouldn't just stay put, but with the updateFilter() line removed?
> > 
> > Actually I think the whole piece should probably stay. I'll submit with this back in place.
> 
> Then updateFilter would happen twice. This updateLayout is happening because
> of the time change in _updateTimes, where you added updateFilter below.
> 
> The filtering can hide or show the selected row. In that case we need to
> update the navigation bar selection. I'm thinking updateFilter() should do
> that itself.

That works. What is the best approach to dispatch the SelectionPathComponentsDidChange event properly from the OverviewTimelineView? ContentView#showContentViewForRepresentedObject()?
Comment 15 Jonathan Wells 2015-01-12 16:00:51 PST
(In reply to comment #12)
> Comment on attachment 244228 [details]
> [PATCH] Proposed fix, different approach.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=244228&action=review
> 
> >>>> Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js:-123
> >>>> -                this.dispatchEventToListeners(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange);
> >>> 
> >>> We need to find a new home for this code.
> >> 
> >> I'm wondering if this shouldn't just stay put, but with the updateFilter() line removed?
> > 
> > Actually I think the whole piece should probably stay. I'll submit with this back in place.
> 
> Then updateFilter would happen twice. This updateLayout is happening because
> of the time change in _updateTimes, where you added updateFilter below.
> 
> The filtering can hide or show the selected row. In that case we need to
> update the navigation bar selection. I'm thinking updateFilter() should do
> that itself.

How best can I accurately gather whether the selectedTreeElement has changed to hidden inside updateFilter()?
Comment 16 Timothy Hatcher 2015-01-12 16:09:39 PST
Comment on attachment 244228 [details]
[PATCH] Proposed fix, different approach.

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

>>>>>>> Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js:-123
>>>>>>> -                this.dispatchEventToListeners(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange);
>>>>>> 
>>>>>> We need to find a new home for this code.
>>>>> 
>>>>> I'm wondering if this shouldn't just stay put, but with the updateFilter() line removed?
>>>> 
>>>> Actually I think the whole piece should probably stay. I'll submit with this back in place.
>>> 
>>> Then updateFilter would happen twice. This updateLayout is happening because of the time change in _updateTimes, where you added updateFilter below.
>>> 
>>> The filtering can hide or show the selected row. In that case we need to update the navigation bar selection. I'm thinking updateFilter() should do that itself.
>> 
>> That works. What is the best approach to dispatch the SelectionPathComponentsDidChange event properly from the OverviewTimelineView? ContentView#showContentViewForRepresentedObject()?
> 
> How best can I accurately gather whether the selectedTreeElement has changed to hidden inside updateFilter()?

Check selectedTreeElement && selectedTreeElement.hidden before doing the filtering, like this code did.
Comment 17 Jonathan Wells 2015-01-12 17:52:26 PST
Created attachment 244484 [details]
[PATCH] Proposed fix 3.
Comment 18 WebKit Commit Bot 2015-01-12 21:18:06 PST
Comment on attachment 244484 [details]
[PATCH] Proposed fix 3.

Clearing flags on attachment: 244484

Committed r178315: <http://trac.webkit.org/changeset/178315>
Comment 19 WebKit Commit Bot 2015-01-12 21:18:12 PST
All reviewed patches have been landed.  Closing bug.