mrackwitz / MRProgress

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

Crash when progress value changes is too small #120

Open alexchan1680 opened 8 years ago

alexchan1680 commented 8 years ago
@implementation MRCircularProgressView {
    int _valueLabelProgressPercentDifference;
}

As you declared that variable as int, it is crashing here.

// Add timer to update valueLabel
    _valueLabelProgressPercentDifference = (progress - self.progress) * 100;
    CFTimeInterval timerInterval =  self.animationDuration / ABS(_valueLabelProgressPercentDifference);
    self.valueLabelUpdateTimer = [NSTimer scheduledTimerWithTimeInterval:timerInterval
                                                                  target:self
                                                                selector:@selector(onValueLabelUpdateTimer:)
                                                                userInfo:nil
                                                                 repeats:YES];

if progress - self.progress value is smaller than 0.001 then 100% crash because difference becomes zero. I found it when reporting progress from CloudKit asset download and I did nothing tricky to make it crash.

I am not sure if this is bug or not :), but wanted to let you know.

Thanks.