Homescreen Web Applications lose Timing Functions after Lock/Wake

Originator:rgerbasi
Number:rdar://18315454 Date Originated:9/10/2014
Status:Open Resolved:
Product:iOS Product Version:8.0
Classification: Reproducible:
 
Summary:
Calls to requestAnimationFrame, setTimeout and setInterval stop working when you return to the application from a Lock/Wake cycle.

Steps to Reproduce:
1. Download attached HMTL file.
2. Host file on local/remote webserver
3. On iOS8 device open safari and browse hosted file
4. Add Page to homescreen
5. Open 'Test AnimationFrame' from homescreen icon
6. Move finger around on the screen and watch counts move up.
7. Lock the device
8. Unlock the device 
9. Move finger around the screen again timing function counts do not change.

Expected Results:
Timing functions (requestAnimationFrame, setTimeout, setInterval) should work.

Actual Results:
Timing functions (requestAnimationFrame, setTimeout, setInterval) stop working and no longer call there callbacks.

Version:
iOS8 GA

Notes:


Configuration:
iPod 5th generation

Attachments:
<!DOCTYPE html>
<html>
<head>
  <title>Test AnimationFrame</title>
  <meta name="viewport" content="width=device-width, user-scalable=no">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <style type="text/css">
    html, body {
      width: 100%;
      height: 100%;
      background-color: blue;
      color: white;
    }

    #moves:before {
      content: "TouchMove Count: ";
    }

    #af:before {
      content: "Animation Frame Count: ";
    }

    #to:before {
      content: "SetTimeout Count: ";
    }
  </style>
</head>
<body>
  <div id="moves">0</div>
  <div id="af">0</div>
  <div id="to">0</div>

  <script type="text/javascript">
    var body = document.body,
      move = document.getElementById("moves"),
      anim = document.getElementById("af"),
      timeout = document.getElementById("to"),
      afCount = 0, toCount = 0, moveCount = 0;
    
    body.addEventListener("touchmove", onTouchMove);

    function onTouchMove(e) {
      e.preventDefault();
      moveCount++
      move.innerText = moveCount;
      window.requestAnimationFrame(runAF);
      window.setTimeout(runTO, 1);
    }

    function runAF() {
      afCount++;
      anim.innerText = afCount;
    }

    function runTO() {
      toCount++;
      timeout.innerText = toCount;
    }
  </script>
</body>
</html>

Comments

8.1.1

It's solved in 8.1.1

By milad.mostavi at Nov. 20, 2014, 10:21 a.m. (reply...)

iOS 8.1.1

Solved for me with iOS 8.1.1

WebSQL is affected by same issue

I believe that this is also affecting the local WebSQL database. After unlocking the iPad and calling the async transaction function nothing happens; the callback point passed in is never reached.

By KevafhinnLtd at Nov. 3, 2014, 4:28 p.m. (reply...)

iOS 8.1 jQuery fadeIn, fadeOut fails after coming back from lock screen as do other timer dependent function.

I had to change to use show/ hide due to a bug with timers when trying to use an app after timing out to home screen and then unlocking.

My app is pretty complex and is supposed to be added to home screen. BUT, added to home screen setTimeout and other timer dependent functions fail.

The additional problem I have is I also can't run my app as a safari web page as there is a bug that causes only the first page of PDF documents to be shown when PDF loaded into an iframe. That bug does not exist in web app/ home screen version.

Come on Apple, this is costing me a fortune in debugging time. I am going to tell my client to use Chrome, it has neither of these bugs, but sadly Apple does not allow Chrome to add its apps to homescreen. So frustrating!

By rjones2102 at Oct. 30, 2014, 2:09 p.m. (reply...)

AngularJS

I have an app build with AngularJS, after the sleep/wake-up nothing works. Not even $http. This is a disaster, I filed a bug report, no response yet from Apple.

More people should report this to Apple: https://bugreport.apple.com/

By milad.mostavi at Oct. 27, 2014, 9:27 a.m. (reply...)

No change...

Still broken on iOS 8.1 :-(

By david.a.nimmo at Oct. 21, 2014, 7:34 a.m. (reply...)

Semi-Solution and other notes

https://github.com/TaDaa/IOS8-FIX

By Trevor002 at Oct. 3, 2014, 3:41 p.m. (reply...)

For anyone needing an immediate workaround, this is the best you can hope for: http://stackoverflow.com/a/26091749/489586

Additional notes: - also breaks websockets - everything remains broken even after a window.location.reload()

disaster

This is causing all our users to stop functioning, customers are going mad with frustration - is there anyway to inform apple of this problem?

By s.papworth at Oct. 1, 2014, 4:02 p.m. (reply...)

PS: iOS 8.0.1 still has this bug

I opened a similar report, while I explicitly reference this bug id, Apple set my ticket as a duplicate of another bug 18042389 (currently in open status, but no reference on the web).

reference: http://www.openradar.me/18403338

True story

This breaks just about any javascript web app thats pinned to the homescreen once you lock/sleep your device.

By tinysparkdesign at Sept. 25, 2014, 2:35 a.m. (reply...)

disaster

This bug is a disaster, we have customers calling and complaining why their software stopped working. We are a startup and this has the potential of putting us out of business.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!