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

When autoplay is disabled in the browser, audio and video don't work in Talk and the user is not told why, or what to do about it #1378

Open
wknapik opened this issue Mar 19, 2024 · 5 comments
Labels

Comments

@wknapik
Copy link

wknapik commented Mar 19, 2024

The relationship between the autoplay permission and being able to hear audio, or see video in a call is not obvious.

If the user disables autoplay globally and joins a Talk call, they'll hear no audio and see no video. There is no explanation anywhere. An icon shows up in the address bar allowing the user to permit autoplay, but their attention is not otherwise drawn there, nor is the relationship explained.

IMO Talk should warn the user, similar to how it warns about the microphone being muted system-wide when joining. Google Meet even warns the user if their camera is enabled, but covered.

I assume it would be detectable that audio/video aren't working. In that case we could tell the user how to fix it. Even if there are multiple possible reasons and we can't distinguish the real cause, we could still tell them about autoplay.

Bonus points if we can narrow it down to autoplay and just present a dialog to enable it, instead of describing where to click.

Slack thread

@bcaller
Copy link
Contributor

bcaller commented Mar 27, 2024

I tried to see how to detect autoplay being blocked with the following code:

window.setTimeout("var context = new AudioContext(); console.log(context.state); context.resume().then(function(){console.log(context.state)});", 100)

When run in Brave Talk, the state is running. When run in the context of the 8x8 iframe, its state remains suspended fails.

image

We are running the iframe with the autoplay permission delegated from talk.brave.com to the 8x8 iframe

A permissions policy allows developers to selectively enable and disable browser features and APIs. Once an origin has received autoplay permission, it can delegate that permission to cross-origin iframes with the permissions policy for autoplay. Note that autoplay is allowed by default on same-origin iframes.

image

image

So the autoplay permission can easily be detected by the jitsi iframe. Not sure yet why it's not as simple to retrieve it for the brave parent.

@bcaller
Copy link
Contributor

bcaller commented Mar 27, 2024

I think if the 8x8 frame detected autoplay being blocked it could then either: require a click on the page to resume the context (each time Brave Talk is used) or prompt the user to allow the permission.

@bcaller
Copy link
Contributor

bcaller commented Apr 2, 2024

We can either ask 8x8 to add a check or we can do the check from talk.brave.com as follows:

  • Create an iframe to a cross-origin domain (i.e. not talk.brave.com), needs to be a domain allowed by CSP and a page which doesn't set annoying X-Frame headers.
  • Add a postMessage listener to the iframe
  • Iframe runs (new AudioContext()).state: if autoplay is blocked, the result is 'suspended' (otherwise it's 'running')
  • Iframe needs to communicate this back to the talk.brave.com parent via postMessage
  • If the iframe reports that the audio context started in the suspended state, Brave Talk needs to prompt the user to open the page permissions - there is no builtin permissions dialog for this, so we need to show instructions.

@goodov
Copy link
Member

goodov commented Apr 18, 2024

Looks like this is solvable with existing APIs available in browser, I don't see anything we should change browser-side.

@mrose17
Copy link
Member

mrose17 commented May 7, 2024

Need to discuss with the Jitsi folks.

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