How do I redraw SVG elements on invalidation from the compositor?

39 views
Skip to first unread message

Ishan Jain

unread,
Sep 19, 2025, 11:02:14 AM (7 days ago) Sep 19
to Chromium-dev
Hello everyone, 

I have a custom build of chromium. In this version, the images may not be available when chromium runs the GPU commands to draw them. In this situation, after we have the decoded images ready to be drawn, we do a call to `LayerTreeHostImplClient->SetNeedsImplSideInvalidation(true)` in cc to redraw all the images on the page.

This works perfectly for <img> tags but I am running into problems with SVGs that have bitmaps embedded.  

The SVGImage class can be shared by multiple resources and on call to `SetNeedsImplSideInvalidation`, it calls DrawInternal on the SVGImage class but not on the SVG root/container elements. So, on invalidation there is nothing sending a GPU command to redraw the bitmap. This results in broken SVGs where you can see all the vector shapes but not the bitmaps embedded. 

The only way I have found so far is to change the dimensions of the SVG HTML element by 1 pixel which triggers a re-layout and a re-render of the whole element. By the time this re-layout happens the image is decoded/available to be drawn and every thing works. The problem with this approach is, there is no good way to trigger this from the SVGImage class and that's the only one that is notified on an invalidation from cc.


Is there a way to trigger a full re-render/invalidation of the SVG element from cc ? 


This communication (including any attachments) is intended for the sole use of the intended recipient and may contain confidential, non-public, and/or privileged material. Use, distribution, or reproduction of this communication by unintended recipients is not authorized. If you received this communication in error, please immediately notify the sender and then delete all copies of this communication from your system.

Ishan Jain

unread,
Sep 22, 2025, 12:02:18 PM (4 days ago) Sep 22
to Chromium-dev, Ishan Jain
Updating where I am at right now. 


1. The `SetNeedsImplSideInvalidation` calls triggers `UpdateLIfecycle` on `WebFrameWidgetImpl`. 
2. There are multiple lifecycle stages like Layout, PrePaint, Paint. The `SetNeedsImplSideInvalidation` always runs the `Paint` stage if they are no layout changes.
3.  SVG element is a `LocalFrame` and child of the root HTML element. The `UpdateLifecycle` call triggered by `SetNeedsImplSideInvalidation` terminates because `RunPrePaintLifecyclePhase` returns false. 
Reply all
Reply to author
Forward
0 new messages