Hello everyone,
I’m experiencing occasional crashes in my app related to the Core Haptics framework, specifically when creating haptic pattern players. The crashes are intermittent and not easily reproducible, so I’m hoping to get some guidance on what might be causing them.
It's seems it's connected to Audio Resource I'm using within AHAP file.
Setup:
I use AVAudioSession and AVAudioEngine to record and play continuous audio. After activating the audio session and setting up the audio engine, I initialize the CHHapticEngine as follows:
let engine = try CHHapticEngine(audioSession: .sharedInstance())
...
try engine?.start()
// Recreate all haptic pattern players you had created.
let pattern = createPatternFromAHAP(Pattern.thinking.rawValue)!
thinkingHapticPlayer = try? engine?.makePlayer(with: pattern)
// Repeat for other players...
AHAP file:
"Pattern":
[
... haptic events
{
"Event":
{
"Time": 0.0,
"EventType": "AudioCustom",
"EventWaveformPath": "voice.chat.thinking.mp3",
"EventParameters":
[
{ "ParameterID": "AudioVolume", "ParameterValue": 0.7 }
]
}
}
]
I’m receiving the following crash report:
Crashed: com.apple.main-thread
EXC_BREAKPOINT 0x00000001ba525c68
0
CoreHaptics
+[CHHapticEngine(CHHapticEngineInternal) doRegisterAudioResource:options:fromPattern:player:error:].cold.1 + 104
1
CoreHaptics
+[CHHapticEngine(CHHapticEngineInternal) doRegisterAudioResource:options:fromPattern:player:error:].cold.1 + 104
2
CoreHaptics
+[CHHapticEngine(CHHapticEngineInternal) doRegisterAudioResource:options:fromPattern:player:error:] + 3784
3
CoreHaptics
-[CHHapticPattern resolveExternalResources:error:] + 388
4
CoreHaptics
-[PatternPlayer initWithPlayable:engine:privileged:error:] + 560
5
CoreHaptics
-[CHHapticEngine createPlayerWithPattern:error:] + 256
6
Mind
VoiceChatHapticEngine.swift - Line 170
VoiceChatHapticEngine.createThinkingHapticPlayer() + 170
Has anyone encountered similar crashes when working with CHHapticEngine and haptic patterns that contains audioCustom event?
Thank you so much for your help.
Ondrej