You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In workers (and other non-Window global objects), we can call performance.mark named with a PerformanceTiming attribute but we cannot access those marks in performance.measure because it will throw, e.g.:
// worker.jsperformance.mark('navigationStart');// no errorperformance.measure('failure','navigationStart');// throws an Exception
This makes the mark less useful and it's easy to cause an exception and stop the script with it. I find it unintuitively inconsistent with Window global objects which don't let you create performance marks with these names.
I think that the behavior in non-Window global objects should either be:
the user cannot create a PerformanceMark with a PerformanceTiming attribute markName (i.e. the same as Window global objects)
the user can call performance.measure with PerformanceTiming attributes without throwing an error (i.e. no restrictions around using PerformanceTiming attributes as markNames in non-Window global objects)
Run with, e.g.tar -xf testcase.tar.gz && cd testcase && python3 -m http.server, opening localhost:8000/testcase.html in the browser, and opening the browser console.
Spec references
3.2.1 The PerformanceMark Constructor allows you to create a PerformanceMark whose markName is an attribute in PerformanceTiming if the global object is not a Window (e.g. a worker).
Makes sense to not have those "special names" apply to workers. A broader question: are the special names useful in the Window context? They are definitely adding a bunch of overhead..
A broader question: are the special names useful in the Window context? They are definitely adding a bunch of overhead..
As a user, I don't like the 'navigationStart' name, especially as it's a shorthand for 0, which is now very straightforward in L3. Turns out I also chimed in on this topic a few years back: #44 and said
Also: I know the L1 spec provided the hack of using 'navigationStart' as a string, and that the WG is interested in removing that approach.
Using provided start/end times (from L3) is so superior to passing this magic string or the awkward undefined argument.
In workers (and other non-Window global objects), we can call
performance.mark
named with a PerformanceTiming attribute but we cannot access those marks inperformance.measure
because it will throw, e.g.:This makes the mark less useful and it's easy to cause an exception and stop the script with it. I find it unintuitively inconsistent with Window global objects which don't let you create performance marks with these names.
I think that the behavior in non-Window global objects should either be:
performance.measure
with PerformanceTiming attributes without throwing an error (i.e. no restrictions around using PerformanceTiming attributes as markNames in non-Window global objects)Test case
testcase.tar.gz
Run with, e.g.
tar -xf testcase.tar.gz && cd testcase && python3 -m http.server
, openinglocalhost:8000/testcase.html
in the browser, and opening the browser console.Spec references
3.2.1 The PerformanceMark Constructor allows you to create a PerformanceMark whose
markName
is an attribute in PerformanceTiming if the global object is not a Window (e.g. a worker).This behavior that causes
performance.measure
to throw is defined in 4.2 Convert a name to a timestamp – throw an error if the global object is not a Window, which is called by 4.1 Convert a mark to a timestamp, which is called by 3.1.3 measure() method.The text was updated successfully, but these errors were encountered: