Avoiding a "CoreAnimation Disable Warning with Uncommitted CATransaction" If You DO NOT Use CoreAnimation

Just in appdelegates, applicationDidBecomeActive. I create and start a thread, this thread waits for asynchronous loading and then saves the 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 done, I get the following warning:

 CoreAnimation: warning, deleted thread with uncommitted CATransaction; 
+3
source share
3 answers

Another way to ensure that any UI drawing is executed in the main thread, as described by Andrew, uses the performSelectorOnMainThread:withObject:waitUntilDone: or, alternatively, performSelectorOnMainThread:withObject:waitUntilDone:modes:

 - (void) someMethod { […] // Perform all drawing/UI updates on the main thread. [self performSelectorOnMainThread:@selector(myCustomDrawing:) withObject:myCustomData waitUntilDone:YES]; […] } - (void) myCustomDrawing:(id)myCustomData { // Perform any drawing/UI updates here. } 

For a related message about the difference between dispatch_async() and performSelectorOnMainThread:withObjects:waitUntilDone: see What is the difference between performSelectorOnMainThread and dispatch_async in the main queue?

+3
source

This error is most likely to occur when using the UII API UI for a non-main thread. To see this, you do not need to use Core Animation directly. All UIViews are supported by the Core Animation layer, so Core Animation is used regardless of whether you interact with it directly or not.

There is not enough code in your question to determine the exact problem, but the fact that you are using multithreading is the key to your problem, as I described. Do you update your interface after the download is complete and / or 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 }); 
+8
source

I found a problem: changes label in menuViewController

In this thread, I use the isntance variable than the menuViewController element:

 [menuViewController.labelBadgeVideo setText:@"123 videos"]; 

If I comment on this line, a warning will not appear

(Now I have to learn how to change this label without warning)

0
source

Source: https://habr.com/ru/post/909007/


All Articles