Thanks defenestrator and aesnn for pointing us in the right direction.
There is a fairly easy way to reproduce this bug. This is a race condition in
. You simply have to delay a little bit the first step so that
is not 0.
is called for the first time, the current time (stored in variable
) can only be equals OR
. Most of the time they are equals since they are only separated by a few instructions (in
is 0. If the execution is slow enough (a one millisecond delay is enough, e.g. a log, a busy loop, ..), they will not be equals and then thw first state is not zero, resulting in this bug.
The issue is not in jQuery i guess, since i can't find anywhere where it is specified that state must be equal to 0 on the first step. This is a little bit disapointing to see that this bug has not been fixed since 3 months and has been closed without further investigation...