I accidentally ran into what appears to be a very strange bug in Safari's javascript engine on iPad.
The unsigned shift operator >>> is supposed to bitwise right-shift a number. I experienced some errors in a script that worked fine on other platforms, stripped it down and ended up with this:
<html><head><script type='text/javascript'>
var one = 1;
function Zero()
{
return one*0;
}
function Strange()
{
return one = (Zero()+1) >>> 0;
}
var s = 'A bunch of ones: '; // except on iPad :(
for (var i=0; i<200; i++)
{
s += Strange()+' ';
}
document.write(s);
</script></head><body></body></html>
Strangely enough, it correctly generates a bunch of ones, but at a certain point, something breaks and it only outputs zeroes from then on.
Obviously the >>> 0 is meaningless here (a shift over zero places typically does nothing, although it could have forced an integer to become unsigned if javascript made that distinction). It's just to demonstrate the problem, if you omit the >>> 0 it doesn't show up. In my actual situation there were different numbers and more complex expressions involved, but the same thing happened: everything works until a number of iterations, then something 'breaks' and variables suddenly become and remain zero, even after subsequent calculations that really ought to make them non-zero.
Works fine on Android and PC browsers. Strange huh?