iOS 17 and Thread Priority Inversion in Performance Checker

After upgrading to iOS 17, Thread Performance Checker is complaining of priority inversion when converting a CVPixelBuffer to UIImage through a CIImage instance. It might be a false-positive or an issue?

- (UIImage *)imageForSampleBuffer:(CMSampleBufferRef)sampleBuffer andOrientation:(UIImageOrientation)orientation {
   CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
   CIImage *ciImage = [CIImage imageWithCVPixelBuffer:pixelBuffer];
   UIImage *uiImage = [UIImage imageWithCIImage:ciImage];
   NSData *data = UIImageJPEGRepresentation(uiImage, 90);
}

The code snippet above, when running in a thread set to the default priority results in the message below:

Thread Performance Checker: Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions
PID: 1188, TID: 723209
Backtrace
=================================================================
3   AGXMetalG14                         0x0000000235c77cc8 1FEF1F89-B467-37B0-86F8-E05BC8A2A629 + 2927816
4   AGXMetalG14                         0x0000000235ccd784 1FEF1F89-B467-37B0-86F8-E05BC8A2A629 + 3278724
5   AGXMetalG14                         0x0000000235ccf6a4 1FEF1F89-B467-37B0-86F8-E05BC8A2A629 + 3286692
6   MetalTools                          0x000000022f758b68 E712D983-01AD-3FE5-AB66-E00ABF76CD7F + 568168
7   CoreImage                           0x00000001a7c0e580 3D2AC243-0880-3BA9-BBF3-A214454875E0 + 267648
8   CoreImage                           0x00000001a7d0cc08 3D2AC243-0880-3BA9-BBF3-A214454875E0 + 1309704
9   CoreImage                           0x00000001a7c0e2e0 3D2AC243-0880-3BA9-BBF3-A214454875E0 + 266976
10  CoreImage                           0x00000001a7c0e1d0 3D2AC243-0880-3BA9-BBF3-A214454875E0 + 266704
11  libdispatch.dylib                   0x0000000105e4a7bc _dispatch_client_callout + 20
12  libdispatch.dylib                   0x0000000105e5be24 _dispatch_lane_barrier_sync_invoke_and_complete + 176
13  CoreImage                           0x00000001a7c0a784 3D2AC243-0880-3BA9-BBF3-A214454875E0 + 251780
14  CoreImage                           0x00000001a7c0a46c 3D2AC243-0880-3BA9-BBF3-A214454875E0 + 250988
15  libdispatch.dylib                   0x0000000105e5b764 _dispatch_block_async_invoke2 + 148
16  libdispatch.dylib                   0x0000000105e4a7bc _dispatch_client_callout + 20
17  libdispatch.dylib                   0x0000000105e5266c _dispatch_lane_serial_drain + 832
18  libdispatch.dylib                   0x0000000105e5343c _dispatch_lane_invoke + 460
19  libdispatch.dylib                   0x0000000105e524a4 _dispatch_lane_serial_drain + 376
20  libdispatch.dylib                   0x0000000105e5343c _dispatch_lane_invoke + 460
21  libdispatch.dylib                   0x0000000105e60404 _dispatch_root_queue_drain_deferred_wlh + 328
22  libdispatch.dylib                   0x0000000105e5fa38 _dispatch_workloop_worker_thread + 444
23  libsystem_pthread.dylib             0x00000001f35a4f20 _pthread_wqthread + 288
24  libsystem_pthread.dylib             0x00000001f35a4fc0 start_wqthread + 8

PS: CMSampleBufferRef is an instance received from a AVCaptureVideoDataOutputSampleBufferDelegate on method captureOutput:didOutputSampleBuffer:fromConnection. The queue associated with the video capture session was set to default priority. This happens on Xcode 15.3 and iOS 17.4.1.

The same issue happened on XCode 15.3, iOS 17.4 and 17.4.1, but there was no warning on iOS 17.5. Use CGImage for CVPixelBuffer to UIImage does not produce this warning

iOS 17 and Thread Priority Inversion in Performance Checker
 
 
Q