RESOLVED FIXED 122560
scriptProcessor Node not working on iOS (Safari/Chrome)
https://bugs.webkit.org/show_bug.cgi?id=122560
Summary scriptProcessor Node not working on iOS (Safari/Chrome)
Leinho
Reported 2013-10-09 10:50:34 PDT
Created attachment 213792 [details] Code of my app where scriptProcessor Node is not working on iOS I have created an app in HTML 5 that generates white noise on its own using a ScriptProcessorNode (Google Chrome) or a JavaScriptNode (Safari). All is working fine for Google Chrome/Safari on my Mac and also in my Android phone but it is not working in Safari/Chrome on my iPod Touch 5th/iPad 4th on iOS 6.1.2. Browsers checked: iOS: Mob Safari 6.0 (Not working) (536.26 WebKit) Chrome Mob iOS 30.0.1.1599 (Not working) (536.26 WebKit) Mob Safari 7.0 (Not working) MAC: Desktop Chrome 30.0.1599 on MAC (Working) (537.36 WebKit) Desktop Safari 6.0.5 on Mac (Working) (536.30.1 WebKit) Android: Chrome 29.0.1547.59 1547059 (Working) (WebKit 537.36) I have a button on the screen that when it is touched the gainNode is connected to context.destination or it's disconnected. I can see that onaudioprocess event is not triggered on my iPod (iOS 6.1.2 Safari and Chrome)... I am attaching the code of my simple app. What am I doing wrong? Is something different from Safari/Chrome on iOS than for MAC that I am not considering? I need to create sound samples on the fly... If this work I would add a filter node to filter the white noise for generating other sounds as the user wants. Thanks!
Attachments
Code of my app where scriptProcessor Node is not working on iOS (18.98 KB, application/zip)
2013-10-09 10:50 PDT, Leinho
no flags
Added another button that must be touched before play/stop button. It is used to initialise the objects including the audioContext. (19.05 KB, application/zip)
2013-10-11 05:21 PDT, Leinho
no flags
Here I am initialising the context in the onLoad method. It is working using audioBufferSource class. (19.14 KB, application/zip)
2013-10-11 06:55 PDT, Leinho
no flags
Jer Noble
Comment 1 2013-10-10 10:39:59 PDT
iOS Safari has an additional restriction that desktop Safari (and Chrome/Android) do not: The audio context must be created in response to a user event. If you restructure your code so that init() is called from within Start_Audio(), the sample works fine.
Leinho
Comment 2 2013-10-11 05:19:47 PDT
I have tried what you said but still with no success. I am attaching my new code that is not working on iOS yet. I have tested it on iOS 6.1.2 (Safari and Chrome)... By the way, I have found this web: http://compatibility.shwups-cms.ch/en/home? In this link I see that scripProcessor isn't supported on Chrome or Safari. I am using JavaScriptNode in case scriptProcessor isn't supported but still not working on iOS 6. Is that site trustable? What are you using as platform? Thanks! (In reply to comment #1) > iOS Safari has an additional restriction that desktop Safari (and Chrome/Android) do not: > > The audio context must be created in response to a user event. > > If you restructure your code so that init() is called from within Start_Audio(), the sample works fine.
Leinho
Comment 3 2013-10-11 05:21:46 PDT
Created attachment 213982 [details] Added another button that must be touched before play/stop button. It is used to initialise the objects including the audioContext.
Leinho
Comment 4 2013-10-11 05:22:41 PDT
Comment on attachment 213982 [details] Added another button that must be touched before play/stop button. It is used to initialise the objects including the audioContext. I can not hear anything yet on iOS 6.1.2
Leinho
Comment 5 2013-10-11 05:35:33 PDT
Comment on attachment 213982 [details] Added another button that must be touched before play/stop button. It is used to initialise the objects including the audioContext. I can not hear anything yet on iOS 6.1.2
Leinho
Comment 6 2013-10-11 06:54:15 PDT
Also, this code is working on iOS 6.1.2, both browsers, and the audioContext is created in onLoad... I am looping on an audioBuffer using audioBufferSource node. The code I mentioned is attached as: "audiocontext initialised in onLoad method". (In reply to comment #2) > I have tried what you said but still with no success. I am attaching my new code that is not working on iOS yet. I have tested it on iOS 6.1.2 (Safari and Chrome)... > > By the way, I have found this web: http://compatibility.shwups-cms.ch/en/home? > > In this link I see that scripProcessor isn't supported on Chrome or Safari. I am using JavaScriptNode in case scriptProcessor isn't supported but still not working on iOS 6. Is that site trustable? > > What are you using as platform? > > Thanks! > > > > > (In reply to comment #1) > > iOS Safari has an additional restriction that desktop Safari (and Chrome/Android) do not: > > > > The audio context must be created in response to a user event. > > > > If you restructure your code so that init() is called from within Start_Audio(), the sample works fine.
Leinho
Comment 7 2013-10-11 06:55:24 PDT
Created attachment 213987 [details] Here I am initialising the context in the onLoad method. It is working using audioBufferSource class.
Jer Noble
Comment 8 2013-10-11 08:22:27 PDT
(In reply to comment #2) > By the way, I have found this web: http://compatibility.shwups-cms.ch/en/home? > > In this link I see that scripProcessor isn't supported on Chrome or Safari. I am using JavaScriptNode in case scriptProcessor isn't supported but still not working on iOS 6. Is that site trustable? That site is not trustworthy.
Leinho
Comment 9 2013-10-11 08:24:00 PDT
Great to know that! Hope you can help me! (In reply to comment #8) > (In reply to comment #2) > > By the way, I have found this web: http://compatibility.shwups-cms.ch/en/home? > > > > In this link I see that scripProcessor isn't supported on Chrome or Safari. I am using JavaScriptNode in case scriptProcessor isn't supported but still not working on iOS 6. Is that site trustable? > > That site is not trustworthy.
Jer Noble
Comment 10 2013-10-11 08:29:35 PDT
There are still a number of problems with your example. Namely, you have an assertion at line 33 of your most recent index.html, where setting 'context.sampleRate = 44100' fails because context is undefined. You also need to recreate your AudioBufferSourceNode after calling stop(); each AudioBufferSourceNode can only be played once. Please see the spec: <https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AudioBufferSourceNode> You are still calling init() from window.onload, which is not a user event, so this code will still not work in Mobile Safari. Try something like this: function Start_Audio() { if (!context) init(); ... And remove the 'window.onload = init' line.
Leinho
Comment 11 2013-10-11 09:20:40 PDT
Sorry for missing to erase that line. But, the last one (2013-10-11 06:55 PST) is working on Safari. This code was uploaded in order to show you that I can use the context on Safari without problems even declaring in the onLoad method. The one that I uploaded at 2013-10-11 05:21 PST is the update of my first version where I added another button to initialise the context. It is not working on iOS... Thanks for the AudioBufferSourceNode advise, I knew it but I didn't solve it because that is another step in my development. (In reply to comment #10) > There are still a number of problems with your example. Namely, you have an assertion at line 33 of your most recent index.html, where setting 'context.sampleRate = 44100' fails because context is undefined. > > You also need to recreate your AudioBufferSourceNode after calling stop(); each AudioBufferSourceNode can only be played once. Please see the spec: <https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AudioBufferSourceNode> > > You are still calling init() from window.onload, which is not a user event, so this code will still not work in Mobile Safari. Try something like this: > > function Start_Audio() > { > if (!context) > init(); > ... > > > And remove the 'window.onload = init' line.
Leinho
Comment 12 2013-10-14 10:59:52 PDT
Thanks Jer Noble, It's working on iOS 7 now with the suggestion you made. It's a pity that it can not work on iOS 6. It can be noted that an upgrade was made to web audio api compliance on iOS 7 as a scriptProcessor Node can be used. Thanks you very much! (In reply to comment #11) > Sorry for missing to erase that line. > > But, the last one (2013-10-11 06:55 PST) is working on Safari. This code was uploaded in order to show you that I can use the context on Safari without problems even declaring in the onLoad method. > > The one that I uploaded at 2013-10-11 05:21 PST is the update of my first version where I added another button to initialise the context. It is not working on iOS... > > Thanks for the AudioBufferSourceNode advise, I knew it but I didn't solve it because that is another step in my development. > > > > (In reply to comment #10) > > There are still a number of problems with your example. Namely, you have an assertion at line 33 of your most recent index.html, where setting 'context.sampleRate = 44100' fails because context is undefined. > > > > You also need to recreate your AudioBufferSourceNode after calling stop(); each AudioBufferSourceNode can only be played once. Please see the spec: <https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AudioBufferSourceNode> > > > > You are still calling init() from window.onload, which is not a user event, so this code will still not work in Mobile Safari. Try something like this: > > > > function Start_Audio() > > { > > if (!context) > > init(); > > ... > > > > > > And remove the 'window.onload = init' line.
Note You need to log in before you can comment on or make changes to this bug.