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

Implement autoplay-policy conformance for main ShinySDR UI #125

Open
ofadam opened this issue Jan 23, 2019 · 26 comments
Open

Implement autoplay-policy conformance for main ShinySDR UI #125

ofadam opened this issue Jan 23, 2019 · 26 comments
Labels

Comments

@ofadam
Copy link

ofadam commented Jan 23, 2019

When I initially launch ShinySDR via any web browser, the audio is muted although the waterfall display is active and showing signals. I must first click on the "Direct link to audio stream" first, then go back to the dashboard to have working audio. Any idea what may be causing this?

@kpreid
Copy link
Owner

kpreid commented Jan 24, 2019

Which browsers, exactly? In Chrome, I would guess this is due to the newly enabled autoplay restrictions, but that shouldn't trigger on repeated visits to the page.

Is it really the "direct link" that makes it work, or is it just navigating away and back? (Try the other sidebar links, like "ShinySDR Manual".)

Anything in the console?

@kpreid kpreid added the bug label Jan 24, 2019
@ofadam
Copy link
Author

ofadam commented Jan 24, 2019 via email

@ofadam
Copy link
Author

ofadam commented Jan 24, 2019

screen shot 2019-01-23 at 7 14 27 pm

There's a strange sawtooth shape present when no audio.

@ofadam
Copy link
Author

ofadam commented Jan 24, 2019

Firefox works, though!

@kpreid
Copy link
Owner

kpreid commented Jan 24, 2019

That sounds like the AudioContext isn't running (the sawtooth is the audio buffer repeatedly filling up and being thrown out). Please check the console for messages.

@ofadam
Copy link
Author

ofadam commented Jan 24, 2019

The only console items are the following:

gr::log :INFO: audio source - Audio source arch: alsa

INFO:shinysdr:Flow graph: Rebuilding connections because: switched device

INFO:shinysdr:Flow graph: Rebuilding connections because: added receiver a

@kpreid
Copy link
Owner

kpreid commented Jan 24, 2019

Sorry, I mean the browser console.

@ofadam
Copy link
Author

ofadam commented Jan 24, 2019

Ah, right.

"The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page." https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#webaudio

@kpreid
Copy link
Owner

kpreid commented Jan 24, 2019

In my experience, that message can appear even if the AudioContext is working normally. Could you please copy the entire console text so I can see the sequence of messages?

(I'll probably need to add some extra debugging to figure this out, but the complete log might have hints.)

@ofadam
Copy link
Author

ofadam commented Jan 24, 2019

How's this?

main.js:95 Loading plugins…
main.js:95 Connecting to server…
ws-stream.js:68 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
main.js:95 Downloading state…
ws-stream.js:252 Streaming using ScriptProcessor 48000 1ch audio and converting to 48000
ws-stream.js:277 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
bufferer.js:106 Extreme audio overrun.
widget.js:225 Widget Banner did not handle title attribute
main.js:95 Ready.

@kpreid
Copy link
Owner

kpreid commented Jan 24, 2019

OK, unfortunately, that's essentially the same set of messages I see routinely. I've got some ideas, but it'll probably be a few days before I have them out for you to test.

@ofadam
Copy link
Author

ofadam commented Jan 24, 2019

Understood! I really appreciate all the attention you've give it already. It's been an impressive piece of software.

@kpreid
Copy link
Owner

kpreid commented Jan 25, 2019

I pushed 446e6dd which adds debug logging.

For me, on reloading, I get this for a log:

main.js:95 Loading plugins…
main.js:95 Connecting to server…
ws-stream.js:72 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
ws-stream.js:68 audio playback debug: initial state is suspended
main.js:95 Downloading state…
widget.js:225 Widget Banner did not handle title attribute
main.js:95 Ready.
[Violation] 'requestAnimationFrame' handler took 405ms
ws-stream.js:257 Streaming using AudioWorklet 44100 2ch audio and converting to 44100
ws-stream.js:68 audio playback debug: attempting resume, immediate state is suspended
ws-stream.js:283 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
ws-stream.js:68 audio playback debug: attempted resume, immediate state is suspended
ws-stream.js:68 audio playback debug: resume resolved
[Violation] 'requestAnimationFrame' handler took 302ms

So the Chrome autoplay policy seems to be not doing what it's supposed to do, but for me the final result is that playback works anyway. Let me know what your log looks like. No need to copy the stack traces.

@kpreid
Copy link
Owner

kpreid commented Jan 25, 2019

I also notice in your log that the audio stream is running in ScriptProcessor mode rather than AudioWorklet mode. This is surprising. Could you specify exactly which Chrome version you're using?

@ofadam
Copy link
Author

ofadam commented Jan 25, 2019 via email

@kpreid
Copy link
Owner

kpreid commented Jan 26, 2019

@ofadam Please rerun with the latest ShinySDR revision and report the new log results. No need to include the stack traces.

@ofadam
Copy link
Author

ofadam commented May 13, 2019

It's been a while since I worked on this, but the issue remains even in the latest release. Starting the webapp results in silence with a sawtooth audio wave, which is only fixed after clicking on that direct audio link.

@kpreid
Copy link
Owner

kpreid commented May 21, 2019

I've been trying to make progress towards a robust fix for this.

Ignoring the question of any issues with Chrome's actual implementation of the stated autoplay policy, in order to make this work in general we definitely need a client-side state of “muted / not playing” which can then be “unmuted” by the user. I'm making some changes to the UI layout to make a good place for that mute button.

@mathisono
Copy link

mathisono commented May 21, 2019 via email

@kpreid
Copy link
Owner

kpreid commented May 21, 2019

Having audio streams with different content is a bigger problem — right now, the server-side signal flow is completely shared, the only exception being the sample rate conversion for audio. Changing that is covered by issue #73.

And if you've observed bugs, please do report them as separate issues. ShinySDR development is mainly limited by having enough free time to think about how to refactor things, and user-visible bugs are often really simple to tackle so it'll actually get things done faster in total if I know about more of them.

@kpreid
Copy link
Owner

kpreid commented Jul 8, 2019

I was doing some refactoring to prepare to have the above-mentioned mute state and I discovered that it wouldn't actually be guaranteed to resume the context on startup if there's supposed to be audio playing. Oops. Commit aeaaabe fixes that, I hope.

@ofadam Give this update try and let me know if it does anything different?

@ofadam
Copy link
Author

ofadam commented Jan 29, 2020

Hello, I'm back! And still having trouble with audio not playing on initial launch with Chrome. It does with Firefox, somehow. Any further suggestions for ironing this out? I get the sawtooth-like waveform in the audio panel.

@kpreid
Copy link
Owner

kpreid commented Jan 31, 2020

@ofadam Please update ShinySDR to the latest version and post the contents of your console on one of the loads that fails to play audio (no stack traces needed, just the log messages for now).

@ofadam
Copy link
Author

ofadam commented Jan 31, 2020

Loading plugins…
main.js:95 Connecting to server…
ws-stream.js:72 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
ws-stream.js:68 audio playback debug: initial state is suspended
main.js:95 Downloading state…
ws-stream.js:206 Streaming using ScriptProcessor 44100 2ch audio and converting to 44100
ws-stream.js:68 audio playback debug: attempting resume, immediate state is suspended
ws-stream.js:233 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
ws-stream.js:68 audio playback debug: attempted resume, immediate state is suspended
widget.js:235 Widget Banner did not handle title attribute
[Violation] 'requestAnimationFrame' handler took 491ms
[Violation] Forced reflow while executing JavaScript took 112ms
[Violation] 'requestAnimationFrame' handler took 60ms
[Violation] Forced reflow while executing JavaScript took 59ms
[Violation] Forced reflow while executing JavaScript took 39ms
bufferer.js:106 Extreme audio overrun.
[Violation] 'requestAnimationFrame' handler took 277ms

@kpreid
Copy link
Owner

kpreid commented Feb 2, 2020

[I've edited your comment to strip out the stack traces which make it hard to read.]

I don't have any good ideas about why this is happening, but apparently the autoplay policy isn't behaving the same for you as others. (Do you routinely do a 'clear browsing data', or use some other sort of privacy tool, maybe?)

The correct solution here is for ShinySDR to implement a UI to prompt for starting playback when it is needed (as the "audio toolbox" pages already do). I don't seem to have it recorded as an issue already, but the plan I had in mind was to add a “mute/pause” feature to the audio UI. Then, if autoplay is not permitted (or, perhaps, if the user prefers it), the page will start in muted state and the user will have to click to unmute it, which should satisfy the autoplay policy without extra dialogs.

@kpreid kpreid changed the title No audio on initial launch Implement autoplay-policy conformance for main ShinySDR UI Feb 2, 2020
@kpreid kpreid mentioned this issue Aug 27, 2020
@redge76
Copy link

redge76 commented Nov 27, 2020

Temporary and local solution: #148 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants