title: CAShapeLayer path animation has serious delay
body: <p>I'm attempting to create a loading screen that draws a circle while my app makes network requests. The amount drawn of the circle is meant to represent how close the request is to finishing. However there is a serious delay (~8 seconds) between the network request and the animation. After A LOT of searching I haven't found anyone that has had this problem before so I'm very desperate.</p>
  
  <p>My setup right now is that an NSProgress object will be updated as a request is being made and will trigger a KVO Notification with the NSProgress object in the userInfo. This is the same method found <a href="https://stackoverflow.com/a/19380812/2589965">here</a>.</p>
  
  <pre><code>#Client.m
  - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
      if ([keyPath isEqualToString:@"fractionCompleted"] &amp;&amp; [object isKindOfClass:[NSProgress class]]) {
          NSProgress *progress = (NSProgress *)object;
          NSDictionary *userInfo = @{@"progress":progress};
          [[NSNotificationCenter defaultCenter] postNotificationName:@"FractionCompleted" object:self userInfo:userInfo];
      }
  }
  </code></pre>
  
  <p>Then the view controller that is listening for the notification will update the LoadingProgressView with the fractionCompleted of the NSProgress object that it receives.</p>
  
  <pre><code>#MainViewController.m
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateProgress:) name:@"FractionCompleted" object:nil];
  ...
  ...
  - (void)updateProgress:(NSNotification*)note {
      NSProgress* prog = note.userInfo[@"progress"];
      [self.progressIndicatorView updateProgress:(CGFloat)prog.fractionCompleted];
  }
  </code></pre>
  
  <p>Now within the LoadingProgressView, the CAShapeLayer's strokeEnd property is set as the fractionCompleted value. I am using the same idea from the tutorial found <a href="http://www.raywenderlich.com/94302/implement-circular-image-loader-animation-cashapelayer" rel="nofollow noreferrer">here</a>.</p>
  
  <pre><code>#LoadingProgressView.m
  - (void)updateProgress:(CGFloat)frac {
      _circlePathLayer.strokeEnd = frac;
  }
  </code></pre>
  
  <p>When I actually make a request, nothing happens until about 5 seconds AFTER the request is finished. At that point the entire circle is animated at once.</p>
  
  <p>I have ABSOLUTELY NO IDEA why this is happening and it's driving me crazy. I can clearly see using the debugger that the strokeEnd property is being updated in real-time and yet the LoadingProgressView refuses to re-render until much later. Any help is very much appreciated. Thanks.</p>
  
  <p>EDIT: OK so a temporary solution was to fork a new thread with a delay of 0 to update the progress view for each notification. However this seems like poor thread management since I could be creating over a hundred different threads to do the same task. I'm wondering if there's anything else I can do.</p>
  
  <pre><code>- (void)updateProgress:(NSNotification*)note {
      NSProgress* prog = note.userInfo[@"progress"];
      dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
          [self.progressIndicatorView updateProgress:(CGFloat)prog.fractionCompleted];
      });
  }
  </code></pre>