New issue
Advanced search Search tips

Issue 923952 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

[UserTiming] Measure API: end mark is set incorrectly when start mark is absent

Project Member Reported by maxlg@chromium.org, Yesterday (32 hours ago)

Issue description

Chrome Version: 73.0.3680.0 (Developer Build) (64-bit)
OS: Linux

What steps will reproduce the problem?
(1) Execute the following codes:
const endMark = performance.mark("endMark")
const measureEntry = performance.measure("measureEntry", undefined, "endMark");
console.log("endMark.startTime="+endMark.startTime);
console.log("measureEntry end="+(measureEntry.start + measureEntry.duration));
(2) Observe whether the two results are equal.

What is the expected result?
The result should be equal. According to the spec https://w3c.github.io/user-timing/#measure-method, |measureEntry|'s end should be |endMark|'s start time:
"Compute end time as follows:
If endMark is present, let end time be the value returned by running the convert a mark to a timestamp algorithm passing in endMark."

What happens instead?
The two time are different.


Please use labels and text to provide additional information.
The culprit seems to be this line:
https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/timing/performance_user_timing.cc?q=usertiming+package:%5Echromium$&dr=CSs&l=217
---------------------------------------
if (start.IsNull()) {
    end_time = performance_->now();
}
---------------------------------------

These lines stem back to 2012.
 

Comment 1 by maxlg@chromium.org, Yesterday (32 hours ago)

Status: Assigned (was: Untriaged)

Comment 2 by maxlg@chromium.org, Yesterday (32 hours ago)

Description: Show this description

Comment 3 by maxlg@chromium.org, Yesterday (32 hours ago)

Summary: [UserTiming] Measure API: when start is unset and end is set, the (start + duration) of the entry is not the set end (was: [UserTiming] When start is unset and end is set, end becomes now)

Comment 4 by maxlg@chromium.org, Yesterday (32 hours ago)

Description: Show this description

Comment 5 by maxlg@chromium.org, Yesterday (32 hours ago)

Description: Show this description

Comment 6 by maxlg@chromium.org, Yesterday (32 hours ago)

Summary: [UserTiming] Measure API: end mark is set correctly when start mark is absent (was: [UserTiming] Measure API: when start is unset and end is set, the (start + duration) of the entry is not the set end)

Comment 7 by maxlg@chromium.org, Yesterday (32 hours ago)

Summary: [UserTiming] Measure API: end mark is set incorrectly when start mark is absent (was: [UserTiming] Measure API: end mark is set correctly when start mark is absent)

Comment 8 by maxlg@chromium.org, Yesterday (32 hours ago)

Description: Show this description

Comment 9 by npm@chromium.org, Yesterday (31 hours ago)

:O good catch! Longstanding bug, I guess skipping start is infrequent enough that no one noticed...

Comment 10 Deleted

Comment 11 by maxlg@google.com, Today (14 hours ago)

I've found a test for the behavior. It did try to catch this case, but it tolerates an error. The rationale is probably that we do clapping on the time - so the recorded end time and the output end time has some error in between, which is also where the bug sneaked in. Now that we have L3 where we can set mark time directly. We can create new test to make an exact comparison.

https://cs.chromium.org/chromium/src/third_party/blink/web_tests/external/wpt/user-timing/measure.html?q=user-timing/measure+package:%5Echromium$&dr&l=270

Sign in to add a comment