iPad ajax problems iPad ajax problems ajax ajax

iPad ajax problems


Putting this here, as in comment there isn't any syntax highlighting.

I've made a super minimal test page here: http://www.focalstrategy.com/tests/ajax.php

The code is:

<?if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {echo date("F j, Y, G:i:s a");exit();}?><!doctype html><html><head>    <title>AJAX test</title></head><body>    <h1>Ajax Test</h1>    <p>This page makes an AJAX request every 5 seconds and replaces the div below with the returned date.</p>    <div><p id="date"><?= date("F j, Y, G:i:s a") ?></p></div>    <div><p><span id="count">0</span> updates made.</p></div>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>    <script>    var count = 0;    var getDate = function() {        $.get('/tests/ajax.php', function(data) {            $('#date').html(data);            count = count + 1;            $('#count').html(count);        });    }    setInterval(getDate, 5000);    </script></body></html>

So, I ran this for an hour, and didn't have any issues, the iPad (fully updated) ran fine throughout, without missing any.

I also ran this on Chrome and recorded it's behaviour. This looks like this:

Chrome Profiler view, showing graphs for DOM Node, Event Listeners and memory usage.

(Full size)

There's some weirdness here, in that at first the number of event listeners stays constant, then after a while goes mad,, increasing up to 56 listeners before dropping to 1 again. The DOM Node Count also repeatedly spikes, as high as 424. Both have fairly odd behaviour bearing in mind the simplicity of this code.

Perhaps on your app the number of Dom Nodes being tracked, or the number of event listeners is reaching some value causing the iPad to lose track of what's happening, or something similar.

It's also worth noticing that the memory usage ramps up until garbage collection happens. That's what is meant to happen, though perhaps it's less efficient on the iPad.

Edit: I've tested it again on a clean profile, many of the Event listeners are due to extensions – the same behaviour happens, but not to same degree, also background values are 0-1 rather than 15-20