hubs icon indicating copy to clipboard operation
hubs copied to clipboard

Audio Pannernode behavior bug on iOS Safari and iOS Chrome

Open pigubaoza opened this issue 2 years ago • 7 comments

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

  • Device: iPhone 13 Pro
  • OS: iOS 15.5 (19F77)
  • Browser: Safari, Chrome 102.0.5005.67

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

pigubaoza avatar May 25 '22 04:05 pigubaoza

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?

takahirox avatar May 25 '22 23:05 takahirox

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.

pigubaoza avatar May 26 '22 05:05 pigubaoza

Thanks for the info.

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

takahirox avatar May 26 '22 06:05 takahirox

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 avatar Jun 21 '22 16:06 Dayk0

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.

Dayk0 avatar Jun 23 '22 09:06 Dayk0

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.

takahirox avatar Jun 24 '22 20:06 takahirox

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

pigubaoza avatar Dec 02 '23 03:12 pigubaoza