title: NSInternalInconsistencyException accessing _cachedSystemAnimationFence requires the main thread
body: <p>Using Crittercism with some beta testers I am seeing an error appear several times that I've never experienced myself and I am unable to replicate.</p>
  
  <p>Crittercism tells me:NSInternalInconsistencyException    accessing _cachedSystemAnimationFence requires the main thread</p>
  
  <p>And the line it is pointing to is:</p>
  
  <pre><code>[picker dismissViewControllerAnimated:YES completion:^{
  </code></pre>
  
  <p>Doing some reading on StackOverflow it appears that any UI code should be ran on the main thread. Is the error I am experiencing because the dismissViewControllerAnimated has been ran on a background thread?</p>
  
  <p>Curious why this error is relatively random (i.e. I cannot reproduce it) and also how do I fix it.</p>
  
  <pre><code>- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
  
      __block PHObjectPlaceholder *assetPlaceholder;
  
      [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
  
          PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:[info objectForKey:@"UIImagePickerControllerOriginalImage"]];
  
          assetPlaceholder = changeRequest.placeholderForCreatedAsset;
  
      } completionHandler:^(BOOL success, NSError *error) {
  
          NSArray *photos = [[NSArray alloc] initWithObjects:assetPlaceholder.localIdentifier, nil];
          PHFetchResult *savedPhotos = [PHAsset fetchAssetsWithLocalIdentifiers:photos options:nil];
  
          [savedPhotos enumerateObjectsUsingBlock:^(PHAsset *asset, NSUInteger idx, BOOL *stop) {
  
              NSMutableArray *images = self.event.eventAttachments;
              if (images) {
                  [images addObject:asset];
              } else {
                  images = [[NSMutableArray alloc]init];
                  [images addObject:asset];
              }
  
              self.event.eventAttachments = images;
  
              [picker dismissViewControllerAnimated:YES completion:^{
  
                  NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:4];
                  NSArray *indexPaths = [[NSArray alloc] initWithObjects:indexPath, nil];
  
                  [self.tblChildrenNotes beginUpdates];
                  [self.tblChildrenNotes reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
                  [self.tblChildrenNotes endUpdates];
  
              }];
  
          }];
      }];
  
  }
  </code></pre>