Hubs-Foundation / hubs

Duck-themed multi-user virtual spaces in WebVR. Built with A-Frame.
https://hubsfoundation.org
Mozilla Public License 2.0
2.13k stars 1.42k forks source link

Audio Pannernode behavior bug on iOS Safari and iOS Chrome #5458

Open pigubaoza opened 2 years ago

pigubaoza commented 2 years ago

Description I created a room with multiple audio files with linear roll off in Spoke. As expected, on Chrome desktop, the audio fades in as the avatar gets closer, and fades out as I get further. However on iOS Safari, all audio files start playing at once in all locations of the room. On iOS Chrome, some of the audio files don’t even play. Is this a known bug? and quick fixes I can do as a user?

To Reproduce Steps to reproduce the behavior:

  1. Create a room in Spoke, upload 2 different audio files, and put them in the scene
  2. Check "Override Audio Settings", choose "Pannernode", change Distance Model to "Linear", and set "Max distance" to a small number.
  3. Publish the scene to Hubs and create room.
  4. View the room on iOS Safari and iOS Chrome

Expected behavior The audio should fade in as the avatar gets closer, and fades out as the avatar gets further from the audio source. However, all audio are playing at once on iOS Safari, and might or might not be playing on iOS Chrome

Screenshots NA, audio issue

Hardware

Additional context It might be related to this issue https://github.com/mozilla/hubs/issues/4411 I have also asked this question on discord: https://discord.com/channels/498741086295031808/819203046931693589/978877075354173440

takahirox commented 2 years ago

Hi, thanks for the problem report.

Regarding the problem on iOS Safari, yes currently we force to disable the panning audio. But the audio gain should still be dependent on the distance. Further audio should be quieter.

Can you to test to disable panning audio from the pereference on desktop Chrome to check if the problem is reproducible? I want to know if the problem is iOS or Safari specific.

Regarding the problem on iOS Chrome, sounds like another problem from the above. Can you check the console warning or error on your device? If you can, would you share the warning/error messages with us?

pigubaoza commented 2 years ago

Hey @takahirox thanks for the reply.

after some trial and error on my own, i've found out that this only happens when there is a large number of audio files set to pannernode, and linear rolloff. I have not found out what this threshold number is.

A guess is that the linear distance model return value is not explicitly clamped to 0 and 1 in audio-gain-system.js, so the gain is able to become a large negative number, and this might behave differently on iOS webkit and Chrome V8. it's clamped in audio-debug.frag.

i have not fixed the issue but these are some guesses with what i can see from the code.

takahirox commented 2 years ago

Thanks for the info.

Can you make and share a room where you can reproduce the problem? It helps us investigate the problem.

Dayk0 commented 2 years ago

I reproduced the problem on my side by putting the maximum distance at 10m as well as the linear mode. It does not work on iOS. Whether on Safari or Chrome. I stuck to the media (a video with sound) and nothing to do. Whereas when I leave the maximum distance at 10000m, it works.

Dayk0 commented 2 years ago

I managed to reproduce the bug and the problem comes from the format of the videos. With an external audio output in mpeg it does not work. I managed to get the sound working by changing the audio output to AAC LAV format only.

takahirox commented 2 years ago

Hi, thanks for the report. Do you mind shareing the link to the room that you used for the tests with us? It helps us for testing.

pigubaoza commented 9 months ago

sorry for my silence for over a year. i saw that there has been some changes and old projects are not stored anymore. but for what it's worth, i believe these were two scenes i was working on with this issue https://hubs.mozilla.com/spoke/projects/V4qNugf https://hubs.mozilla.com/spoke/projects/ZLMVCuD