[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
Configure
AVAudioSession.sharedInstance()
and call..setCategory(.playback, mode: .default)
setActive(true)
Initialize
RiveViewModel
with my file name and artboard nameIn SwiftUI, show
RiveViewModel.view()
and observe in app that expected sounds from Rive animation play.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).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: FromAVAudioPlayer
) work as expected at this time.
What I've tried to fix this
riveViewModel.reset()
andriveViewModel.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!
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.