← Back to context

Comment by pcwalton

6 years ago

I highly suspect that the issue is that Windows video playback can only use scanout compositing if there is nothing on top of the video. Scanout compositing is significantly more energy-efficient than standard framebuffer compositing because it avoids a memory copy each frame.

This ultimately comes down to hardware limitations. GPUs are limited as to what they can compose during scanout, because of memory bandwidth limits. Each plane that you can alpha-blend together at scanout time multiplies the amount of memory fetches per dot you have to do. On today's high-DPI displays, the bandwidth going out to the display is very high to begin with, so you can't afford to multiply that by much. That is why putting something on top of a video is tricky: you're adding another layer to be alpha-blended on top, increasing your memory bandwidth by 50% over the two layers you already have (RGB for the background plus YUV for the video). The user's GPU may or may not support that--as I recall, prior to Skylake, Intel GPUs only had two hardware planes, for instance.

I'm not surprised that Microsoft just used "are there any DOM elements over the video?" as a quick heuristic to determine whether scanout compositing can be used. Remember that there is always a tradeoff between heuristics and performance. At the limit you could scan every pixel of each layer to see whether all of them are transparent and cull the layer if so, but that would be very expensive. You need heuristics of some kind to get good performance, and I can't blame Microsoft for using the DOM for that.

> You need heuristics of some kind to get good performance, and I can't blame Microsoft for using the DOM for that.

which, again, that's fine, but mayyyyybe they were a little lax in checking performance on nearly any other popular video site on the web to see if that heuristic is a good one?

Or maybe changing page layout in an extremely common way wasn't an effort to undermine a hyper specific benchmark?

  • How many sites put invisible DOM elements over the videos?

    Remember, if you put visible DOM elements on top of the videos, then you lose scanout compositing no matter what.

    • > How many sites put invisible DOM elements over the videos?

      A lot of them? Vimeo, for instance, has a number of opacity: 0 and hidden divs over the video. Twitch has at least a couple of opacity: 0 divs on top.

      Maybe we're interpreting the phrase

      > hidden empty div over YouTube videos

      differently? That's the structure I assume they were talking about.

      2 replies →

    • There are visible elements on top of YouTube videos.

      That's what this "empty div" is for if that's the one I think it is. It is the container for things like branding and annotations.