Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYNTAX_ERR exception for markName argument #1

Closed
plehegar opened this issue Feb 3, 2015 · 14 comments
Closed

SYNTAX_ERR exception for markName argument #1

plehegar opened this issue Feb 3, 2015 · 14 comments
Assignees
Milestone

Comments

@plehegar
Copy link
Member

plehegar commented Feb 3, 2015

From https://lists.w3.org/Archives/Public/public-web-perf/2015Jan/0070.html
[[
In the Exceptions section of the User Timing spec for the mark method, it
states:

"Throws a SYNTAX_ERR exception if the markName argument is the same name as
an attribute in the PerformanceTiming interface."

In Gecko we implemented bug 760851 [1] out-of-spec and added toJSON to
the PerformanceTiming interface to get a JSON version of the timing
attributes. Following this reasoning, then toJSON being a
PerformanceTiming attribute may need to throw a SYNTAX_ERR when used as a
performance marker name:

performance.mark('toJSON');

So we need some clarification of the spec to determine whether all
attributes of the PerformanceTiming interface should throw if used as
marker names, or only those specifically defined by the spec.
[1]
https://bugzilla.mozilla.org/show_bug.cgi?id=760851

]]

@igrigorik
Copy link
Member

I believe we discussed this on one of the conf calls and the conclusion was that we should allow any/all metric names. Any objections? /cc @toddreifsteck

@toddreifsteck
Copy link
Member

I'm unsure where this bit of the spec originated but I just tested Chrome and IE. Both allow name, duration, startTime, entryType to be used. I believe we should cut this from the spec. Should we follow up with Firefox? I did not check their prerelease builds of Gecko.

@igrigorik
Copy link
Member

/cc @mina @marcoscaceres

@plehegar
Copy link
Member Author

plehegar commented Jun 4, 2015

@toddreifsteck do you/we have a test somewhere that I can run on firefox?

@plehegar
Copy link
Member Author

We have a test at:
http://w3c-test.org/user-timing/test_user_timing_mark_exceptions.html
if you add the other methods, like toJSON, duration, entryType, or startTime, those will be allowed in FF and Chrome.

@marcoscaceres
Copy link
Member

Sorry, I've not been following this spec or it's implementation in Gecko at all :( I don't know if I can be much here.

@plehegar
Copy link
Member Author

So, it looks like we got mixed up in measure() and the fix would impact this issue:

  1. we store DOMHighResStamp, ie PerformanceMeasure will return DOMHighResStamp values.
    https://w3c.github.io/user-timing/#performancemeasure
  2. if startMark or endMark use is one of the attributes in the PerformanceTiming interface, "the value of that attribute is used as the end DOMHighResTimeStamp time value"
    https://w3c.github.io/user-timing/#h-dom-performance-measure

However, PerformanceTiming doesn't contain DOMHighResTimeStamp values:
http://www.w3.org/TR/navigation-timing-2/#the-performancetiming-interface

imho, this should be changed to refer to PerformanceNavigationTiming attributes instead.

Now, if we do that, can one store the mark "prerenderSwitch" or "nextHopProtocol"?

@plehegar
Copy link
Member Author

Btw, if the answer to my last question is "no, you should raise a SyntaxError instead", then what should we do with performance.measure("myMeasure", "prerenderSwitch", "nextHopProtocol") ?

@igrigorik
Copy link
Member

Btw, if the answer to my last question is "no, you should raise a SyntaxError instead", then what should we do with performance.measure("myMeasure", "prerenderSwitch", "nextHopProtocol") ?

Ugh, that's messy. Related, what about measure("domInteractive", ...)

Wondering if we should consider option (3): remove that capability entirely, since it's just syntax sugar for measure('thing', performance.timing.x, performance.timing.y)?

@plehegar
Copy link
Member Author

"domInteractive" is ok as far as I know. We don't raise SYNTAX_ERR on the measureName.
We could indeed change the function prototype from
measure(DOMString, DOMString, DOMString)
to
measure(DOMString, DOMHighResTimeStamp, DOMHighResTimeStamp)
or
measure(DOMString, (DOMString | DOMHighResTimeStamp), (DOMString | DOMHighResTimeStamp))

However, would we break anyone if we remove
measure('thing', "responseStart", "responseEnd") ?

@igrigorik
Copy link
Member

Ah, right, apologies about the confusion.

  • measure(name) should be measured against time origin - i.e. "from navigationStart to the current time" is incorrect #11.
  • On the one hand I understand the desire to have the convenience of referencing PerformanceNavigationTiming attributes, but on the other it creates a bunch of complications (current and moving forward)
    • we have PerformanceNavigationTiming that are not timestamps
    • assuming we unpack redirects into separate entries in the future, there won't be just a single PerformanceNavigationTiming entry; we'd reference the last one? =/
    • there is no PerformanceNavigationTiming in worker

That said, I'm not sure if/what we'd break if we were to remove that functionality at this point.

If we want to keep it backwards compatible, perhaps we should explicitly list the names of "special markNames" that would only be applicable in Window context?

@plehegar
Copy link
Member Author

Note that #13 doesn't solve this issue.

@igrigorik igrigorik added this to the Level 2 milestone Jun 29, 2016
@igrigorik
Copy link
Member

igrigorik commented Sep 20, 2016

After re-reading this thread, my proposal is...

If the global object [HTML51] is a Window object, and markName uses the same name as a read only attribute (excluding toJSON) in PerformanceTiming interface, throw a SyntaxError.

  • Limit above behavior to Window contexts; PerformanceTiming doesn't exist for Workers.
  • Keep the exceptions scoped to PerformanceTiming (i.e. do not update it to PerformanceNavigationTiming). My hunch is that the whole exception business is not something we would do if we were writing the spec today, but for historical reasons I think we need to maintain this behavior; let's freeze the list of attributes on NT1 and move on.

Thoughts / objections?

@igrigorik igrigorik assigned igrigorik and unassigned plehegar Sep 20, 2016
@toddreifsteck
Copy link
Member

Discussed with Ilya/Yoav. The original purpose of this exception is to protect measure string lookups on nav timing 1 from being corrupted by user timings that are injected.

performance.measure('foo','navigationStart','fetchStart')

A simple spec update to limit the attributes protected to only include the readonly attributes will mean that the following does not need to throw for the spec to be followed:

performance.mark('toJSON')

igrigorik added a commit that referenced this issue Sep 20, 2016
Raised whenever name of the mark matches a readonly attribute of
Performance Timing (NT1) interface. toJSON is writable [1] and is thus
excluded. Related discussion in [2].

Closes #1.

[1] https://heycam.github.io/webidl/#es-serializer
[2] #1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants