Skip to main content
M
15d ago

[iOS] Sounds in RiveViewModel stop working after `AVAudioSession.setActive(false)` is called

Environment

  • RiveRuntime 6.3.1

  • Xcode 16.1

  • iOS 18.1

Repro steps

  1. Configure AVAudioSession.sharedInstance() and call..

    1. setCategory(.playback, mode: .default)

    2. setActive(true)

  2. Initialize RiveViewModel with my file name and artboard name

  3. In SwiftUI, show RiveViewModel.view() and observe in app that expected sounds from Rive animation play.

  4. Later, call AVAudioSession.setActive(false) to be a good iOS AVAudioSession citizen when the app no longer needs to play sound (Ex: My app does this regardless of me wanting to play the new Rive animation when the app is backgrounded).

  5. When I later repeat steps 1-3 to show the same Rive animation with sound (I initialize a new RiveViewModel), the Rive animation plays as expected, but without sound. Other Swift-driven sounds (Ex: From AVAudioPlayer) work as expected at this time.

What I've tried to fix this

  • riveViewModel.reset() and riveViewModel.resetToDefaultModel() after the first time I show the Rive animation and before I play the Rive animation again.

Is there an issue with my approach or possibly a bug in RiveRuntime iOS code or an issue with the sound configuration in the Rive animation file?

Thank you in advance for any help!

1 reply
D
D
15d ago

Just to clarify: your app is playing audio in addition to Rive playing audio? It sounds like yes, but I just want to double check! Could you provide a barebones example app that reproduces this problem? If so, I can hopefully replicate and better debug this in my development environment.