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

Time Origin in Workers - official moment of creation or not? #41

Closed
JosephPecoraro opened this issue Jan 29, 2017 · 3 comments
Closed

Comments

@JosephPecoraro
Copy link

The spec specifically mentions that the time origin for Workers:

The time origin is the time value from which time is measured:

This doesn't appear to match implementations. For example:

<script>
let blob = new Blob([`console.log(performance.now())`]);
let url = URL.createObjectURL(blob);
console.log(performance.now());
setTimeout(() => { worker = new Worker(url); }, 1000);
</script>

Based on the spec, I would expect very low numbers for both logs. The one on the page because it is very close to the page's load. The one in the worker because it is very close to the worker's load.

Implementations are consistent but differ from the spec:

  • Chrome (v55)
    page: 13.495
    worker: 1047.71

  • Firefox (v51)
    page: 17.135
    worker: 1032.125

I am unable to test on Edge. If someone could include their numbers that would be fantastic!

@JosephPecoraro
Copy link
Author

JosephPecoraro commented Jan 29, 2017

It may make sense for a DedicatedWebWorker's time origin to match the Document that spawned it. That would make it so developers can more easily reason about timestamps gathered in both the document and its workers. This convenience breaks down for SharedWorkers, so I would say it is not worth making different behavior for different types of Workers.

I suggest keeping the spec as is, filing bugs on browsers, and adding a web platform test to cover this. But I want to make sure my interpretation of the spec and test case is correct.

@igrigorik
Copy link
Member

I suggest keeping the spec as is, filing bugs on browsers, and adding a web platform test to cover this. But I want to make sure my interpretation of the spec and test case is correct.

It is. You can scrub through the past conversations on translateTime to see us covering the same points.. Also why we introduced https://w3c.github.io/hr-time/#dom-performance-timeorigin in L3.

WPT tests + bugs is the right path forward.

@JosephPecoraro
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants