0

I'm working on a watchOS app which plays sound using an AVAudioPlayerNode. Whenever I put the app in the background, open it back again and try to play sound, the app crashes with the following message:

Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'player did not see an IO cycle.'

If I use this answer to catch NSExceptions in Swift, the following error appears:

The operation couldn’t be completed. (com.apple.coreaudio.avfaudio error 0.)

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
  • I experienced a similar issue, but stopping the old/running instance before creating a new one, seemed to solve the problem. – LoVo Dec 22 '22 at 14:06

1 Answers1

0

Observe WKExtension.applicationDidBecomeActiveNotification.

Whenever it gets posted:

  • reinitialize the AVAudioEngine instance you're using (audioEngine = AVAudioEngine())
  • reattach all the nodes
Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223