Bug Tracker

Opened 12 years ago

Closed 12 years ago

#8766 closed bug (invalid)

Bug in mobile safari involving ajax when canvas is used

Reported by: [email protected] Owned by:
Priority: undecided Milestone: 1.next
Component: ajax Version: 1.5.2
Keywords: Cc:
Blocked by: Blocking:


Here is a link to some examples: http://beatgammit.github.com/sandbox/

Here is a link to a readme about the examples: https://github.com/beatgammit/sandbox


When run as a home-screen app on iPod, the canvas is not updated when polling recursively from within the $.ajax() success callback.

In order to fully understand what is going on, please read the readme and test the examples provided. Please look at the source code as well (there is only about three lines difference between the three examples). This must be run as a home screen app on iPod.

Follow these steps to see the bug:

  • Go to the first link provided on iPod using Safari
  • Visit the first bullet point
  • Verify that it works as expected (there should be a moving bug)
  • Click the middle button on the bottom row of Safari (bookmark button)
  • Click Add to Home Screen and give it a name
  • Open the new icon on the home screen
  • Wait as long as you like, the bug will not move (if it shows up at all)

Try the other examples in the same manner and verify that they work as expected.

Steps to reproduce

  • Put an ajax callback inside of a function
  • Update a canvas element from within $.ajax() success callback
  • Call the function at the end of the success callback in $.ajax()
  • Start the loop


  • Do recursive call from within $.ajax() success with setTimeout
  • Do recursive call from outside $.ajax() success with setTimeout


The ajax calls are continually made, which means that $.ajax() does not call the error callback. I have verified this on my own webserver by outputting to the console each time an ajax call is made. The only difference is that the canvas is not updated.

My Use-Case

I have an app that polls a server and draws the updates to a canvas. In my case, the server has a setTimeout to regulate the update cycle.

Tested Platforms

  • iPod 3g running iOS 4.2.1 (8C148)
  • iPod 4g running iOS 4.3.1 (8G4)

Please email me if you would like more information. I will also submit a bug report to Apple about this.

Change History (7)

comment:1 Changed 12 years ago by Rick Waldron

Component: unfiledajax

Does anyone have a device to test this on? "This must be run as a home screen app on iPod." I feel like that's a little too edge.

comment:2 Changed 12 years ago by [email protected]

Well, don't you think more and more people will be using HTML5, especially for games that use ajax? I think this is a relevant concern and will make developing interactive apps simpler that work on the browser and as an "app".

comment:3 Changed 12 years ago by Rick Waldron

I suspect that when you "add to homescreen" that your resource is no longer found by the ajax call. But that's just a guess without testing - Send me your ipod and I'll debug the issue and send it back.

comment:4 Changed 12 years ago by [email protected]

The resource is still being found as evidenced by the two examples that work. I can also verify that the ajax calls are being sent.

If none of your friends has an iPod or an iPhone and you really want to debug it, I might consider sending it to you. If I get time, I'll try this using a vanilla XHR and post the results to my bug report to Apple.

Maybe someone will see this bug and file a clever patch; the important thing here is that it is documented with work-arounds just in case someone else runs into the same bug.

comment:5 Changed 12 years ago by Rick Waldron

Keywords: needsreview added

comment:6 Changed 12 years ago by [email protected]

I implemented the Ajax call without jQuery and I got the same results.

I don't know what kind of work-around would be best, but maybe putting a short setTimeout before the success callback is called would work. This would only apply to mobile safari when run it's pinned to the home screen. I don't know if that is detectable (too specific?).

I've updated my bug report to Apple with this information, so hopefully it will be fixed soon.

comment:7 Changed 12 years ago by dmethvin

Keywords: needsreview removed
Resolution: invalid
Status: newclosed

Reporter indicates it's not a jQuery issue so I'm closing the ticket.

Note: See TracTickets for help on using tickets.