+Khushal, who worked in images-on-compositor thread in the past. +pdr as TL for paint/compositing.I don't think this has been tried.Do you have data on savings, and how common this is across the web? Also, allocating a new composited layer is by no means free, there is plenty of overhead for it. I wonder if instead we can just optimize the code for damage within an existing layer.

On Fri, Aug 27, 2021 at 10:50 AM Chris Harrelson <chri...@chromium.org> wrote:+Khushal, who worked in images-on-compositor thread in the past. +pdr as TL for paint/compositing.I don't think this has been tried.Do you have data on savings, and how common this is across the web? Also, allocating a new composited layer is by no means free, there is plenty of overhead for it. I wonder if instead we can just optimize the code for damage within an existing layer.I'm not sure what you mean when you ask how common this is. Are you asking about the prevalence of animated gifs?
If you run Chromium with
--show-surface-damage-rects and go to this page you'll see the damage rect encloses the animated gif:On a Mac, running with QuartzDebug shows a very large update region getting pushed to the screen (see the attached QuartzDebugScreenUpdates.mov). We're consuming a lot more power than we need to as a result. The issue is magnified if the page contains two or more animated gifs.I found another instance of what I thought was this same problem but I don't think there are any animated gifs involved(?). If you go to https://www.bookbaby.com/myaccount/login.aspx you'll see the damage rect encloses the insertion point. However in the attached screen recording the insertion point flashing is causing a similarly large screen update as in the animated gif case. Is this a separate problem?

--
To unsubscribe from this group and stop receiving emails from it, send an email to graphics-dev...@chromium.org.

I think it's because my browser windows size is different. So the Mac overlay borders look different from Jayson's screen shot. If I compare the borders in --show-composited-layer-borders and in --show-mac-overlay-borders, they match each other on my Mac.On Fri, Aug 27, 2021 at 4:08 PM Jayson Adams <shr...@chromium.org> wrote:I originally thought this might be a Mac problem but then I ran Chromium with
--show-composited-layer-borders, which I assume is cross-platform. I thought I was getting the same rects as the Mac overlay borders but on closer inspection they don't match up.
On Fri, Aug 27, 2021 at 3:44 PM Maggie Chen <mag...@google.com> wrote:In Viz surface aggregation, damages from all surfaces are merged into one "root damage rect ". This is the final rect for the Renderer to update and display. Command line switch --show-aggregated-damage will shows the damage rect after surface aggregation. If we run this page on Windows, the only part that is updated should be the gif rect.I know this Viz root damage rect is not used on Mac, I just tried that gif again on Mac with command line --show-mac-overlay-borders. Below is what it shows. It updates more than the root damage rect.
On Fri, Aug 27, 2021 at 5:04 PM Maggie Chen <mag...@google.com> wrote:I think it's because my browser windows size is different. So the Mac overlay borders look different from Jayson's screen shot. If I compare the borders in --show-composited-layer-borders and in --show-mac-overlay-borders, they match each other on my Mac.On Fri, Aug 27, 2021 at 4:08 PM Jayson Adams <shr...@chromium.org> wrote:I originally thought this might be a Mac problem but then I ran Chromium with
--show-composited-layer-borders, which I assume is cross-platform. I thought I was getting the same rects as the Mac overlay borders but on closer inspection they don't match up.--show-composited-layer-borders is cross-platform. The only compositing differences between Mac and non-Mac is in the aggregate step of the pipeline.On Fri, Aug 27, 2021 at 3:44 PM Maggie Chen <mag...@google.com> wrote:In Viz surface aggregation, damages from all surfaces are merged into one "root damage rect ". This is the final rect for the Renderer to update and display. Command line switch --show-aggregated-damage will shows the damage rect after surface aggregation. If we run this page on Windows, the only part that is updated should be the gif rect.I know this Viz root damage rect is not used on Mac, I just tried that gif again on Mac with command line --show-mac-overlay-borders. Below is what it shows. It updates more than the root damage rect.Exactly - this seems like something we can try to improve on Mac. (I know it's tricky due to the use of Core Animations, but still. :) )
For testing, add the following style to the <img> tag to cause it to get a cc::Layer:style="will-change: transform;"It is relatively easy (<1 week) to automatically promote large animated images with CompositeAfterPaint (launching M94). A potential worry is the memory cost (see: gpu memory ablation study). Want to collaborate on a finch trial in Q4?
On Fri, Aug 27, 2021 at 8:52 PM Christopher Cameron <ccam...@google.com> wrote:My suspicion is that the biggest gain will be from the more precise damage during swap. The area of pixels one changes on the screen has a substantial impact on power on macOS. I suspect this would have a more limited impact on other platforms (e.g, I hear that on Windows, moving non-overlay videos to their own layers didn't produce much gain).Is there a quick-and-hacky way to force animated gifs to have their own layers? With that we could just measure if this makes a difference and then further invest or discard it accordingly. (In fact, just making layers for <img> elements of a size greater than some constant would be enough to get power numbers).RE partial swap: Mac doesn't have partial swap -- individual CALayers can only take full damage. (And I think this is as it should be -- if we just want to damage the rectangle on the screen for an image, and we requested a feature to do this, the response would rightly be "why aren't you making that image its own CALayer?").
On Sat, Aug 28, 2021 at 12:15 PM Philip Rogers <p...@chromium.org> wrote:For testing, add the following style to the <img> tag to cause it to get a cc::Layer:style="will-change: transform;"It is relatively easy (<1 week) to automatically promote large animated images with CompositeAfterPaint (launching M94). A potential worry is the memory cost (see: gpu memory ablation study). Want to collaborate on a finch trial in Q4?Could you clarify the CAP dependency here? I assumed all we'll need is to make the presence of an animated image a compositing trigger. Add the trigger here and query whether the LayoutObject is an animated image similar to the logic here. It should automatically hit the directly composited image path and associated optimizations as well, correct?
On Mon, Aug 30, 2021 at 9:18 AM Khushal Sagar <khusha...@chromium.org> wrote:On Sat, Aug 28, 2021 at 12:15 PM Philip Rogers <p...@chromium.org> wrote:For testing, add the following style to the <img> tag to cause it to get a cc::Layer:style="will-change: transform;"It is relatively easy (<1 week) to automatically promote large animated images with CompositeAfterPaint (launching M94). A potential worry is the memory cost (see: gpu memory ablation study). Want to collaborate on a finch trial in Q4?Could you clarify the CAP dependency here? I assumed all we'll need is to make the presence of an animated image a compositing trigger. Add the trigger here and query whether the LayoutObject is an animated image similar to the logic here. It should automatically hit the directly composited image path and associated optimizations as well, correct?Pre-CompositeAfterPaint, compositing changes paint order. This is known as the "fundamental compositing bug" (crbug.com/370604) and it prevents us from compositing arbitrary content. Here is an example that would break if we composited animated images pre-CompositeAfterPaint:<!doctype html>
<img src="https://upload.wikimedia.org/wikipedia/commons/1/1d/Newtons_cradle.gif">
<div style="width: 100px; height: 100px; background: lightblue; display: inline-block; margin-left: -50px;">This should be on top.</div>CompositeAfterPaint fixes this issue by running the overlap test after painting which lets us composite the content that overlaps the animating image, preserving paint order.
On Mon, Aug 30, 2021 at 12:33 PM Philip Rogers <p...@chromium.org> wrote:On Mon, Aug 30, 2021 at 9:18 AM Khushal Sagar <khusha...@chromium.org> wrote:On Sat, Aug 28, 2021 at 12:15 PM Philip Rogers <p...@chromium.org> wrote:For testing, add the following style to the <img> tag to cause it to get a cc::Layer:style="will-change: transform;"It is relatively easy (<1 week) to automatically promote large animated images with CompositeAfterPaint (launching M94). A potential worry is the memory cost (see: gpu memory ablation study). Want to collaborate on a finch trial in Q4?Could you clarify the CAP dependency here? I assumed all we'll need is to make the presence of an animated image a compositing trigger. Add the trigger here and query whether the LayoutObject is an animated image similar to the logic here. It should automatically hit the directly composited image path and associated optimizations as well, correct?Pre-CompositeAfterPaint, compositing changes paint order. This is known as the "fundamental compositing bug" (crbug.com/370604) and it prevents us from compositing arbitrary content. Here is an example that would break if we composited animated images pre-CompositeAfterPaint:<!doctype html>
<img src="https://upload.wikimedia.org/wikipedia/commons/1/1d/Newtons_cradle.gif">
<div style="width: 100px; height: 100px; background: lightblue; display: inline-block; margin-left: -50px;">This should be on top.</div>CompositeAfterPaint fixes this issue by running the overlap test after painting which lets us composite the content that overlaps the animating image, preserving paint order.Thanks for clarifying. I sort of assumed that we can already layerize images because we have a "directly composited image" path. Didn't realize it was limited to images which have their own stacking context. I'm excited to hear CAP is taking away this restriction!
IMO supporting partial swap on mac if we have an API that allows partially damaging layers is a better area to optimize. Would setNeedsDisplayInRect work? It will address use-cases beyond gifs.
On Mon, Aug 30, 2021 at 10:11 AM Khushal Sagar <khusha...@chromium.org> wrote:On Mon, Aug 30, 2021 at 12:33 PM Philip Rogers <p...@chromium.org> wrote:On Mon, Aug 30, 2021 at 9:18 AM Khushal Sagar <khusha...@chromium.org> wrote:On Sat, Aug 28, 2021 at 12:15 PM Philip Rogers <p...@chromium.org> wrote:For testing, add the following style to the <img> tag to cause it to get a cc::Layer:style="will-change: transform;"It is relatively easy (<1 week) to automatically promote large animated images with CompositeAfterPaint (launching M94). A potential worry is the memory cost (see: gpu memory ablation study). Want to collaborate on a finch trial in Q4?Could you clarify the CAP dependency here? I assumed all we'll need is to make the presence of an animated image a compositing trigger. Add the trigger here and query whether the LayoutObject is an animated image similar to the logic here. It should automatically hit the directly composited image path and associated optimizations as well, correct?Pre-CompositeAfterPaint, compositing changes paint order. This is known as the "fundamental compositing bug" (crbug.com/370604) and it prevents us from compositing arbitrary content. Here is an example that would break if we composited animated images pre-CompositeAfterPaint:<!doctype html>
<img src="https://upload.wikimedia.org/wikipedia/commons/1/1d/Newtons_cradle.gif">
<div style="width: 100px; height: 100px; background: lightblue; display: inline-block; margin-left: -50px;">This should be on top.</div>CompositeAfterPaint fixes this issue by running the overlap test after painting which lets us composite the content that overlaps the animating image, preserving paint order.Thanks for clarifying. I sort of assumed that we can already layerize images because we have a "directly composited image" path. Didn't realize it was limited to images which have their own stacking context. I'm excited to hear CAP is taking away this restriction!
IMO supporting partial swap on mac if we have an API that allows partially damaging layers is a better area to optimize. Would setNeedsDisplayInRect work? It will address use-cases beyond gifs.My understanding is that that API doesn't work / help with IOSurface-backed CALayers, which is the common backing type that Chrome uses:It probably only helps with layers rendered to by Core Graphics.The longstanding issue is that CALayer updates have been "all or nothing" - back when Chrome used OpenGL to render its main CALayer, the only option was a full buffer swap for the smallest update. ccameron's work to support multiple CALayers and separate updates was the foundational change that yielded huge power savings, for example with Docs' or Gmail's blinking caret.Chris (Cameron) might know whether we've tried the experiment to use setNeedsDisplayInRect for rasterization damage.
But if we can promote GIFs to layers it could help us avoid a few redundant copies for these animations (that have been on the wishlist). It might end up being better for memory in some cases as well :- Don't raster tiles for these images. We can use the decoded image textures during viz compositing directly, that would benefit platforms beyond mac. Also avoid allocating textures for tiles.- Decode directly into GMBs to avoid a texture upload. +Chris Blume had started work on this. Should work for Mac/CrOS and maybe also Android.