amphtml: amp-ima-video: browser freezes after pre-roll ad plays
What’s the issue?
amp-ima-video
with pre-roll ads will freeze browser tab when network conditions are poor. The tab freezes right about when the regular video starts to play after the pre-roll. You can see the moment right after the pre-roll ad that the CPU climbs up to 100%:
We tried to also replicate this issue using the regular amp-video
component and could not. This appears to only occur with amp-ima-video
.
How do we reproduce the issue?
https://jsbin.com/makubutuca/1/edit?html,output
- Go to JS Bin link above
- Turn off “Auto-run JS”
- Control case - Press “Run with JS” - should see sample preroll & then video play.
Everything at this point is interactive and working as expected. - Go to network and set throttle (Slow 3g or slower)
- Press ‘Run with JS’ again
- Wait for the video to load & after pre roll plays (In most of our testing, it would take up to minute and a half to get to this point). Not able to interact with footer (or browser at all)
You can try the above steps on a regular amp-video
component in the JS Bin link below to verify that it works as expected using amp-video
:
https://jsbin.com/jefikolugo/edit?html,output
What browsers are affected?
Tested on Mac: Chrome, Safari, Firefox, Edge
Which AMP version is affected?
1907091704050
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (16 by maintainers)
Commits related to this issue
- 🐛Fixes ima-video race condition and percentage played (#24900) Fixes the race condition that causes the ima-video player to freeze with slow network connection. Also added event trigger to calculat... — committed to ampproject/amphtml by deleted user 5 years ago
- 🐛Fixes ima-video race condition and percentage played (#24900) Fixes the race condition that causes the ima-video player to freeze with slow network connection. Also added event trigger to calculat... — committed to jeffjose/amphtml by deleted user 5 years ago
- 🐛Fixes ima-video race condition and percentage played (#24900) Fixes the race condition that causes the ima-video player to freeze with slow network connection. Also added event trigger to calculat... — committed to Parsely/amphtml by deleted user 5 years ago
- 🐛Fixes ima-video race condition and percentage played (#24900) Fixes the race condition that causes the ima-video player to freeze with slow network connection. Also added event trigger to calculat... — committed to micajuine-ho/amphtml by deleted user 5 years ago
Hey @zhouyx @cvializ
Wanted to bump, hoping for any new information (especially since @torch2424 focus is shifted elsewhere). I tried and was unsuccessful in determine if PLAY and/or SECONDS_PLAYED cause the freeze.
Thank you all!
@sanchezedgar
So By using a custom network profile, 250 down, 50 up, 300ms latency I was able to reproduce the bug 👍 And yeah totally it pegs the Page / CPU after the ad is finished.
Getting the performance profile was very difficult since, the page is completely frozen. But I finally got lucky, and got a performance profile. You can download it here, and it’s a 42MB file haha! And the website I used was the ima-video amp.dev example.
For the “why” this is happening, the profile shows the following:
(anonymous) @ video-manager-impl.js:1494
points to our analytics handling code for all of our video players: https://github.com/ampproject/amphtml/blob/master/src/service/video-manager-impl.js#L1491And which you can see it constantly being called by all of the events being fired. 😢
@prateekbh and @zhouyx Suggested because the network is poor, and we are listening to the ‘playing’ event, instead of the ‘play’ event, the video must be constantly stopping and starting, thus continually firing this event over and over.
Thank you @sanchezedgar for opening this issue! Super glad you caught this, will work on a fix ASAP 😄
cc @alanorozco because this probably affects all AMP video 👍