Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Javascript DOM "Freezing?"

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?

like image 917
James Kyle Avatar asked Dec 02 '11 19:12

James Kyle


2 Answers

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 StackOverflow 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)

like image 112
mrbinky3000 Avatar answered Nov 17 '22 22:11

mrbinky3000


To answer the third question, a decent-sized limitation is that sometimes innerHTML just plain doesn't work. From the accepted answer:

It happens when the CPU of the phone is very busy (say 100%). Then the rendering engine sometimes forget about innerHTML settings.

The solution included in my unify project is to test if there is an element in childNodes, otherwise apply it again.

like image 44
sdleihssirhc Avatar answered Nov 18 '22 00:11

sdleihssirhc