Bug 160207 - Web Inspector: Window resize causes TimelineOverview graph elements to be repositioned
Summary: Web Inspector: Window resize causes TimelineOverview graph elements to be rep...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P1 Normal
Assignee: Matt Baker
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-07-26 13:29 PDT by Matt Baker
Modified: 2016-12-20 16:16 PST (History)
3 users (show)

See Also:


Attachments
[Video] Timeline overview resize bug (667.77 KB, video/mp4)
2016-07-26 13:29 PDT, Matt Baker
no flags Details
[Video] TimelineRuler divider calculation (1.12 MB, video/mp4)
2016-12-18 21:02 PST, Matt Baker
no flags Details
Patch (3.01 KB, patch)
2016-12-19 10:43 PST, Matt Baker
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews117 for mac-yosemite (1.76 MB, application/zip)
2016-12-19 15:00 PST, Build Bot
no flags Details
Patch (3.01 KB, patch)
2016-12-19 16:02 PST, Matt Baker
no flags Details | Formatted Diff | Diff
Patch (3.24 KB, patch)
2016-12-20 12:56 PST, 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-07-26 13:29:23 PDT
Created attachment 284622 [details]
[Video] Timeline overview resize bug

Summary:
Window resize causes TimelineOverview graph elements to be repositioned. Graph elements and ruler markers are shifted horizontally during resize once the window is too narrow to show the current time marker (see attachment).

Steps to Reproduce:
1. Record a timeline
2. Zoom (wheel) the overview graph until the current time marker is just before the right edge of the window
3. Resize window, decreasing width until current time marker should no longer fit
Expected:
  => Current time marker becomes hidden
Actual:
  => Current time marker moves with the window edge, and is always visible. Graph elements shift as well.
Comment 1 Radar WebKit Bug Importer 2016-07-26 13:29:40 PDT
<rdar://problem/27553228>
Comment 2 Timothy Hatcher 2016-08-05 10:08:38 PDT
This is pretty bad! Good find.
Comment 3 Matt Baker 2016-12-18 20:42:15 PST
Investigating this for a *very* long time uncovered a subtle bug in TimelineRuler.prototype.layout which made it possible for dividers and labels to remain fixed while the ruler start time is changing.

So, it turns out the issue here isn't that graph elements are being repositioned, but that ruler's elements *aren't* being repositioned.
Comment 4 Matt Baker 2016-12-18 21:02:47 PST
Created attachment 297451 [details]
[Video] TimelineRuler divider calculation

The way ruler dividers are calculated leads to the bug. The video shows the dividerData calculation updating in real-time, as the window is resized.

Note that resizing the window doesn't cause dividers to be added or removed, or for their positions to change. The logged values (Inspector² console) show that the data is changing however, apparently because `dividerData.lastTime` holds the actual end time and not the calculated time of the last visible divider. A related point: the divider count is shows as 7, when only 5 dividers are visible.
Comment 5 Matt Baker 2016-12-19 10:43:54 PST
Created attachment 297467 [details]
Patch
Comment 6 Build Bot 2016-12-19 15:00:11 PST
Comment on attachment 297467 [details]
Patch

Attachment 297467 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/2755902

New failing tests:
imported/w3c/web-platform-tests/IndexedDB/interfaces.worker.html
Comment 7 Build Bot 2016-12-19 15:00:14 PST
Created attachment 297482 [details]
Archive of layout-test-results from ews117 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews117  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 8 Matt Baker 2016-12-19 16:02:33 PST
Created attachment 297488 [details]
Patch
Comment 9 BJ Burg 2016-12-20 11:47:15 PST
Comment on attachment 297488 [details]
Patch

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

r=me

> Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js:453
> +        let firstDividerTime = (Math.ceil((this._startTime - this._zeroTime) / sliceTime) * sliceTime) + this._zeroTime;

I had trouble understanding the derivation of this. My understanding is that we just start placing slices starting from zero time, then use the first one that's greater than startTime. Can you put this into a comment, as the formula is kind of inscrutable (I had to diagram it on a whiteboard).

It might be more readable to use the iterative solution rather than the closed formula, but if there's a comment explaining they are equivalent, then this can stay as-is.
Comment 10 Matt Baker 2016-12-20 11:55:40 PST
Comment on attachment 297488 [details]
Patch

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

>> Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js:453
>> +        let firstDividerTime = (Math.ceil((this._startTime - this._zeroTime) / sliceTime) * sliceTime) + this._zeroTime;
> 
> I had trouble understanding the derivation of this. My understanding is that we just start placing slices starting from zero time, then use the first one that's greater than startTime. Can you put this into a comment, as the formula is kind of inscrutable (I had to diagram it on a whiteboard).
> 
> It might be more readable to use the iterative solution rather than the closed formula, but if there's a comment explaining they are equivalent, then this can stay as-is.

The `firstDividerTime` formula hasn't changed, just `lastDividerTime`. This was being set equal to the end time, not the time position of the last divider. The effect was that the check for Object.shallowEqual would fail as long as the end time changed between layouts, ensuring the ruler is updated as the view scrolls/zooms. But when the overview start time changes while the end time remains fixed (the original steps to reproduce), the Object.shallowEqual check will pass and early return, so long as the first divider doesn't change.
Comment 11 BJ Burg 2016-12-20 12:05:27 PST
Comment on attachment 297488 [details]
Patch

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

>>> Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js:453
>>> +        let firstDividerTime = (Math.ceil((this._startTime - this._zeroTime) / sliceTime) * sliceTime) + this._zeroTime;
>> 
>> I had trouble understanding the derivation of this. My understanding is that we just start placing slices starting from zero time, then use the first one that's greater than startTime. Can you put this into a comment, as the formula is kind of inscrutable (I had to diagram it on a whiteboard).
>> 
>> It might be more readable to use the iterative solution rather than the closed formula, but if there's a comment explaining they are equivalent, then this can stay as-is.
> 
> The `firstDividerTime` formula hasn't changed, just `lastDividerTime`. This was being set equal to the end time, not the time position of the last divider. The effect was that the check for Object.shallowEqual would fail as long as the end time changed between layouts, ensuring the ruler is updated as the view scrolls/zooms. But when the overview start time changes while the end time remains fixed (the original steps to reproduce), the Object.shallowEqual check will pass and early return, so long as the first divider doesn't change.

Oh. You should have put this comment into the changelog, as it actually tells me why the changes are necessary. "Update ruler layout to calculate accurate divider count and divider times," kinda goes without saying.
Comment 12 Matt Baker 2016-12-20 12:56:48 PST
Created attachment 297548 [details]
Patch
Comment 13 WebKit Commit Bot 2016-12-20 16:16:35 PST
Comment on attachment 297548 [details]
Patch

Clearing flags on attachment: 297548

Committed r210046: <http://trac.webkit.org/changeset/210046>
Comment 14 WebKit Commit Bot 2016-12-20 16:16:39 PST
All reviewed patches have been landed.  Closing bug.