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

PositionalAudio doesnt work on VisionOS in VR #27779

Open
marwie opened this issue Feb 19, 2024 · 12 comments
Open

PositionalAudio doesnt work on VisionOS in VR #27779

marwie opened this issue Feb 19, 2024 · 12 comments

Comments

@marwie
Copy link
Contributor

marwie commented Feb 19, 2024

Description

PositionlAudio is not working on vision OS (simulator) when entering VR

Reproduction steps

  1. Open webaudio-orientation example and add the VR button
  2. Start server
  3. Open in Safari on VisionOS or Simulator (make sure you have WebXR flags enabled)
  4. Click Play - note audio is starting
  5. Click Enter VR button - note audio is not playing

Code

needle-tools@1064ee0

Live example

https://uploads.needle.tools/bugreports/threejs%20positional%20audio/examples/webaudio_orientation

Screenshots

No response

Version

160

Device

Headset

Browser

Safari

OS

No response

@marwie marwie changed the title PositionalAudio doesnt work on VisionOS VR PositionalAudio doesnt work on VisionOS in VR Feb 19, 2024
@hybridherbst
Copy link
Contributor

@mrdoob Do you happen to have any idea here?

@mrdoob
Copy link
Owner

mrdoob commented Feb 21, 2024

Hmm... If the Vision Pro is still at my desk tomorrow I'll have a look 👀

@mrdoob
Copy link
Owner

mrdoob commented Feb 27, 2024

I tried this the other day.

I think it has to be a Safari bug because I noticed the audio did get filtered when leaving VR.

@hybridherbst
Copy link
Contributor

Thanks for trying. So you think it's a WebAudio bug on their end? Regular HTML audio elements continue playing just fine it seems.

@mrdoob
Copy link
Owner

mrdoob commented Feb 28, 2024

I think so yeah.

@hybridherbst
Copy link
Contributor

OK, Ada confirmed it to be a bug and restarting the audio context is a workaround for now:

Is it ok if I keep this issue open until the root cause is fixed, even with no actionable item on three.js side?

@mrdoob
Copy link
Owner

mrdoob commented Feb 28, 2024

That's okay 👍

@hybridherbst
Copy link
Contributor

hybridherbst commented Feb 28, 2024

Workaround a customer found today:

const ctx = AudioContext.getContext();
ctx.addEventListener ("statechange", async () => {
    if (ctx.state === "suspended" || ctx.state === "interrupted") {
        ctx.resume().then(() => {
            console. log("AudioContext resumed");
        }).catch((err) => {
            console.error ("AudioContext couldn't be resumed", err);
        });
    }
});

@danrossi
Copy link

danrossi commented Mar 1, 2024

I'm doing some testing in the simulator and media stops immediately launching xr. And there is no controls to click to play.

@marwie
Copy link
Contributor Author

marwie commented Mar 1, 2024

I'm doing some testing in the simulator and media stops immediately launching xr. And there is no controls to click to play.

Would you mind trying again here? https://thankful-faint-coral.glitch.me/

@danrossi
Copy link

danrossi commented Mar 1, 2024

In the webxr session start event, forcing video/audio element playback works. Now need to detect for visionOS to do that. actually you can't detect what platform visionOS is. navigator.platform reports Ipad. So have to check if it's Ipad in WebXR and force play.

@hybridherbst
Copy link
Contributor

@danrossi you can add this code somewhere to work around this bug in VisionOS. No need for navigator checks.
#27779 (comment)

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

5 participants