[Crash Report] PHAssetResourceManager.writeDataForAssetResource causes app crash on iOS18

We are encountering a critical, intermittently occurring crash issue when accessing photo data using PHAssetResourceManager.writeDataForAssetResource on iOS 18. The problem does not arise on iOS 17 or earlier versions.

We have been unable to identify a consistent reproduction path. Based on user feedback, the issue seems to involve Live Photo and Raw image files.

Our investigation has revealed that the crash occurs in the +[PISchema identifier] method of the PhotoImaging Framework. When called manually, this method causes a crash on iOS 18 but works without issues on iOS 17.

Reproduction Steps:

1.Fetch PHAsset.

2.Get PHAssetResource by [PHAssetResource assetResourcesForAsset:].

3.Call [PHAssetResourceManager writeDataForAssetResource:toFile:options:completionHandler:].

Crash Log:

Incident Identifier: CFD60092-FDB1-43B4-BA42-3F507F7B8B96
CrashReporter Key:   260b4780989083a54e0cb451930fe9a3bed64862
Hardware Model:      iPhone13,4
AppStoreTools:       16C5031b
AppVariant:          1:iPhone13,4:18
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]

Date/Time:           2025-02-15 19:07:57.7054 +0800
Launch Time:         2025-02-15 19:07:55.4106 +0800
OS Version:          iPhone OS 18.3.1 (22D72)
Release Type:        User
Baseband Version:    5.20.03
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: SIGNAL 6 Abort trap: 6
Terminating Process: mCloud_iPhone [11109]

Triggered by Thread:  11

Application Specific Information:
abort() called

Thread 11 name:   Dispatch queue: com.apple.NSXPCConnection.m-user.com.apple.photos.service
Thread 11 Crashed:
0   libsystem_kernel.dylib        	       0x1e850b2d4 __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x221b4959c pthread_kill + 268
2   libsystem_c.dylib             	       0x19ec24b08 abort + 128
3   NeutrinoCore                  	       0x1bdcdbdec -[NUAssertionPolicyAbort notifyAssertion:] + 68
4   NeutrinoCore                  	       0x1bdcdbbf4 -[NUAssertionPolicyComposite notifyAssertion:] + 160
5   NeutrinoCore                  	       0x1bdcdc098 -[NUAssertionPolicyUnique notifyAssertion:] + 176
6   NeutrinoCore                  	       0x1bdcdb524 -[NUAssertionHandler handleFailureInFunction:file:lineNumber:currentlyExecutingJobName:description:arguments:] + 156
7   NeutrinoCore                  	       0x1bdcdc4bc _NUAssertFailHandler + 176
8   NeutrinoCore                  	       0x1bdc8ea98 -[NUIdentifier initWithNamespace:name:version:] + 2352
9   NeutrinoCore                  	       0x1bdc8eba8 -[NUIdentifier initWithName:version:] + 84
10  NeutrinoCore                  	       0x1bdc8ec10 -[NUIdentifier initWithName:] + 68
11  PhotoImaging                  	       0x1bda54ce4 +[PISchema identifier] + 36
12  PhotoImaging                  	       0x1bda550fc +[PISchema registeredPhotosSchemaIdentifier] + 32
13  PhotoImaging                  	       0x1bd9d7128 +[PIPhotoEditHelper newComposition] + 28
14  PhotoImaging                  	       0x1bd940798 +[PICompositionSerializer deserializeCompositionFromAdjustments:metadata:formatIdentifier:formatVersion:sidecarData:error:] + 160
15  PhotoImaging                  	       0x1bd9412ec +[PICompositionSerializer deserializeCompositionFromData:formatIdentifier:formatVersion:sidecarData:error:] + 224
16  PhotoLibraryServices          	       0x1afabf75c -[PLPhotoEditPersistenceManager loadCompositionFrom:formatIdentifier:formatVersion:sidecarData:error:] + 1856
17  PhotoLibraryServices          	       0x1afabffe4 +[PLPhotoEditPersistenceManager validateAdjustmentData:formatIdentifier:formatVersion:error:] + 108
18  Photos                        	       0x1af4ac360 __167+[PHContentEditingInputRequestContext contentEditingInputRequestContextForAsset:requestID:managerID:networkAccessAllowed:downloadIntent:progressHandler:resultHandler:]_block_invoke + 260
19  Photos                        	       0x1af4ac67c -[PHAdjustmentData(ContentEditingInput) _contentEditing_readableByClientWithVerificationBlock:] + 136
20  Photos                        	       0x1af4ac4b0 -[PHAdjustmentData(ContentEditingInput) _contentEditing_requiredBaseVersionReadableByClient:verificationBlock:] + 88
21  Photos                        	       0x1af4abb8c -[PHContentEditingInputRequestContext _adjustmentBaseVersionFromResult:request:canHandleAdjustmentData:] + 404
22  Photos                        	       0x1af4a911c -[PHContentEditingInputRequestContext produceChildRequestsForRequest:reportingIsLocallyAvailable:isDegraded:result:] + 624
23  Photos                        	       0x1af2c1d10 -[PHMediaRequestContext _produceChildRequestsForRequest:withResult:] + 88
24  Photos                        	       0x1af2c11e8 -[PHMediaRequestContext mediaRequest:didFinishWithResult:] + 88
25  Photos                        	       0x1af505184 -[PHAdjustmentDataRequest _finishFromAsynchronousCallback] + 124
26  Photos                        	       0x1af5050a0 __39-[PHAdjustmentDataRequest startRequest]_block_invoke + 584
27  PhotoLibraryServicesCore      	       0x1b001be8c __106-[PLAssetsdResourceClient adjustmentDataForAsset:networkAccessAllowed:trackCPLDownload:completionHandler:]_block_invoke.86 + 864
28  CoreFoundation                	       0x196dd8e34 __invoking___ + 148
29  CoreFoundation                	       0x196dd7e7c -[NSInvocation invoke] + 428
30  Foundation                    	       0x195a64ae0 __NSXPCCONNECTION_IS_CALLING_OUT_TO_EXPORTED_OBJECT__ + 16
31  Foundation                    	       0x195a63514 -[NSXPCConnection _decodeAndInvokeReplyBlockWithEvent:sequence:replyInfo:] + 532
32  Foundation                    	       0x195a6653c __88-[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:]_block_invoke_5 + 188
33  libxpc.dylib                  	       0x221babb80 _xpc_connection_reply_callout + 116
34  libxpc.dylib                  	       0x221b9e2d0 _xpc_connection_call_reply_async + 80
35  libdispatch.dylib             	       0x19eb6b028 _dispatch_client_callout3 + 20
36  libdispatch.dylib             	       0x19eb88b64 _dispatch_mach_msg_async_reply_invoke + 340
37  libdispatch.dylib             	       0x19eb7242c _dispatch_lane_serial_drain + 352
38  libdispatch.dylib             	       0x19eb73158 _dispatch_lane_invoke + 432
39  libdispatch.dylib             	       0x19eb7e38c _dispatch_root_queue_drain_deferred_wlh + 288
40  libdispatch.dylib             	       0x19eb7dbd8 _dispatch_workloop_worker_thread + 540
41  libsystem_pthread.dylib       	       0x221b44680 _pthread_wqthread + 288
42  libsystem_pthread.dylib       	       0x221b42474 start_wqthread + 8
[Crash Report] PHAssetResourceManager.writeDataForAssetResource causes app crash on iOS18
 
 
Q