Skip to content

WebAudio Orientation example not working on mobile browser (iOS) #18654

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

Closed
2 tasks done
dataexcess opened this issue Feb 17, 2020 · 25 comments
Closed
2 tasks done

WebAudio Orientation example not working on mobile browser (iOS) #18654

dataexcess opened this issue Feb 17, 2020 · 25 comments

Comments

@dataexcess
Copy link

dataexcess commented Feb 17, 2020

Description of the problem

I am having problems making PositionalAudio work on mobile. I am initialising everything Audio related after a user click like so:

$('#enter-popup').click( function() { 
    $('#enter-popup').hide()
    var AudioContext = window.AudioContext || window.webkitAudioContext    
    audioContext = new AudioContext()
    listener = new THREE.AudioListener()
    camera.add(listener)
    createSoundObjects()
    setupLocalUser()
})

The createSoundObjects method fetches a source url from firebase and uses it for the initialiser of my "Sound" class like so..

this.mediaElement = new Audio(url);
this.mediaElement.loop = true;
this.mediaElement.preload = 'auto';
this.mediaElement.crossOrigin = 'anonymous';
this.mediaElement.play()

This works great on desktop, but I cannot get it to work on mobile (iOS 13, Safari && Chrome && Firefox).

I then proceeded to check out some examples and found out that the official WebAudio Orientation example isn't working either.

=> https://threejs.org/examples/webaudio_orientation.html

Nothing abnormal is getting logged in my console. please help. Thank you.

Three.js version
  • "three": "^0.112.1"
Browser
  • All of them
OS
  • iOS
Hardware Requirements (graphics card, VR Device, ...)
  • iPhone XS (iOS 13)
@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 17, 2020

I'm unable to reproduce on a Pixel (1) Android with latest Chrome and Firefox. The example works as expected. I don't have an iOS device at hand so somebody else needs to confirm this issue.

BTW: The following two lines of code should not be necessary when using the audio classes of three.js:

var AudioContext = window.AudioContext || window.webkitAudioContext    
audioContext = new AudioContext()

three.js internally manages the audio context so there is no need to do this on application level.

@dataexcess
Copy link
Author

I'm unable to reproduce on a Pixel (1) Android with latest Chrome and Firefox. I don't have an iOS device at hand so somebody else needs to confirm this issue.

BTW: The following two lines of code should not be necessary when using the audio classes of three.js:

var AudioContext = window.AudioContext || window.webkitAudioContext    
audioContext = new AudioContext()

three.js internally manages the audio context so there is no need to do this on application level.

Thanks for the clarification. :)
I guess I added those lines trying to fix the"iOS" related bug, but yeah out of pure ignorance...

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 17, 2020

What do you mean with "does not work"? Do you hear no sound at all in webaudio_orientation? Or does the audio not have any spatiality?

@dataexcess
Copy link
Author

dataexcess commented Feb 17, 2020

What do you mean with "does not work"? Do you hear no sound at all in webaudio_orientation? Or does the audio not have any spatiality?

no sound at all. when visiting another website (youtube) there is sound.

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 17, 2020

Okay, I see. But the other WebAudio examples do work on your iPhone?

@dataexcess
Copy link
Author

Okay, I see. But the other WebAudio example do work on your iPhone?

No, the webaudio_visualizer example is also not wortking :/

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 17, 2020

All examples work on an iMac with macOS 10.15.3 and Safari/FF/Chrome. So yeah, it is obviously an iOS issue.

@dataexcess
Copy link
Author

All examples work on an iMac with macOS 10.15.3 and Safari/FF/Chrome. So yeah, it is obviously an iOS issue.

Yep, tested this myself with my MacBook Pro.
All good.

@dataexcess
Copy link
Author

All examples work on an iMac with macOS 10.15.3 and Safari/FF/Chrome. So yeah, it is obviously an iOS issue.

Yep, tested this myself with my MacBook Pro.
All good.

I just tested on iOS 12. The examples seem to work.
So it is definitely an iOS 13 issue.

Sadly enough my code does not work on either...

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 17, 2020

Probably related: #17948

@mrdoob
Copy link
Owner

mrdoob commented Feb 18, 2020

Hmm, will test tomorrow.

@dataexcess
Copy link
Author

Any chance you tested this on iOS 13?
I Just want to know if it is a general issue, or somehow caused by my device/configuration. 🙂

Thnx

@mrdoob
Copy link
Owner

mrdoob commented Feb 26, 2020

I can confirm that https://threejs.org/examples/webaudio_orientation.html works on Safari 12.1/iOS 12.4.

@mrdoob
Copy link
Owner

mrdoob commented Feb 26, 2020

Updating to iOS 13.3.1...

@mrdoob
Copy link
Owner

mrdoob commented Feb 26, 2020

And I can confirm that audio no longer works in Safari 13/iOS 13.3.

@mrdoob
Copy link
Owner

mrdoob commented Feb 26, 2020

The console has no relevant messages either.

Screen Shot 2020-02-25 at 4 39 36 PM

So I guess this should be reported to Apple instead...

@chrisguttandin
Copy link

Hi everyone, I guess this is caused by a bug in Safari (https://bugs.webkit.org/show_bug.cgi?id=203435) which seems to be fixed but not yet shipped.

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 26, 2020

That would perfectly explain why webaudio_orientation is broken.

@dataexcess
Copy link
Author

Hi everyone, I guess this is caused by a bug in Safari (https://bugs.webkit.org/show_bug.cgi?id=203435) which seems to be fixed but not yet shipped.

👏 good find. 👍

Keep in mind it is not just a Safari issue, also does not work on Chrome and Firefox. Basically anywhere were MediaElement is used in code.

I guess nothing to do but wait it out... (or is there an alternative way to play audio sources?)

Cheers!

@chrisguttandin
Copy link

Unfortunately there is no real Firefox or Chrome on iOS. Apple doesn't allow that. Every browser is a Safari (or WebKit) on the inside.

If your audio file is small enough you could use an AudioBufferSourceNode to play it. But I'm not sure how that works with three.js.

@dataexcess
Copy link
Author

Unfortunately there is no real Firefox or Chrome on iOS. Apple doesn't allow that. Every browser is a Safari (or WebKit) on the inside.

If your audio file is small enough you could use an AudioBufferSourceNode to play it. But I'm not sure how that works with three.js.

aha, didn't know that.
but makes sense., coming from Apple...

@dataexcess
Copy link
Author

@chrisguttandin Any chance we can find out when the fix will be shipped?

@chrisguttandin
Copy link

I have no idea. Hopefully it comes with the next security update for iOS but I wouldn't bet on it. :-(

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 26, 2020

Any chance we can find out when the fix will be shipped?

You might want to ask this question at the webkit issue 👍

@Mugen87 Mugen87 closed this as completed Feb 26, 2020
@dataexcess
Copy link
Author

Any chance we can find out when the fix will be shipped?

You might want to ask this question at the webkit issue 👍

Ok! Thnx

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

4 participants