且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iOS Javascript DOM“冻结”

更新时间:2023-12-05 15:09:46

iOS 6.x暂停所有事件计时器以响应诸如滚动的触摸事件,并且一旦事件完成,就不会再次启动所有定时器。这是一个众所周知的iOS 6错误,这是非常烦人的。它几乎打破了视差和东西。有些人已经采用了自己的滚动功能。



这是另一个同一主题的***:
iOS 6 safari,setInterval没有被触发



和另一个:
iphone / ipad中的setInterval暂停Safari)在滚动



这里是最接近你的错误报告的事情(苹果公司不会公开bug维护完美的错觉,所以开发人员自己的bug网站): http://openradar.appspot.com/12756410



这一段代码将解冻在页面滚动期间由iOS破坏/丢失/销毁的定时器: https://gist.github.com/ronkorving/3755461



这是另一个修复冻结的尝试: iOS 6 js事件功能未调用如果有setTimeout在其中



不幸的是,没有什么可以做的事情触发事件WHILE页面滚动。喜欢在向上滚动页面时淡出一个back-to-top链接。当涉及到滚动时,iOS6无法揉搓它的肚子,拍拍它的头。 (iOS5工作正常,btw。这是一个回归)


A few questions here:

  1. Is there anyway to keep iOS from freezing javascript on the page while scrolling?

  2. Does iOS freeze javascript when your in another tab or if you switch apps?

  3. Are there any other major javascript limitations on iOS?

iOS 6.x suspends all event timers in response to touch events like scrolling and has a tendency not to start up all the timers again once the event is done. It's a well known iOS 6 bug that is super-annoying. It pretty much breaks parallax and stuff. Some people have resorted to building their own scroll functionality.

Here's another *** on the same topic: iOS 6 safari, setInterval doesn't get fired

and another: setInterval pauses in iphone/ipad (mobile Safari) during scrolling

and here is the closest thing you'll get to a bug report on it (Apple doesn't make bug reports public to maintain the illusion of perfection, so developers made their own bug site): http://openradar.appspot.com/12756410

This bit of code will unfreeze timers that are broken / lost / destroyed by iOS during a page scroll: https://gist.github.com/ronkorving/3755461

This is another attempt to fix the freeze: iOS 6 js events function not called if has setTimeout in it

Unfortunately, there is nothing you can do to fire events WHILE page scrolling. Like fade out a back-to-top link when scrolling up the page. When it comes to scrolling, iOS6 is incapable of rubbing it's tummy and patting it's head. (iOS5 works fine, btw. This is a regression)