BackburnerJS / backburner.js

A rewrite of the Ember.js run loop as a generic microlibrary
MIT License
392 stars 80 forks source link

setTimeout problems on iOS 6 #57

Closed robharper closed 10 years ago

robharper commented 10 years ago

This is actually a browser bug/quirk but seriously affects backburner. If setTimeout is called while a page is scrolling on iOS 6.0, the timeout never fires. Obviously this affects backburner in many ways.

http://jsbin.com/agebuqeP/2 shows this in action. Load this page on a device running iOS 6.0. Pinch-zoom the page. You'll see the big square change color but no alert will appear. Try on a device running iOS 7 and the square will change color and the alert will appear.

Fixing this is non-trivial but there are work-arounds such as this: https://gist.github.com/ronkorving/3755461

I wanted to log this so other people experiencing bizarre behaviour in their backburner/Ember apps have an explanation.

stefanpenner commented 10 years ago

@robharper ya we run with that gist in production for our iOS 6 users. We have been for over a year now, with no issues.

The question is, do we bundle this with backburner, and user agent sniff? Or do we document.

stefanpenner commented 10 years ago

@robharper their are actually other time dilation issues + replay issues during some of the various resume scenarios on iOS 6 ( and I believe 7), backburner itself mitigate some but some are tricky to solve.

robharper commented 10 years ago

I'd say document. iOS 6 market share is currently ~20% [1] and the majority of that is 6.1.x [2].

[1] https://mixpanel.com/trends/#report/ios_7/from_date:-73,to_date:0 [2] https://mixpanel.com/trends/#report/ios_frag/from_date:-75,to_date:0

stefanpenner commented 10 years ago

@robharper I wonder if we should just include it. + opt in via snif. I would hate for people to have to uncover this problem in an ad-hoc way. I actually feel pretty bad that we have subjected you and likely many other people to this problem by not already including it.

@tomdale @ebryn @kselden @lukemelia i would love your feedback.

robharper commented 10 years ago

Including the scroll event workaround in backburner would definitely save some people a few headaches. However, setTimeout use is so prevalent in other libraries (for example, jQuery animations, CSS3 transition end fallbacks, etc) that unless you monkeypatch window.setTimeout itself people are still going to have to deal with the issue.

krisselden commented 10 years ago

@stefanpenner we switched to using the requestAnimationFrame workaround instead of that gist and there are other variants. I lean toward documenting it as it affects other libraries like jquery and they don't include it.

ebryn commented 10 years ago

I think it should be documented. I'd rather people have a single app-wide solution than per library ones.

stefanpenner commented 10 years ago

@kselden we can role the fix to only affect backburners usage of setTimeout

@ebryn sounds good.

stefanpenner commented 10 years ago

@robharper got a chance to submit the readme additions?

stefanpenner commented 10 years ago

as iOS 8 is nearly here and considering the huge upgrade % by apple users, we can likely close this. I will gladly accept a README addition outlineing this issue