ComponentAnimator assert when Time::getMillisecondCounter wraps (bug)


#1

Time::getMillisecondCounter is 32bit and wraps sometimes. This can assert in ComponentAnimator.

See timerCallback and useTimeslice


#2

Bump, made a thread during ADC :man_facepalming:


#3
auto elapsed = (int) (timeNow - lastTime);

I don’t think that’ll cause any trouble - the subtraction of the two uint32s should do the right thing.

What assertion are you hitting?


#4

If lastTime is large (near rollover), and timeNow is small (after rollover), then elapsed is -ve.

Then in useTimeslice: newProgress is less than lastProgress, but still more than 0. Assertion is jassert (newProgress >= lastProgress); on line 82

I think that was how it happened (it was a while ago now).


#5

The result of timeNow - lastTime is still a uint32, so when lastTime is large and timeNow is small it will remain positive and correct.

There’s a potential problem when the reverse happens (lastTime is small and timeNow is large) as a large valued uint32 will map to a negative int, but it seems pretty unlikely you’d have run into that.

… there may be something else going on though - I’ll have a look tomorrow


#6

Darn, you appear to be correct. I cannot remember why it happened then.

We have an animated screensaver type screen where a thing moves around according to a ComponentAnimator. We had an issue that involved leaving the screensaver on for a long time (days) and it crashing. I will see if I can get a correct explaination tomorrow…