mrackwitz / MRProgress

Collection of iOS drop-in components to visualize progress
MIT License
2.55k stars 305 forks source link

Fix crash when a small change in progress #108

Open AddAloner opened 9 years ago

AddAloner commented 9 years ago

Crash reason in - animateToProgress:

_valueLabelProgressPercentDifference = (progress - self.progress) * 100; // (int) 0 CFTimeInterval timerInterval = self.animationDuration / ABS(_valueLabelProgressPercentDifference); // NaN

mrackwitz commented 9 years ago

Thanks for pointing out the crash. But I'm pretty sure rather the whole calculation further below should be changed, as that seems to be really wrong.

-_valueLabelProgressPercentDifference = (progress - self.progress) * 100;
-CFTimeInterval timerInterval =  self.animationDuration / ABS(_valueLabelProgressPercentDifference);
+CFTimeInterval timerInterval = self.animationDuration * ABS(progress - self.progress);
jaybowang commented 8 years ago

I got this crash too. NaN crash.

@mrackwitz Could you please fix it and release a new version? It's been a while since this issue was created in Sep. 2015. I know there must be somebody else using this awesome progress view and hope this crash can be fixed.

brnunes commented 8 years ago

Also getting this crash

Airtower commented 8 years ago

I did too. I found the error in the code and I added a simple isNan() check. If it is NAN, I set the progress to zero. A proper fix would be nice though.