_dispatch_assert_queue_fail under iOS 16.4.1. Don't understand the error.

Since updating to iOS 16.4.1, our app crashes randomly with the following error message.

Exception Codes: 0x0000000000000001, 0x0000000199d542c0
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [499]

Triggered by Thread:  2

Thread 2 Crashed:
0   libdispatch.dylib             	       0x199d542c0 _dispatch_assert_queue_fail + 120
1   libdispatch.dylib             	       0x199d54248 dispatch_assert_queue + 196
2   UIKitCore                     	       0x1949c870c -[UIImageView _mainQ_beginLoadingIfApplicable] + 88
3   UIKitCore                     	       0x19495db34 -[UIImageView setHidden:] + 68
4   UIKitCore                     	       0x19492f128 -[UIButtonLegacyVisualProvider _updateImageView] + 372
5   UIKitCore                     	       0x19492ed78 -[UIButtonLegacyVisualProvider layoutSubviews] + 116
6   UIKitCore                     	       0x19492ecc4 -[UIButton layoutSubviews] + 40
7   UIKitCore                     	       0x1948fbef4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1920
8   QuartzCore                    	       0x193db64ac CA::Layer::layout_if_needed(CA::Transaction*) + 500
9   QuartzCore                    	       0x193dc9a28 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 148
10  QuartzCore                    	       0x193ddae54 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 444
11  QuartzCore                    	       0x193e0a3c0 CA::Transaction::commit() + 648
12  QuartzCore                    	       0x193e54b08 CA::Transaction::release_thread(void*) + 228
13  libsystem_pthread.dylib       	       0x1f2214b9c _pthread_tsd_cleanup + 620
14  libsystem_pthread.dylib       	       0x1f2217560 _pthread_exit + 84
15  libsystem_pthread.dylib       	       0x1f22140cc _pthread_wqthread_exit + 80
16  libsystem_pthread.dylib       	       0x1f2213e64 _pthread_wqthread + 424
17  libsystem_pthread.dylib       	       0x1f2213b7c start_wqthread + 8

I have trouble interpreting where our error lies within the exception. Can anyone give me a hint as to what kind of problem this might be?

Kind regards

Answered by Frameworks Engineer in 752540022

The most likely cause is that you manipulated a UIButton from a secondary thread, and now that the thread is exiting, Core Animation is committing a transaction due to your manipulation, resulting in this eventual assertion.

So the immediate cause of this crash is a Dispatch queue assert. UIImageView, in frame 2, has called dispatch_assert_queue to assert that it’s on the main queue. It isn’t on the main queue, and thus Dispatch has trapped.

As to why it’s doing this from a secondary queue, that’s very much a UIKit question and thus kinda outside of my area of expertise. I’ve added the UIKit tag to your thread to see if that might garner some other eyes.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

The most likely cause is that you manipulated a UIButton from a secondary thread, and now that the thread is exiting, Core Animation is committing a transaction due to your manipulation, resulting in this eventual assertion.

You are accessing a UIKit API from a secondary thread. You can try reproducing the error with the Main Thread Checker enabled (In your scheme -> Diagnostics -> Main Thread Checker).

_dispatch_assert_queue_fail under iOS 16.4.1. Don't understand the error.
 
 
Q