-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
use monotonic clock for elapsed time #5870
Conversation
Not sure what this error is about: https://travis-ci.org/videojs/video.js/builds/507654239#L295 Some vjsstandard thing? |
To get around the vjsstandard linter issue you will want to use I also see that we use After looking into this a bit it seems like It also looks like Google recommends using |
I doubt that anywhere we use it, we really have any performance implications to using Date.now() vs new Date().getTime() vs performance.now(). |
Agreed, the term
Will take a look. Thanks for the review. |
Another mysterious failure: https://travis-ci.org/videojs/video.js/builds/513188217#L432 |
Looks like the test that's failing is the node require test. Looks like one of the usages of window.performance is being run directly on require and it's crashing. We should either do null checks and fallback to Date.now() or potentially just not do anything if it doesn't exist. It should basically just not throw any errors in a node require rather than have to work. |
Should I just revert the changes in |
OK, so I looked into the travis issue and it is related to the change in EDIT: EX: const now = (window.performance && window.performance.now && window.performance.now()) || Date.now();
...
const elIdAttr = 'vdata' + Math.floor(now); |
will do. |
Made changes, up for review. |
ooh, good call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think anyone should rely on vdata_
and if they do they should be using something like vdata_\d+
to find it. I don't have any concerns with this change.
with this sinon stub in place, a change in |
it actually seems the stub isn't initialized properly when moving it to the global-shims module.. any idea? |
the stub in global-shim may be happening to early, it may be necessarily to do after every usage of useFakeTimers. |
sounds good. |
Can you update sinon in the master branch? |
if you use npm 6, it should update the package-lock file as well, you'd want to check it in. But yeah, we can take a look at updating sinon in a separate PR as it's possible things will break. |
I've opened #5953 for this. We shouldn't add workarounds for testing in prod code, but simply make sure the test env is setup properly. |
@thijstriemstra I updated sinon in #5954 which is now in master, if you rebase/merge in master, it should fix the build. |
Not sure what's up with netlify, but it isn't actually required to pass. |
Ready for review. |
Thanks @thijstriemstra! |
Hi, The usage performance.now is not "secure" in all occurrences. In html5.js and dom-data.js it is fine. in systems where Performance API is not available it will generate an error. would be nice to fix this. |
Which ones? |
Hi, we had problems on older LG and Samsung TV sets. |
@fermarci you can use a polyfill for these devices: https://gist.github.com/paulirish/5438650#gistcomment-2976364 |
Description
Improve accuracy using
performance.now()
See https://developers.google.com/web/updates/2012/08/When-milliseconds-are-not-enough-performance-now
Specific Changes proposed
All major browsers support this for ages, although IE supports it since v10, according to https://developer.mozilla.org/en-US/docs/Web/API/Performance/now