gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Cover Block: User can't play background video on devices in low power mode

Open bhdd opened this issue 2 years ago • 16 comments

Description

When using a background video in a cover block, devices that are in "low power mode" will not autoplay the video. The browser adds a play button over the video in this case, but the user is unable to click or tap that play button. Those events are impacted by the overlay functionality of the cover block -- they are caught by the .wp-block-cover__background span and not passed to the button added to the .wp-block-cover__video-background video element.

Step-by-step reproduction instructions

  1. On iPhone, go to settings / battery, and enable "low power mode".
  2. Open browser (Safari or Chrome)
  3. Visit site with background video in cover block
  4. The video will not be playing, but you should see a play button overlaid on the video. Clicking on that play button will not work.

Screenshots, screen recording, code snippet

IMG_3233

Environment info

WordPress 6.6.1 iPhone 14 Pro (iOS 17.6)

Please confirm that you have searched existing issues in the repo.

  • [X] Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • [X] Yes

bhdd avatar Jul 31 '24 22:07 bhdd

I'm interested to solve this issue, I was able to find couple of solutions to this problem as well But I'm not sure how can I actually replicate this 'Low power mode on iPhone' issue on Mac ( chrome or safari ), any suggestions ? Thanks in advance 🙇

Rishit30G avatar Aug 01 '24 13:08 Rishit30G

@Rishit30G Try these:

  • https://developer.apple.com/documentation/safari-developer-tools/inspecting-ios
  • https://developer.chrome.com/blog/debugging-chrome-on-ios

bhdd avatar Aug 01 '24 16:08 bhdd

If i remember well you can install XCode on Mac and then launch a sub tool called Simulator, which allows you to launch a iOS device emulation. With that you will have an iPhone and also ability to trigger "Low power mode". Not tested.

tresorama avatar Aug 01 '24 19:08 tresorama

Thanks @tresorama and @bhdd 🙇 I was able to see where the exact issue is, there is a Shadow Content (User Agent) that gets embedded to <video/> tag as soon as the Low Power Mode is triggered, this brings the play button over the video:

image

To avoid this we can maybe try using this:

video::-webkit-media-controls {
    display: none !important;
}

Rishit30G avatar Aug 05 '24 16:08 Rishit30G

@Rishit30G I would hope that the intended fix would be to allow the user to play the video, rather than hiding the play button entirely and preventing playback. I suspect it will probably take some Javascript to pass the touch/click events through to the lower video layer.

bhdd avatar Aug 07 '24 16:08 bhdd

Yes @bhdd, my bad! You are right, this will set the display of the buttons to none but might not guarantee that the video will autoplay or not Yes, that could be a possible solution 👍 Replicating it on local WordPress setup with all the low power mode is little daunting, lmk if there is a solution to it

Rishit30G avatar Aug 07 '24 17:08 Rishit30G

My understanding, after doing more reading, is that user agent shadow DOM elements aren't accessible via Javascript. Given that it's the browser adding the play button based on detection of low-power mode, I suspect that it won't be possible to get the coordinates of the play button (in the shadow DOM) and pass the touch/click events from the top layer to the lower video layer. The layer order can't be adjusted given the nature of the elements on each, so I can't think of a path to a solution at this time.

bhdd avatar Aug 09 '24 00:08 bhdd

Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

github-actions[bot] avatar Sep 09 '24 00:09 github-actions[bot]

I can reproduce the issue with Browser Stack using IOS 17 in low power mode. As mentioned by @bhdd we can't play the video due to span tag blocking the click events.

It can be fixed by adding pointer-events: none; to the span.

https://github.com/WordPress/gutenberg/blob/bdb16796eb85051b9d5d7b00fcb773973642a5e7/packages/block-library/src/cover/style.scss#L49-L58

However, if the Cover Block contains inner elements, they can still block clicks if positioned exactly over the video buttons. And I don't think it's a good idea to apply pointer-events: none; to .wp-block-cover__inner-container.

karthikeya-io avatar Mar 27 '25 11:03 karthikeya-io

If user use low power mode and the video tag in html has auto play true the auto play is not respected . At least this what I remember , in this case js is needed to trigger the play method of the video dom element

tresorama avatar Mar 27 '25 15:03 tresorama

Looked into an old project where I resolved this... When iOS blocks the auto play of the video , the video dom element trigger a "suspend" event.

You can listen to it and do video play (hoping the browser allows you to do it). In case not , the rationale is "only user can intentionally play a video" so a play button is necessary.

tresorama avatar Mar 27 '25 15:03 tresorama

Thanks, @\tresorama , for the details. The pointer-events: none on the overlay at least allows the user to play the video if it's not auto-played. Using JS to auto-play is a good idea, as it would avoid cases like a cover block with inner elements, which can also prevent clicks. I will check on it."

karthikeya-io avatar Mar 28 '25 07:03 karthikeya-io

Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

github-actions[bot] avatar May 28 '25 00:05 github-actions[bot]

== Reproduction Report This report validates that the issue can be reproduced.

=== Environment

  • OS: Android 16
  • Web Server: Nginx
  • PHP: 7.4.29
  • WordPress: 6.0-RC1-53341-src
  • Browser: Chrome
  • Theme: Twenty Twenty-Four
  • Active Plugins:
    • Gutenberg 13.2.0
    • WordPress Beta Tester 3.2.1

=== Actual Results

  • ❌ Error condition didn't occur. - will test again

=== Additional Notes

  • Video played fine with and without ultra low power mode

=== Supplemental Artifacts Add Inline: Image

Successfulsebunya avatar Jul 14 '25 14:07 Successfulsebunya

Bug Report

Description

When in low power mode (iOS), the background video in a cover block won't play.

Environment

  • iOS: 17.6.1
  • Safari: 17.6.1
  • WordPress: 6.8.2

Steps to Reproduce

  1. On iPhone, enable Low Power Mode (Settings -> Battery -> Low Power Mode or Control Centre -> Low Power Mode).
  2. Open Safari and visit a WordPress site with a cover block using a background video (sunrisemovement.org used for testing).
  3. Observe the browser shows a play button overlay on the video because autoplay is blocked.
  4. Try to click or tap the play button.
  5. 🐞 The tap does not work and video cannot be played.
  6. Turn off the Low Power Mode.
  7. Refresh the site and the video will autoplay as expected.

Expected Results

  1. ✅ When tapping the play button overlay on the video, the video should play.

Actual Results

  1. ❌ Tapping the play button overlay does nothing and the video cannot be played.

Supplemental Artifacts

Example screen recording:

https://github.com/user-attachments/assets/ac0b24d2-0183-498e-ac58-82e3b00a5df5

BugReportOnWeb avatar Jul 21 '25 15:07 BugReportOnWeb

@Mamaduka since you added the Needs Testing tag and it seems we have a confirmed reproduction here, we can move this from it to Needs Dev.

SirLouen avatar Jul 21 '25 16:07 SirLouen