Mac Catalyst: weird crash related to requestImageForAsset

I am loading 256x256 previews of the last 2048 photos of the photo library into a Metal ArrayTexture of size 256x256x2048.


This works nicely on iPhone, iPad and appleTV, but on Mac Catalyst it throws with a call to a method that doesn't exist in the documentation.


Do you guys know where I might be able to enquire about this issue ?



[OS_dispatch_group filePath]: unrecognized selector sent to instance 0x6000021a90e0'

*** First throw call stack:

(

0 CoreFoundation 0x00007fff354da8ab __exceptionPreprocess + 250

1 libobjc.A.dylib 0x00007fff6b794805 objc_exception_throw + 48

2 CoreFoundation 0x00007fff35559b61 -[NSObject(NSObject) __retain_OA] + 0

3 CoreFoundation 0x00007fff3543eadf ___forwarding___ + 1427

4 CoreFoundation 0x00007fff3543e4b8 _CF_forwarding_prep_0 + 120

5 libMTLCapture.dylib 0x00007fff696a4ff0 DYMTLWrapDeviceWithDebugLayer + 24933

6 libMTLCapture.dylib 0x00007fff697051ab GTHarvesterAddTexturePlane + 63172

7 ************ 0x00007fff42f2d46d VTCreateCGImageFromIOSurfaceAndAttributes + 15989

8 ************ 0x00007fff42f2c5e1 VTCreateCGImageFromIOSurfaceAndAttributes + 12265

9 ************ 0x00007fff42f01476 VTRegisterPixelTransferCapability + 192425

10 ************ 0x00007fff42ebd85a VTPixelTransferSessionTransferImage + 10855

11 MediaToolbox 0x00007fff3a4e71b7 FigPhotoScaleAndRotateSessionGetTypeID + 1794

12 MediaToolbox 0x00007fff3a0d2fc8 FigPhotoScaleAndRotateSessionTransformForSize + 199

13 MediaToolbox 0x00007fff3a320fa2 FigTTMLDocumentWriterCreateLineBreaker + 15053

14 MediaToolbox 0x00007fff3a32049c FigTTMLDocumentWriterCreateLineBreaker + 12231

15 MediaToolbox 0x00007fff3a101605 FigPhotoDecompressionSessionGetTypeID + 1404

16 libdispatch.dylib 0x00000001002d87b3 _dispatch_call_block_and_release + 12

17 libdispatch.dylib 0x00000001002d978f _dispatch_client_callout + 8

18 libdispatch.dylib 0x00000001002dc5e9 _dispatch_continuation_pop + 585

19 libdispatch.dylib 0x00000001002db6dd _dispatch_async_redirect_invoke + 769

20 libdispatch.dylib 0x00000001002ed31d _dispatch_root_queue_drain + 334

21 libdispatch.dylib 0x00000001002edd8f _dispatch_worker_thread2 + 127

22 libsystem_pthread.dylib 0x0000000100364fe6 _pthread_wqthread + 220

23 libsystem_pthread.dylib 0x0000000100364157 start_wqthread + 15

I encountered exactly the same error when I try to fetch images in an NSCollectionView using PhotoKIt.

I implemented a MTKView (Metal Kit View) on the same window so that I can make a real time monitor

of CIFilter effect.


Without that MTKView, there was no trouble in fetching images. So I am guessing that there is some conflict

between PhotoKit+NSCollectionView and MTKView.


Sorry I am not giving you answers to your question but I just want let you know that you are not the only one

who is in trouble.

It turned out that the error occurred only in the XCode simulator but disappeared on the real Application. The App never crash although the NSCollectionView stops smooth scroll occasionally but it's acceptable.

well, I just have the MTKView and PhotoKit, so I guess NSCollectionView isn't the problem.
Now, you're talking about XCode Simulator, so I guess you're getting this error on iOS. In my case, it's actually happening only on OSX and not on iOS. I thought it was somewhere in Catalyst, but I have switched the macOS version to AppKit, hoped the crash disappeared but it just happened to me again.

You were right. NSCollectionView only repeated the fetch command to PhotoKit so many times and it has essentially nothing to do with this crash.


By the way, I am wokring on macOS project not iOS. What I meant by "in the simulator" was the App launched inside the XCode by 'Run' command where I encountered the error. However, when I actually built a stand alone application using 'Archive' command, that applicataion worked without the crash. Did you try that ?

I was having the exact same problem. It all started as soon as I added MetalKit as a framework.
Anyway in case anyone else is having the same problem, you need to request the Image synchronously even if all your calls are being scheduled on the main-thread I only set this as sync on the DEBUG builds as release builds seems to work fine.

Code Block
PHImageRequestOptions *requestOptions = [[PHImageRequestOptions alloc] init];
requestOptions.synchronous = YES;
....
[manager requestImageForAsset:asset
            targetSize:targetSize
           contentMode:contentMode
             options:requestOptions...];

Mac Catalyst: weird crash related to requestImageForAsset
 
 
Q