-
Notifications
You must be signed in to change notification settings - Fork 20.6k
New Flag: jQuery.support.raf - Allow disabling requestAnimationFrame for people having issues with #9381 #436
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
Conversation
…equestAnimationFrame to allow people to work around #9381
So I think it was @jaubourg who suggested we create |
Have we decided that the flag will happen? We should probably discuss this pull, louisremi's pull, and, I don't see this one in the queue anymore, but one that runs a separate timer to handle the queue. I'm not sure which I'm in favor of or if we should do some combination. There's also another option that we haven't discussed yet: remove requestAnimationFrame altogether. |
It's quite obvious we need to seriously discuss the issue because whatever decision we take we'll have a huge impact on the future of animations in jQuery. We can add jQuery.support.raf (I prefer things short ;)) right now to deal with the immediate problem. It's somehow clean in the sense it won't give us a gigantic headache if and when we find a proper solution and actually refactor the animation system properly (we will still have to feature test raf anyway). |
jQuery.suport.raf/jQuery.support.requestAnimationFrame sounds like an acceptable stop-gap solution, but given that (as Timmy mentions) there are a number of available pulls which alternative solutions, perhaps the best idea would be to schedule this for discussion in one of the next -dev meetings. Let's make sure whatever is decided is documented well..it can get confusing enough as it is at the moment :) |
Although I am definitely in favor of having jQuery.support.raf (was in my initial implementation of raf), this does not solve #9381. (again, because setInterval "slows down" in inactive tabs Firefox and Chrome). |
Yeah we're dealing with several problems here. For 1.6.3 the ability to just plain disable rAF would be fine, but we may want to do something more ambitious for 1.7 -- if we can just figure out what that is! |
Here is the link to my alternative fix: #446 |
I'm still convinced we need to talk with browser vendors about this setTimeout/setDelay slow down. It just doesn't make sense and not just in the context of animations. I'd really like if we could see about fighting this atrocity before attempting to circumvent it, because if we start and circumvent it (in a very blind-man-trying-to-see kind of way btw), then we're basically condonning it. This slow down is part of no standard (I'll be so bold as to say it actually contradicts existing standards) and will cause more troubles in the long run than what it is trying to achieve. We're not in the IE6 days anymore: we can and will voice our opinion if and when browsers go haywire. |
Given that we've said 1.7 is probably not going to get wrapped up until some time in the fall, I think we definitely have enough scope to engage in some level of discussions with browser vendors about the issues here - it certainly wouldn't hurt. I guess the question is, is the general feeling that this should be done or that we should internally decide on a workaround/solution based on the numerous pulls?. I share some of Julian's concerns with the slow-down causing more headaches in the long-term. |
@jaubourg, read it and weep: http://www.w3.org/TR/html5/timers.html I think we need to accept this will happen, work around it as well as we can, and get the word out about what it means. |
I agree with jaubourg. The argument is reasonable. That will probably mean waiting on louisremi's pull so we can see if anything will come out of a discussion with browser vendors. As far as the queue timer, it sounds like that will have a better chance at being efficient in the effects rewrite jaubourg and gnarf and I want to push for 1.8. So, maybe for 1.6.3 AND 1.7, we can add jQuery.support.raf and tackle this problem more thoroughly when 1.8 rolls around. |
Just now seeing dave's comment. Well, that may change everything I just said. |
The "thread" bug about sites broken by this change is here: https://bugzilla.mozilla.org/show_bug.cgi?id=652472 Currently the policy is to contact developers and ask them to fix it. If dozens of websites are reported to break, the change might well be reverted. But this behavior has been in Firefox and Chrome "dev builds" for quite some time now, and the Web still runs. |
I doubt the browser vendors realized in advance what a mess this makes of existing code. It has always been true that Still, it's a very good idea to do this by default for the reasons mentioned by the W3C page; it saves lots of battery life. I would prefer that browser makers hold their ground and we work together on ways to unbreak the old code. |
@timmywil et all - The "other" solution that @jaubourg recommended is still just a piss poor untested draft branch I threw together here https://github.com/gnarf37/jquery/compare/ticket_9381_2 If we like this approach I can turn it into a better method and put it into a pull request. |
Regarding
The TLDR: It makes sense in either place, and if you guys think |
I'm going to close this PR since it's likely we'll need to rethink and rework the animation timer/rAF issue when it finally lands. |
Effects: Adding
jQuery.support.raf
boolean to allow disabling the use of requestAnimationFrame to allow people to work around #9381http://jqbug.com/9381
Just submitting for some discussion. The general idea here is you would set
jQuery.support.raf = false
in a codebase where you haven't gotten around to properly implementing design patterns necessary to avoid queuing new animations while they aren't running.I feel that no matter how much we try to educate the best practices mentioned in the ticket, there will still be situations where the end user can't manage to set up the animation queueing properly.
As coded, this flag can not be changed while animations are running, and thus, should only be set once (and only to false) before any animations are queued.
It is likely possible to replace the current
requestAnimationFrame
&setInterval
code with a "recursive setTimeout pattern" that more closely approximates the rAF implementations. If we were to do that, you could actually probably shorten the whole thing quite effectively, and allow toggling this flag while running.