amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

allow="autoplay" for amp-ad component

Open RonanDrouglazet opened this issue 8 years ago • 18 comments

What's the issue?

Because no attribute allow="autoplay" are present on the amp-ad cross domain iframe, if a muted video is played inside it, the sound can't be unmuted even with a user interaction (click / touch the sound button)

Currently our video node has all the necessary attributes to be played automatically (muted video) but the user are not allowed to unmute the sound because if it does, the video go to pause with a warning in the console "Unmuting failed and the element was paused instead because the user didn't interact with the document before"

an issue has already been created on chromium side because -> this behavior were working on chrome M65, but not since M66 -> we have a user interaction (click on the unmute button) -> the video is still paused

you can find more info (video screen capture / screenshot / etc.. ) in the chromium issue -> https://bugs.chromium.org/p/chromium/issues/detail?id=845817

but for them, it's a framework issue because the amp-ad cross domain iframe doesn't have the allow="autoplay" attribute. I've tested to manually set it via the web console and it works, with this attribute the user is allowed to unmute the video inside the cross domain iframe

How do we reproduce the issue?

  1. go to https://amp.teads.tv
  2. wait a little for the page to be loaded
  3. scroll to the video ad
  4. click on the unmute button (bottom right corner)

the issue is present on desktop AND mobile

ps: do not scroll too fast to the video ad, if you scroll to the slot before the ad is loaded, the AMP framework does not allow the opening of this ad

What browsers are affected?

Chrome 66+ on Android & Desktop

Which AMP version is affected?

All I think

Thanks for you help AMP Team !

RonanDrouglazet avatar Jun 01 '18 13:06 RonanDrouglazet

!! This doesn't seem right. @mounirlamouri, both unmute button and video are in the same iframe, why is allow="autoplay" needed for unmuting via user action?

aghassemi avatar Jun 01 '18 17:06 aghassemi

(just saw the Chrome bug, let's continue the discussion there)

aghassemi avatar Jun 01 '18 18:06 aghassemi

/cc @lannka

aghassemi avatar Jun 01 '18 19:06 aghassemi

/to @lannka comes down to needing allow=autoplay on the 3P iframe.

aghassemi avatar Jun 19 '18 18:06 aghassemi

Hi @aghassemi & @lannka ! Do you think this fix will be done ? Currently we show a sound button which can not work 😞
So can we wait for this attribute to be put on amp-ad iframe, or should we hide our sound button and not allowing sound on AMP (we will have to communicate to publisher about this issue) ?

Thanks for you help !

RonanDrouglazet avatar Jul 10 '18 15:07 RonanDrouglazet

sorry for being late in this thread. Do we let pub to specify <amp-ad allow="autoplay"> and then we pass down the attribute to the iframe? If so, I can quickly come with a PR.

lannka avatar Jul 14 '18 03:07 lannka

Thanks for your feedback @lannka We appreciate your proposition but this implies contacting thousands of publisher and asking them to make a change in their implementation. Since there is a user interaction, some might not understand why this is a need.

=> Is this possible to have this parameter set by default and thus not having any regression with prior implementations? Thanks for your help!

github-nourdine-dahmani avatar Jul 16 '18 14:07 github-nourdine-dahmani

yes, this should be allowed by default, since it really only impacts post-interaction behavior.

cramforce avatar Jul 16 '18 16:07 cramforce

Hi @lannka and @cramforce, hope you're well Any news regarding the fix release? We would like to provide an ETA to some clients Thanks!

github-nourdine-dahmani avatar Jul 25 '18 07:07 github-nourdine-dahmani

hi @ndahmani , @aghassemi had question regarding to your implementation on the chrome bug that @RonanDrouglazet reported.

The current status looks to me is

  1. It's uncertain if this is a Chrome bug or mis-implementation. Given the unmute button was put in a different iframe, for some reason browser didn't tie the user interaction with the unmute call. As Chrome folks asked on the thread, could you come up with a simpler example with the bug.

  2. I tried that adding allow=autoplay does fix the issue

  3. According to Chrome's autoplay policy, allow=autoplay attribute is supposed to be used for parent sites who want to delegate the permission of "autoplay unmuted video" down to an iframe. On mobile, the permission is collected by having user add the site to home screen.

So, 3) will be a side effect of doing a fix as 2). I want to make sure this is OK for all publishers to automatically delegate their autoplay permission down to 3p iframes. @cramforce @jasti what you think?

lannka avatar Aug 02 '18 20:08 lannka

@lannka why is this a non-issue on non-AMP pages? If yes, is the ads cross domain iframe setting allow=autoplay?

jasti avatar Aug 02 '18 21:08 jasti

@lannka why is this a non-issue on non-AMP pages? If yes, is the ads cross domain iframe setting allow=autoplay?

This can be a question for @RonanDrouglazet . did you had to use allow=autoplay in non-AMP world?

lannka avatar Aug 02 '18 21:08 lannka

Hi @jasti & @lannka ! Sorry for the delay, holidays 🏖

Yes we have the same issue (and fix) in the non-AMP world, especially with the IAB SafeFrame implementation, which is pretty similar to the AMP ad management (XDomain iframe / API between child frame & parent / etc..)

DFP SafeFrame integration https://www.thespruce.com/online-etiquette-classes-4159960?kw=4746367666test The Teads ad player is lazy-loaded into a SafeFrame on the bottom of the page capture d ecran 2018-08-16 a 15 36 50 capture d ecran 2018-08-16 a 15 37 43

I've shared the info with the biggest IAB SafeFrame player (doubleclick) via @bradfrizzell but no news for now

Publishers (using AMP and / or SafeFrame) start to complain a lot about this issue 😞(present since almost 3 month now), they don't understand it, and it's normal ... as we have a user interaction with the video

RonanDrouglazet avatar Aug 16 '18 14:08 RonanDrouglazet

If the mute/unmute button is in the main frame and the ad is in a x-origin iframe, clicking the button will not be enough to allow the ad to unmute.

Quoted from the Chrome thread. Again, as mentioned in 1) of my previous comment, it's unclear to me if this is a Chrome bug or a bad implementation in teads. I'm hesitant to enable autoplay for all ad networks in AMP, given the side effect of 3).

I would suggest you folks to follow through the Chrome issue and see if it should be fixed in teads script.

If that isn't obvious and slow to proceed, one thing we can do in AMP is to apply this temporary work around only to teads. And we should plan to remove the hack once fixed from root cause.

lannka avatar Aug 16 '18 15:08 lannka

+1. Since this is something that only stopped working since M66, I'd recommend finding an alternative with Chrome to avoid the side effects.

jasti avatar Aug 16 '18 15:08 jasti

After further test, I've discover the root cause. Our video node is not in the same frame as the sound button. Even if it's a friendly iframe without src (for CSS / JS isolation purpose), the issue comes from here. If the sound button and the video node is on the same frame, we are able to activate the sound, without the attribute allow="autoplay" on the main xdomain iframe

strange behavior ... so we will do the modification on our side to avoid any side effect

RonanDrouglazet avatar Aug 16 '18 17:08 RonanDrouglazet

@RonanDrouglazet that's aligned with my findings as well https://bugs.chromium.org/p/chromium/issues/detail?id=845817#c22

aghassemi avatar Aug 16 '18 17:08 aghassemi

@RonanDrouglazet that's great. I'm closing the issue for now. Let me know if you have further problem.

lannka avatar Aug 16 '18 20:08 lannka