Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid "CoreAnimation warning deleted thread with uncommitted CATransaction" if NOT using CoreAnimation

Just in the appdelegates, applicationDidBecomeActive. I create and start a thread, this thread waits an asynchronous download and then save data:

 - (void)applicationDidBecomeActive:(UIApplication *)application
    {
              // begins Asynchronous download data (1 second):
               [wsDataComponents updatePreparedData:NO];

               NSThread* downloadThread = [[NSThread alloc] 
                  initWithTarget:self 
                        selector: @selector (waitingFirstConnection) 
                          object:nil];
               [downloadThread start];
        }

then

-(void)waitingFirstConnection{    

    while (waitingFirstDownload) {
      // Do nothing ...  Waiting a asynchronous download, Observers tell me when
      // finish first donwload
    }

    // begins Synchronous download, and save data (20 secons)
    [wsDataComponents updatePreparedData:YES];

    // Maybe is this the problem ?? I change a label in main view controller 
    [menuViewController.labelBadgeVideo setText:@"123 videos"];

    // Nothig else, finish and this thread is destroyed
}

In the Organizer console, when finished, I am getting this warning:

CoreAnimation: warning, deleted thread with uncommitted CATransaction;
like image 776
Albert Català Avatar asked Jan 26 '26 01:01

Albert Català


1 Answers

This error is most commonly seen when using UIKit UI API on a non-main thread. You don't have to be directly using Core Animation to see this. All UIViews are backed by a Core Animation layer, so Core Animation is in use whether you're interacting directly with it or not.

There's not enough code in your question to identify the exact problem, but the fact that you're using multithreading is a clue that your problem is as I've described. Are you updating your UI after the download is complete and/or the data is saved? If so, you need to move the UI update back to the main thread/queue. This is easier if you use GCD instead of NSThread:

// download is finished, save data
dispatch_async(dispatch_get_main_queue(), ^{
    // Update UI here, on the main queue
});
like image 176
Andrew Madsen Avatar answered Jan 27 '26 17:01

Andrew Madsen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!