Bug 157588 - Web Inspector: Improve snapshot selection in heap allocations overview graph
Summary: Web Inspector: Improve snapshot selection in heap allocations overview graph
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: Matt Baker
URL:
Keywords: InRadar
Depends on: 157593
Blocks:
  Show dependency treegraph
 
Reported: 2016-05-11 14:58 PDT by Matt Baker
Modified: 2016-05-12 03:33 PDT (History)
9 users (show)

See Also:


Attachments
[Video] snapshot selection (397.59 KB, video/mp4)
2016-05-11 14:58 PDT, Matt Baker
no flags Details
[Video] better snapshot selection (625.24 KB, video/mp4)
2016-05-11 16:09 PDT, Matt Baker
no flags Details
[Patch] Proposed Fix (15.91 KB, patch)
2016-05-11 20:38 PDT, Matt Baker
no flags Details | Formatted Diff | Diff
[Patch] Proposed Fix (16.36 KB, patch)
2016-05-12 03:11 PDT, Matt Baker
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Baker 2016-05-11 14:58:11 PDT
Created attachment 278670 [details]
[Video] snapshot selection

* SUMMARY
Improve snapshot selection in heap allocations overview graph.

- Now that http://webkit.org/b/156963 has landed, selecting snapshot icons make use of TimelineOverGraph.selectedRecord.
- Viewing a snapshot (by clicking an icon in the overview graph, or making a navigation bar selection) should make the icon in the graph appear "selected" (see video).
Comment 1 Radar WebKit Bug Importer 2016-05-11 15:00:01 PDT
<rdar://problem/26231245>
Comment 2 Timothy Hatcher 2016-05-11 15:07:32 PDT
Neat!
Comment 3 Matt Baker 2016-05-11 16:09:15 PDT
Created attachment 278678 [details]
[Video] better snapshot selection

Added styles for a selected marker in a deselected graph, and the ability to select a graph by clicking a marker.
Comment 4 Matt Baker 2016-05-11 16:09:33 PDT
(In reply to comment #3)
> Created attachment 278678 [details]
> [Video] better snapshot selection
> 
> Added styles for a selected marker in a deselected graph, and the ability to
> select a graph by clicking a marker.

This requires https://bugs.webkit.org/show_bug.cgi?id=157593.
Comment 5 Matt Baker 2016-05-11 20:38:01 PDT
Created attachment 278690 [details]
[Patch] Proposed Fix
Comment 6 Joseph Pecoraro 2016-05-11 21:08:41 PDT
Comment on attachment 278690 [details]
[Patch] Proposed Fix

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

r=me, but feel free to put up another patch given my comments.

> Source/WebInspectorUI/ChangeLog:37
> +        * UserInterface/Views/HeapAllocationsTimelineView.js:
> +        (WebInspector.HeapAllocationsTimelineView.prototype.get selectionPathComponents):
> +        Current content view may be null if path components are requested
> +        after data grid has been removed but before the snapshot view is added.

I'm not sure I understand this. The three show functions showHeapSnapshotList, showHeapSnapshotTimelineRecord, showHeapSnapshotDiff tend to be very conservative and only issue path components changes at the end. And adding/removing a subview only happens in these.

This seems fine, but when is the currentContentView null during a selectionPathComponents call?

> Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.css:40
> +.timeline-overview-graph.heap-allocations > img.snapshot.selected {
> +    content: url(../Images/HeapSnapshotSelected.svg);
> +}

We should probably do something about non-Apple ports, but that is not new here.

> Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js:82
> +            imageElement.addEventListener("click", () => this.selectedRecord = record);

With arrow functions, I have been pushing the style of using braces if the return value is not significant. (No braces, actually returns the value of the body statement). So I'd keep the braces here, because I think it ends up being clearer. You can look at it and know the return value is not significant.

    imageElement.addEventListener("click", () => { this.selectedRecord = record });

> Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js:84
> +            this._recordImageElements.set(record, imageElement);

Seems like it might be easier / more efficient to just put the imageElement as a Symbol / private property on the record:

    record[WebInspector.HeapAllocationsTimelineOverviewGraph.RecordElementAssociationSymbol] = imageElement;

Instead of clearing and populating a Map every layout.

> Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js:103
> +        this._selectedImageElement = null;

This could be done in the bail. That way there is always only one assignment.

> Source/WebInspectorUI/UserInterface/Views/TimelineOverviewGraph.js:251
>          this._scheduledSelectedRecordLayoutUpdateIdentifier = requestAnimationFrame(function() {
>              this._scheduledSelectedRecordLayoutUpdateIdentifier = undefined;
> +            console.assert(this instanceof WebInspector.TimelineOverviewGraph);
>              this.updateSelectedRecord();
> +
> +            this.dispatchEventToListeners(WebInspector.TimelineOverviewGraph.Event.RecordSelected, {record: this.selectedRecord});
>          }.bind(this));

Lets use an arrow function here and eliminate the bind! I'm not sure the assert is needed.

> Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js:634
> +        let record = event.data.record;
> +        let timeline = event.data.timeline;

Might read easier as:

    let {record, timeline} = event.data;
Comment 7 Matt Baker 2016-05-12 03:11:28 PDT
Created attachment 278725 [details]
[Patch] Proposed Fix
Comment 8 WebKit Commit Bot 2016-05-12 03:33:26 PDT
Comment on attachment 278725 [details]
[Patch] Proposed Fix

Clearing flags on attachment: 278725

Committed r200767: <http://trac.webkit.org/changeset/200767>
Comment 9 WebKit Commit Bot 2016-05-12 03:33:32 PDT
All reviewed patches have been landed.  Closing bug.