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

Godot returns **ERROR**: AudioOutputUnitStart failed, code: -50 on iOS when silent mode is enabled on the iOS device #50638

Open
Tracked by #76797
vanoak opened this issue Jul 20, 2021 · 19 comments

Comments

@vanoak
Copy link

vanoak commented Jul 20, 2021

Godot version

3.3.2 stable

System information

MacOS Big Sur 11.4, iOS 12.5.4, iPhone 6

Issue description

Hello,

Made my first attempt to export to iOS. I attempted with the Audio Generator Demo from the Asset Library which I did successfully.

After that all my attempts to export even a simple app with one sprite with an AudtioStreamPlayer node running an OGG file will return the error **ERROR**: AudioOutputUnitStart failed, code: -50, which is

Mac OS error -50 (paramErr): error in user parameter list

My guess it is that something went missing from a plist file, but had I to know Godot internals to check how Godot is initialising the AudioOutput to dig deeper (i'm a competent scripter but not a developer).

Phone sound is ok with other apps, btw.

Steps to reproduce

New Project (GLES3)
Add any sprite (just to show something)
Add a AudioStreamPlayer, add an OGG audio file, on Loop and Autoplay.
Save Default Bus Layout.
Confirm that in Project Settings->Audio Driver is set to Core Audio
Export to iOS template - arm7, arm64
Open xcodeproject in XCode
Accept changes on Build Settings and translation to English.
Build successfully, runs on device but no sound;
Logs say

2021-07-20 00:33:20.440427+0100 Ios[429:26956]    At: drivers/coreaudio/audio_driver_coreaudio.cpp:254:start() - AudioOutputUnitStart failed, code: -50```
@Calinou
Copy link
Member

Calinou commented Jul 20, 2021

Confirm that in Project Settings->Audio Driver is set to Core Audio

This setting is only used on macOS, not iOS. The audio driver setting is OS-specific, and not all platforms have multiple audio drivers (in fact, only Linux really does with PulseAudio and ALSA).

@vanoak
Copy link
Author

vanoak commented Jul 20, 2021

Ok, good to know. Thank you.

@svprdga
Copy link

svprdga commented Jul 27, 2021

Same issue here, in my case with an *.mp3 audio file.

From the ignorance, my guess is that maybe @vanoak and me have some specific hardware (or system) conditions that maybe triggers this error. I think so because it's so easy to reproduce this error, so I guess that if it was a general error it would be already discovered when creating the 3.3.2 release.

I use an M1 mac to build the export, can this be related?

@Calinou
Copy link
Member

Calinou commented Jul 27, 2021

I think so because it's so easy to reproduce this error, so I guess that if it was a general error it would be already discovered when creating the 3.3.2 release.

Godot's iOS-targeting userbase is not that large, so it's possible that nobody bothered reporting the result (or even tested it in the first place). Most core contributors don't have access to an iOS device and a macOS device (which is required to export to iOS) – that includes me.

Edit: Godot does support audio playback on iOS and it's been working well so far. The issue here is that the audio generator demo likely causes specific trouble that happens to linger on when exporting other unrelated projects from the same PC. Some of the official demo projects are quite niche and don't get much testing on various platforms as a result. Unfortunately, troubleshooting this issue is pretty much impossible without hardware access.

@svprdga
Copy link

svprdga commented Jul 27, 2021

Godot's iOS-targeting userbase is not that large, so it's possible that nobody bothered reporting the result (or even tested it in the first place). Most core contributors don't have access to an iOS device and a macOS device (which is required to export to iOS) – that includes me.

I see.

Well, I was considering Godot for the next game for my company but it is automatically discarded based on what you said.

I understand that mobile is not the current focus for the Godot team, but if in the future is, I recommend providing the same features and performing the same kind of tests for both Android & iOS, as the vast majority of companies won't bother to invest in an engine that only performs correctly in one of them.

Thanks for the clarification @Calinou

@akien-mga
Copy link
Member

CC @godotengine/ios

A minimum reproduction project as a ZIP would be useful. The steps outlined in OP are not too complex but given that it involves changing project settings, it would be best to ensure contributors have access to the exact same setup.

@vanoak
Copy link
Author

vanoak commented Jul 27, 2021

@akien-mga @Calinou i can provide the minimum reproduction project, but the export settings would not be the same because i will not provide my apple developer information, so it will be a vanilla godot project file, so I think not that useful. Or I can dig a little deeper hardware-wise in order to help you troubleshoot the problem, if you tell me what am I looking for.

@svprdga
Copy link

svprdga commented Jul 27, 2021

Here's a reproducible example:

https://github.com/svprdga/godot-issue-50638

@naithar
Copy link
Contributor

naithar commented Jul 27, 2021

Tested https://github.com/svprdga/godot-issue-50638 on stable 3.3.2 on iPhone XS (14.6).
After disabling silent mode (side button) and turning on the sound everything is working fine - iPhone plays sound on button tap the same way it happens when running project in editor.

**ERROR**: AudioOutputUnitStart failed, code: -50 error is logged probably when Godot tries to start it's audio session before iOS platform manages to initialize it. After iOS platform is completely initialised, audio session should be started automatically without any issue.

@vanoak
Copy link
Author

vanoak commented Jul 27, 2021

Confirmed. Error still occurs but app plays sound.

@naithar
Copy link
Contributor

naithar commented Jul 27, 2021

Confirmed. Error still occurs but app plays sound.

In OP you've mentioned that there was no sound. Was issue related to the silent mode?

@vanoak
Copy link
Author

vanoak commented Jul 27, 2021

I have my phone always on silent mode (ringer off).

I made a quick check and most of my used apps play sound even in silent mode. The two quick tests that I exported right now from Godot to iOS play sound only when silent mode is off. If that is the expected behaviour then the issue is resolved.

If that is the case, I must conclude that I associated the initialisation error with running the app on silent mode, not being aware beforehand that Godot only plays audio when silent mode is off (ringer on).

@naithar
Copy link
Contributor

naithar commented Jul 27, 2021

Most of the games that are installed on my phone have the same behavior (no sound in silent mode). Other apps are probably using different session category.
Godot uses Ambient session category: https://github.com/godotengine/godot/blob/3.x/platform/iphone/app_delegate.mm#L96. So changing it might affect the way sound is played.

@bruvzg
Copy link
Member

bruvzg commented Jul 27, 2021

I made a quick check and most of my used apps play sound even in silent mode.

Godot uses AVAudioSessionCategoryAmbient audio mode, which disabled audio in background, in silent mode and with locked screen, so this is expected, but we probably can add a switch to optionally change it to AVAudioSessionCategoryPlayback.

@bruvzg
Copy link
Member

bruvzg commented Jul 27, 2021

I can also confirm the -50 (kAudio_ParamError) error, but sound seems to work fine. Probably one of the audio unit parameters is set unsupported value (code is shared with macOS), but I'm not sure which one.

@svprdga
Copy link

svprdga commented Jul 28, 2021

Godot uses AVAudioSessionCategoryAmbient audio mode, which disabled audio in background, in silent mode and with locked screen, so this is expected, but we probably can add a switch to optionally change it to AVAudioSessionCategoryPlayback.

That would be great, as I think that there are a lot of people with the silent mode enabled. I think that I got it enabled when I bought my iphone, so having to remember the player that if he/she doesn't hear anything might be because of their audio mode is not ideal.

@Calinou Calinou changed the title simple godot app returns **ERROR**: AudioOutputUnitStart failed, code: -50 on iOS Godot returns **ERROR**: AudioOutputUnitStart failed, code: -50 on iOS when silent mode is enabled on the iOS device Jul 29, 2021
@troy-lamerton
Copy link

I made a quick check and most of my used apps play sound even in silent mode.

Godot uses AVAudioSessionCategoryAmbient audio mode, which disabled audio in background, in silent mode and with locked screen, so this is expected, but we probably can add a switch to optionally change it to AVAudioSessionCategoryPlayback.

If an option will be added, please make it an option to choose the real AVAudioSession category. A dropdown to pick from the AVAudioSessionCategory enum would work for me. Unity started with toggles and I had to 'brute force' these toggles to get the category that I needed (still not exactly right).

Unity's audio player settings for iOS:
unity ios audio settings

What does each one do? You'll have to read the docs and then try for yourself to uncover the bugs.

Btw I want to ensure Godot continues to be easy to use, I don't mean to rant about other game engines.

@Duikbood
Copy link

Sorry to bring this up again, but is it already possible to switch to AVAudioSessionCategoryPlayback audio mode?

I still didn't manage to get my sound working on iOS in silent mode. As stated above; people mainly run their iPhone on silent mode and I don't want to force my users to toggle that off for the actual sounds to play.

If yes, please let me know! :-)

@Ughuuu
Copy link
Contributor

Ughuuu commented Nov 28, 2023

It is working now (In Godot 4). Set audio/general/ios/session_category to Playback. In the Project Settings.
https://docs.godotengine.org/es/4.x/classes/class_projectsettings.html#class-projectsettings-property-audio-general-ios-session-category
As per docs:
Sets the AVAudioSessionCategory on iOS. Use the Playback category to get sound output, even if the phone is in silent mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants