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

Define performance.transferable + TransferableDOMHighResTimeStamp interface #25

Closed
wants to merge 1 commit into from

Conversation

igrigorik
Copy link
Member

Preview: https://rawgit.com/w3c/hr-time/transferable/index.html

Attempt to flush out a replacement for performance.translateTime, as discussed in #22 (comment):

  • To transfer a DOMHighResTimeStamp between globals developer needs to first "wrap it" via performance.transferable(), which returns a TransferableDOMHighResTimeStamp object.
  • To resolve the transferred timestamp from a different time origin, the developer calls time() on the received TransferableDOMHighResTimeStamp object. Calling the method invokes a calculation which maps the wrapped DOMHighResTimeStamp and it's origin into current global's time origin and returns a new DOMHighResTimeStamp.

Take a look at the updated example in the intro section for a hands-on example. Suggestions on names, wording, etc., welcome! I believe this would resolve #21, #22, #23.

With respect to use cases and motivation (i.e. why is Date() not sufficient?): same reasons why DOMHighResTimeStamp was created in the first place; if we assume a world where workers are often used to perform and offload computation / network activity / etc, it's important that we provide and enable access to monotonic + high-resolution time.

/cc @sicking @DigiTec @annevk @bzbarsky @natduca

@toddreifsteck
Copy link
Member

Had a talk with @DigiTec about this. This doesn't cover the performance.getEntries().toJson() being transferred across context boundaries. That seems like an important sub-scenario. What do you think?

@igrigorik
Copy link
Member Author

Hmm, I'm not sure we can solve the toJson() case... as that, once again, would require embedding some global timestamp in the JSON itself, which runs into same privacy issues as we discussed in #22.

That said, the use case itself is an important one: you want to exchange PerformanceEntry between different contexts and have the ability to resolve their timestamps in different origins.

The first idea that comes to mind is to extend performance.transferable() to accept PerformanceEntry objects, which would then similarly be wrapped can be resolved in a different context?

(Arguably we could automate all this... E.g. each PerformanceEntry object could maintain a reference to the time time-origin where it was created and automatically resolve the timestamps by checking the current vs created time-origin and doing the translation? This does add overhead.. but it's completely transparent to the user, which is a pretty big plus. Crazytalk?)

@toddreifsteck
Copy link
Member

Are we 100% sure that the privacy issue in #22 can't be mitigated?

@igrigorik
Copy link
Member Author

I don't see how, but if you have ideas or suggestions I'm all ears..

@toddreifsteck
Copy link
Member

#26 contains a focus on solving this issue and discussing various privacy spins....

@igrigorik
Copy link
Member Author

Closing, based on discussions in #22.

@igrigorik igrigorik closed this May 18, 2016
@igrigorik igrigorik deleted the transferable branch October 7, 2016 18:54
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

Successfully merging this pull request may close these issues.

Should time origin be defined in terms of a monotonic clock?
2 participants