Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlatformException(DarwinAudioError, Error configuring audio session: Error Domain=NSOSStatusErrorDomain Code=-50 "(null)", null, null) #1740

Open
2 tasks done
nagringapp opened this issue Jan 3, 2024 · 6 comments
Assignees
Labels
bug platform-ios Affects the ios platform

Comments

@nagringapp
Copy link

Checklist

  • I read the troubleshooting guide before raising this issue
  • I made sure that the issue I am raising doesn't already exist

Current bug behaviour

I often get the following error on my console.

lutter: ^[[38;5;196m┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: ^[[38;5;196m│ PlatformException(DarwinAudioError, Error configuring audio session: Error Domain=NSOSStatusErrorDomain Code=-50 "(null)", null, null)<…>
flutter: ^[[38;5;196m├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄<…>
flutter: ^[[38;5;196m│ #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)<…>
flutter: ^[[38;5;196m│ #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)<…>
flutter: ^[[38;5;196m│ #2 <…>
flutter: ^[[38;5;196m├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄<…>
flutter: ^[[38;5;196m│ ⛔ Global Error<…>
flutter: ^[[38;5;196m└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: ----------------FIREBASE CRASHLYTICS----------------
flutter: PlatformException(DarwinAudioError, Error configuring audio session: Error Domain=NSOSStatusErrorDomain Code=-50 "(null)", null, null)
flutter:
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)

flutter: ----------------------------------------------------
[Global Error] Global Error
[Global Error] PlatformException (PlatformException(DarwinAudioError, Error configuring audio session: Error Domain=NSOSStatusErrorDomain Code=-50 "(null)", null, null))
[Global Error] #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)

Expected behaviour

Playe without errors

Steps to reproduce

Just play the music - see code below

Code sample

Code sample
oid _initAudioPlayer(String url) async {
    
    try {
      
      _audioPlayer = AudioPlayer(playerId: _musicId);
      _audioPlayer.setAudioContext(const AudioContext(
        android: AudioContextAndroid(
          contentType: AndroidContentType.music,
          isSpeakerphoneOn: true,
          stayAwake: true,
          usageType: AndroidUsageType.media,
          audioFocus: AndroidAudioFocus.gainTransientExclusive
        ),
        iOS: AudioContextIOS(
          category: AVAudioSessionCategory.multiRoute,
          options: [
            AVAudioSessionOptions.allowAirPlay, 
            AVAudioSessionOptions.allowBluetooth,
            AVAudioSessionOptions.allowBluetoothA2DP,
            AVAudioSessionOptions.defaultToSpeaker,
            AVAudioSessionOptions.interruptSpokenAudioAndMixWithOthers
          ],
        )
      ));

      await _audioPlayer.play(UrlSource(url));
      
      
    } catch (e, s) {
      Log.error('EsquentaPlayer._init', e, s);

    }
  }

Affected platforms

Android, iOS

Platform details

No response

AudioPlayers Version

5.2.1

Build mode

debug

Audio Files/URLs/Sources

No response

Screenshots

No response

Logs

my relevant logs
Full Logs
my full logs or a link to a gist

Flutter doctor:

Output of: flutter doctor -v

Related issues / more information

No response

Working on PR

no way

@nagringapp nagringapp added the bug label Jan 3, 2024
@cgfischer
Copy link

I am experiencing the same problem. Any update or work-around?

@nagringapp
Copy link
Author

nagringapp commented Jan 18, 2024 via email

@jozes
Copy link

jozes commented Jan 24, 2024

Any progress on this matter? Or workaround?

Interestingly I get the same error only when running on IOS in release mode (on physical device). However, I get no error when running in simulator in debug mode. So this is really annoying.
While digging deeper I found that the error is reported from SwiftAudioPlayersDarwinPlugin.swift when the method is "setAudioContext". In my code I had the following line:

AudioPlayer.global.setAudioContext(audioContext)

which was causing the error and I could not get rid of it although I put in try/catch block. As I am using package Catcher to catch and report errors I found that the app is playing audio when I just continued after getting this error.
So my solution was just to comment out setting audio context and everything works as supposed.

@nagringapp
Copy link
Author

nagringapp commented Jan 24, 2024 via email

@jozes
Copy link

jozes commented Jan 24, 2024

@nagringapp
In my app I am using Catcher to catch all uncaught exceptions and this one was always triggering Catcher to display the error to the app user. So in my case the app was crashing in a "controllable" way reporting an exception via Catcher screen. Interesting, no such exception is occurring in debug mode.

@Gustl22 Gustl22 added the platform-ios Affects the ios platform label Mar 16, 2024
@Gustl22
Copy link
Collaborator

Gustl22 commented Mar 16, 2024

Thank you for the detailed report. I currently have no OSX machine. But I try to solve this at some point. Don't hesitate trying to fix it and post a Merge Request. Thank you!

@Gustl22 Gustl22 self-assigned this Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug platform-ios Affects the ios platform
Projects
None yet
Development

No branches or pull requests

4 participants