Our application uses CXProviderConfiguration to set custom ringtone sound for incoming VoIP call. When running on iOS 15.x or iOS 16, our custom ringtone is intermittently overwritten by the system ringtone. The issue is reproducible 1-2 times out of 10 consecutive calls. The application logic is the same in the good and the bad call, but the system behavior is different.
Looking at sysdiagnose logs - in the good case scenario the ringtone can be played successfully:
default 2022-09-01 15:36:43.495068 +0300 callservicesd <TLAlertQueuePlayerController: 0x104f46290; stateDescriptor = <TLAlertQueuePlayerStateDescriptor: 0x104e926d0>>: -_canPlayToneAsset:(<AVURLAsset: 0x104f39bd0, URL = file:///var/mobile/Library/CallServices/Ringtones/40CE68AF-53A0-450A-A3F3-401589E7FF6D-ring.mp3>). Can play!
When the issue occurs the system logs contain an error: "Can't play tone asset because property duration is not loaded." and then the ringtone is replaced:
error 2022-09-01 15:38:30.566179 +0300 callservicesd <TLAlertQueuePlayerController: 0x104f46290; stateDescriptor = <TLAlertQueuePlayerStateDescriptor: 0x1068a0f60>>: -_canPlayToneAsset:(<AVURLAsset: 0x104dadde0, URL = file:///var/mobile/Library/CallServices/Ringtones/26371EBE-9ACB-4687-A563-C89C0E6B69EF-ring.mp3>). Can't play tone asset because property duration is not loaded.
Is there anything we can do from the application side to avoid this issue?