ded / morpheus

A Brilliant Animator
504 stars 57 forks source link

requestAnimationFrame gives unexpected arguments on Chrome 24.0.1312.52 #43

Closed Radagaisus closed 11 years ago

Radagaisus commented 11 years ago

Hi,

I don't know why, and I don't see any mention of it, but Chrome changed the argument passed to requestAnimationFrame's callback function, and it's not the current epoch time any more.

Morpheus live examples don't seem to break, but pretty much every animation I have on my project is now broken. The complete callback functions are never called.

> webkitRequestAnimationFrame(function() { console.log(arguments); });
419
[46905.322000035085]

Commenting out win.webkitRequestAnimationFrame and win.requestAnimationFrame fixes the problem for now. Returning a function that wraps around the requestAnimationFrame inside frame() is probably a decent fix. I can write a pull request but it's 6am, so I'm not going to do this right now.

rvagg commented 11 years ago

see https://github.com/ded/morpheus/pull/36/files for full gory details. are you using the latest version?

Radagaisus commented 11 years ago

I am not on the latest version.

Does this line start = perf && perf.now ? perf.now() : +new Date() fixes the problem?

rvagg commented 11 years ago

Sort of, it's a bit more involved than that. Upgrade to the latest version and try it out. Chrome is now using its own high perf timer as a reference for rAF so Morpheus needs to detect whether the browser is using epoch-based times or perf.now()-based times. Keep in mind that this probably isn't the end of the story; other browsers are likely to shift on rAF, Mozilla was proposing something different still a while back so it's still a little in flux.

rvagg commented 11 years ago

I should have pointed you to the discussion in https://github.com/ded/morpheus/pull/36 rather than the actual diff cause that wasn't the final merged version but it has most of the discussion around the issue. #38 was the final version, see that diff for the code details.

Radagaisus commented 11 years ago

Thanks! It's hard living on the cutting edge ;)