Audio is not working from a webgl application running on ios mobile browser.

Hi,
when a Webgl application made to run it on a ios device in chrome and in safari, the audio from the application is not getting from the device. Is there any way to get audio from the IOS device.
The same thing is working in Android and in Laptops.
How to get audio from a webgl application while running in a Mobile browser (in iphones)?

1 Like

I have the same problem. I think its because of something in ios17

That’s an interesting thought! @unity_107801B5E237A5D0D25D what version of IOS and Unity are you using. Could you provide Safari logs with WebInspector?

Also, a peculiarity of webgl build is that an interaction is needed from the use for the audio context to start. I don’t see why it would work on Android but not IOS, but does anything change if you interact with buttons,triggers, etc?

I am facing similar issue The audio is playing from earpiece instead of speaker and this happens only when I use WebGL template from Imagine WebAR - Image Tracker | Camera | Unity Asset Store but the same thing works perfectly on android windows and MAC WebGL.

When I imported the MP3 into Unity, I encountered audio issues in iOS WebGL, but it worked fine on other platforms. Later, when I switched to importing WAV files, the issue was resolved. (Sorry for using a translation tool.)

Different device hardware or version of OS sometimes have different behaviors, it is quite hard to develop and test for all the variations. The best thing you could do is to submit a bug report using a minimal project reproducing the issue, and it is very important to add the information related to your device:

  • What is the model of the phone
  • What version of OS is it running
  • What is the version of Unity you used to build this project

That is very interesting… it looks like an asset importing tool bug. Does it happen with ALL mp3 files or only specific ones?

If it happens with all the mp3 files, please submit a bug report as this is clearly an issue. If it’s only on specific files, it might be worth trying to reencode them to another format, or even maybe to something-else-then-back-to-mp3, because maybe there is a minor corruption in an mpeg frame that is problematic.

When importing MP3 files, we have encountered issues such as normal audio playback, no sound, or distorted audio (electronic noise) only on iOS web pages. We are transitioning from Cocos to Unity for web development, and these MP3 files do not exhibit any abnormalities when produced in Cocos. Our music partner has provided us with MP3 and WAV formats, so Unity decided to test with WAV format, and unexpectedly, it worked flawlessly.

Are you using the Editor on Windows, Mac or Linux?

When you target WebGL with Unity and go to File >> Build Settings and switch to a specific platform, audio assets are all reimported to 44.1kHz MP4/AAC. Just to make it more fun, this conversion is handled by tools on the system, such as MediaFoundation, AVFoundation, FFMPEG, etc…

It is possible that there is an issue on this conversion path and that MP3 files are not properly processed depending on your editor platform.

The platform used is Windows, with Unity version 2022.3.7. The audio files are all in 48kHz format. However, when I tried the approach you mentioned, converting them to 44.1kHz using different software, they played normally.

It’s puzzling why this issue seems to be so pronounced on iOS WebGL.

1 Like

The system being used is Windows, and Unity version 2022.3.7 is employed. All audio files are in 48kHz format. However, it’s worth noting that when I followed your suggested approach and converted them to 44.1kHz using different software, they played without any issues.

1 Like

@yakkalajayaram @SeventhString - I believe the audio-playing-in-earpiece issue occurs in iOS 17 as soon as the user accepts the camera permission popup. This is easily reproducible by creating a Webcamtexture in Unity, while playing a looping audio source.

Thus, I don’t think it is related in any way to 44.1/48kHz encoding, or is it?

yeah i’m having the same issue with IOS 17 web gl, audio is playing through earpiece speaker and not the louder bottom speaker. Using zapwork’s univeral AR

1 Like

I am having the same issue. Using Zappar’s Unity SDK.
No problems on Android, Windows, and iPad.
On iOS devices audio only plays through earpiece.
I added a button and attached the audio to it for User Interaction Requirement. But it does not fix the problem.
Any solid workarounds for this?

Same here. Works fine everywhere except on my iPhone it only works with headphones

I can relate to the issue.

As I understand, in 2026, Audio in Chrome on iOS will not work when using a non-secure connection: HTTP or self-signed HTTPS. Safari provides the same experience.

But, on Android sound works, because there is an option in the Chrome Settings of Page Permissions to turn on the sound.