amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Low power mode causes story videos to not play

Open propbuster opened this issue 8 years ago • 11 comments

With Low Power mode enabled (on iPhone6s) video does not play correctly. it either doesn't play at all, or it seems to play it really fast on tap the next page, before the next page is rendered.

@newmuis

propbuster avatar Jan 10 '18 23:01 propbuster

My first guess is that the videos that don't play are because might be throwing MEDIA_ERR_DECODE. If they do, then MediaPool (#12604) is a step in the right direction for fixing this, as we can detect this when filling the pool and just lower the cap. iOS already limits to 16 videos even in the regular (non-low-power) case, so it would make sense to me to limit to fewer than that in the low battery case.

This is all speculation; I'll debug and see if I can find out what's happening.

newmuis avatar Jan 11 '18 16:01 newmuis

Nope, my guess was off target. Turns out iOS 11+ just doesn't autoplay videos in low power mode, and there's nothing you can do about it. Android Chrome doesn't autoplay videos served from http hosts.

After #12604 goes in, we should change it to also bless all media in the MediaPool on navigation (currently, we only bless on unmute)

newmuis avatar Jan 11 '18 18:01 newmuis

We could not reproduce the fast video playback. I'm not sure if there's anything we could do about it anyway, especially if it's a decoding issue.

I will leave this open to track blessing media on navigation.

newmuis avatar Jan 17 '18 23:01 newmuis

There are two problems we're seeing currently:

  1. Media on the first page the user is on does not play. There is nothing that we can do about this directly. When the device is in low-power mode, media playback requires a user gesture. We will need to introduce a new user experience that explicitly asks the user to perform a user gesture in the case that we detect that playback has failed.

  2. Media on subsequent pages do not play. We currently only bless media on unmute; we removed blessing on navigation for performance. @gmajoulet now that bless performs better and we also have the ability to defer expensive tasks until after the navigation has taken place, do you think we could bless in a low-priority task at the end of switchTo_?

newmuis avatar Nov 20 '18 16:11 newmuis

Edit: please disregard this comment. Our bless operation was not working because it was not running in the same frame as a user interaction.

I've been playing with this today, and even if blessAll performance as a low-priority task at the end of the page navigation code is fine, it doesn't fix the bug... Our current bless operation unmutes and mutes back the media elements. I updated it to also play and then pause back the media, hoping it'd work as a "play bless", but... the video still doesn't play after a auto-advance :(

I couldn't find any way to autoplay a video without a user interaction while on iOS low energy mode.

I uploaded my test demo here

To summarize:

  • Videos won't play on the first page
  • Videos can play if user taps to navigate to the next page
  • Videos won't play if auto-advance

The good thing is that the play promise is rejected with a NotAllowedError, allowing us to display a message to play the video, like @newmuis just suggested in (1). However, I believe we should think about making the experience similar for all the pages with video(s): if we know some pages won't play, then maybe we should consider requiring that user interaction on all the pages, even if navigation was triggered by a user tap gesture.

gmajoulet avatar Nov 20 '18 22:11 gmajoulet

@gmajoulet, out of curiosity, does the bless with a play() call fix the bug if done in the first step of the navigation?

newmuis avatar Nov 20 '18 22:11 newmuis

Wow, you're right, moving the bless in the first step of the navigation does work. Even with the BlessTask we have right now, without the play().

gmajoulet avatar Nov 20 '18 23:11 gmajoulet

Okay. My theory is that the fact that the latter steps of switchTo_ are deferred is throwing it off, i.e. the browser doesn't think that code is being executed in response to a user gesture.

newmuis avatar Nov 20 '18 23:11 newmuis

@gmajoulet found that putting the bless in the critical path is too slow, so we can try to attempt this by trying to resolve point (1) from my comment above, ensuring that we bless all videos in the pool.

We need to verify that blessing with a play() call will actually allow autoplay videos on auto-advance pages.

newmuis avatar Nov 21 '18 18:11 newmuis

Blessing with mediaEl.muted = true; mediaEl.muted = false is actually enough to autoplay videos on auto advance in this context. (please disregard my previous message, I'll edit it to make this thread less confusing)

gmajoulet avatar Nov 21 '18 18:11 gmajoulet

This also applies to Google Chrome's Data Saver mode.

newmuis avatar Nov 29 '18 13:11 newmuis