Random 561015905 on AVAudioSession setActive

I'm trying to make an app that plays audio when push is received, even while the ringer is silent.


I have the audio background mode enabled and the app works (usually) fine, but sometimes i get a mysterious 561015905 error.


The error is

AVAudioSession.ErrorCode.cannotStartPlaying

And docs indicate:

This error type can occur if the app’s Information property list doesn’t permit audio use.
It can also occur if the app is in the background and using a category that doesn’t allow background audio.

https://developer.apple.com/documentation/avfoundation/avaudiosession/errorcode/cannotstartplaying


However, the audio mode is definitely enabled and the category is always playback that should allow background playing.

(this works 95-99% of times)


So, with intesnse testing i have found that once every 20-100 incoming pushes i get this error:

Error: Error Domain=NSOSStatusErrorDomain Code=561015905 "(null)"


Why?

Did you solve your issue? I'm having the same problem.

Also seeing this A LOT. Many users are having this error.

I'm getting the same error. It's not happening with all users, but it's happening with a lot of users.

Fatal Exception: FlutterError
PlatformException(561015905, Session activation failed, null, null)

          Fatal Exception: FlutterError
0  ???                            0x0 StandardMethodCodec.decodeEnvelope + 651 (message_codecs.dart:651)
1  ???                            0x0 MethodChannel._invokeMethod + 334 (platform_channel.dart:334)
2  ???                            0x0 AVAudioSession.setActive + 150 (darwin.dart:150)
3  ???                            0x0 AudioSession.setActive + 237 (core.dart:237)
4  ???                            0x0 AudioPlayer.play + 934 (just_audio.dart:934)
Random 561015905 on AVAudioSession setActive
 
 
Q