MRProgress icon indicating copy to clipboard operation
MRProgress copied to clipboard

Fix crash when a small change in progress

Open AddAloner opened this issue 9 years ago • 4 comments

Crash reason in - animateToProgress:

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

AddAloner avatar Sep 10 '15 09:09 AddAloner

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);

mrackwitz avatar Sep 24 '15 19:09 mrackwitz

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.

jaybowang avatar Jan 20 '16 13:01 jaybowang

Also getting this crash

brnunes avatar Sep 01 '16 20:09 brnunes

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.

Airtower avatar Sep 01 '16 20:09 Airtower