ampproject / amphtml

The AMP web component framework.
https://amp.dev
Apache License 2.0
14.89k stars 3.89k forks source link

amp-video-docking causes a CLS on floating/docking #33586

Open zetagame opened 3 years ago

zetagame commented 3 years ago

What's the issue?

When testing with several video players (including amp-video and amp-youtube) amp-video-docking incurs a CLS and increases the score in Web Vitals by ~.026 on float and ~.015 on docking.

How do we reproduce the issue?

https://jsbin.com/sudacim/edit?html,output

  1. Select the player you wish to test.
  2. Press play
  3. Scroll until it floats, docks.
  4. Check the console

What browsers are affected?

Tested on Chrome as it pertains to Web Vitals

Which AMP version is affected?

0.1

alanorozco commented 3 years ago

Investigating.

If I turn on Rendering > Layout Shift Regions on devtools, the reported regions are quite distant from the video's position. This is likely from the docking actions alternating position: static, absolute and fixed.

https://user-images.githubusercontent.com/254946/113368232-17546280-9313-11eb-82a2-d41919a24b6e.mp4

alanorozco commented 3 years ago

Still investigating but some good news.

I've tried this in the Canary version of Chrome (91), and some changes in reporting have alleviated this problem.

The CLS event count went down from three to just one.

I suspect that the remaining shift is caused by switching from position: fixed to absolute when undocking. This makes sense if the previous three events were caused by position changes:

https://user-images.githubusercontent.com/254946/113602805-ef594d80-95f7-11eb-9c17-d380970fe915.mp4