w3c / performance-timeline

Performance Timeline
https://w3c.github.io/performance-timeline/
Other
111 stars 34 forks source link

Queue the entry should require a global object as input #162

Closed npm1 closed 4 years ago

npm1 commented 4 years ago

Currently, the algorithm to queue an entry only receives the newEntry. This algorithm then proceeds to obtain the relevant global object from the entry. This should work fine for cases like UserTiming, when mark() and measure() are called via JavaScript and it's clear what the relevant global object is. However, there are other cases like Paint Timing and Long Tasks, where the relevant global object is not clear at all since the calls occur on the event loop processing model.

Therefore, we should add a parameter to this algorithm which contains the relevant global object, and we should make sure that all of the callers use those two parameters (i.e. the entry and the global object). An alternative would be to make the second parameter optional and only use it when needed, but I think it's probably better to make this parameter required so that are callers are properly thinking about what the global object should be.

rniwa commented 4 years ago

I'm not sure that the relevant global object is obvious even in the case of user timing because you can call another realm's user timing API like this: iframe.contentWindow.performance.measure(~).

npm1 commented 4 years ago

Hmm interesting. But relevant global object of a platform object is always defined, so perhaps what needs to change is not this spec. Instead, every spec that creates a new PerformanceEntry must specify the realm under which that object is being constructed, as specified in https://heycam.github.io/webidl/#new. This way there'd be no confusion about what the relevant global object is. Does that make sense?

rniwa commented 4 years ago

Hmm interesting. But relevant global object of a platform object is always defined, so perhaps what needs to change is not this spec. Instead, every spec that creates a new PerformanceEntry must specify the realm under which that object is being constructed, as specified in https://heycam.github.io/webidl/#new. This way there'd be no confusion about what the relevant global object is. Does that make sense?

Yes, that would do. I think I had pointed that out somewhere but can't find where.

npm1 commented 4 years ago

Closing as the ones remaining are tracked on separate issues.