Repository navigation
Description
Summary
Under Impeller a layer's paint_region covers only what was drawn into it. Under Skia it covers the whole frame, because Skia records the frame-start clear into the root slice and Impeller does not.
The layer is cleared either way. So an embedder that trusts paint_region and copies only those rects keeps whatever the previous frame left outside them.
Evidence
embedder_gl_unittests.cc, CanRenderGradientWithCompositorOnNonRootLayer, same fixture and same frame, root layer:
Skia (Vulkan): rects=1 [0,0,800,600]
Impeller (Vulkan): rects=1 [10,10,800,600]
The one picture on that layer is a red box drawn at offset (10, 10), so Impeller's region is the accurate description of what was painted. The test asserts the full-frame rect, which only holds because of the clear.
Cause
flow/compositor_context.cc:
void CompositorContext::ScopedFrame::PaintLayerTreeSkia(...) {
...
canvas()->Clear(DlColor::kTransparent()); // <- lands in the slice, so the
} // region covers the frame
layer_tree.Paint(*this, ignore_raster_cache);
}
void CompositorContext::ScopedFrame::PaintLayerTreeImpeller(...) {
... // no clear recorded
layer_tree.Paint(*this, ignore_raster_cache);
}EmbedderExternalView::Render clears the render target for both renderers (dl_canvas.Clear(DlColor::kTransparent()) when clear_surface), so the pixels outside the reported region really are overwritten — the region just doesn't say so.
Consequence
Partial-update embedders. FlutterBackingStorePresentInfo.paint_region is documented as the region that changed, and that is what makes damage-tracked present (FB_DAMAGE_CLIPS, eglSwapBuffersWithDamage, a dirty-rect blit to a scanout buffer) correct. Under Impeller the region under-reports, so a stale frame's content survives in the gap. A full-surface embedder never notices.
Found while implementing Vulkan backing stores for Impeller (#187525). Not caused by that work — it reproduces on the GL and Vulkan compositor paths alike, and predates it.
Options
- Record the clear on the Impeller path too, so the region matches the pixels that change. Costs the region's precision, which is the thing partial repaint wants.
- Leave the region accurate and stop clearing what is not in it. Bigger change; the clear is what makes the target deterministic.
- Document that
paint_regionis renderer-dependent and that a partial-update embedder must union it with the previous frame's. Cheapest, and the worst answer for anyone doing damage tracking.
Either of the first two is better than the third. Whichever way it goes, the two renderers should agree — right now the same scene reports two different regions depending on a flag the embedder does not set.
Activity
Run the shared Vulkan embedder tests under Impeller as well as Skia
Run the shared Vulkan embedder tests under Impeller as well as Skia
Run the shared Vulkan embedder tests under Impeller as well as Skia
Run the shared Vulkan embedder tests under Impeller as well as Skia
Run the shared Vulkan embedder tests under Impeller as well as Skia
gaaclarke commentedon Sep 21, 2026
@jwinarske can you provide a reproduction please?
jwinarske commentedon Sep 21, 2026
Reproduction against master
aae258a564233b5b3eda8d63e13566e177b7b2f2, as two tests inembedder_gl_unittests.cc. They render one frame of the existingrender_gradient_on_non_root_backing_storefixture and report the root layer'spaint_region. The only difference between them is--enable-impeller; same fixture, same surface, same compositor, same render target type.Neither test asserts which region is correct -- that is the question the issue asks. They only record what each renderer reports, so the two can be compared directly.
The scene draws a single red box at (10, 10), so Impeller's region is the accurate description of what was painted -- Skia's covers the frame because
PaintLayerTreeSkiarecords the frame-start clear into the slice andPaintLayerTreeImpellerdoes not. Still the case on this revision:EmbedderExternalView::Renderclears the target for both renderers, so the pixels outside Impeller's reported region really do change -- the region just doesn't say so. That is what breaks damage-tracked present: an embedder that copies onlypaint_regionkeeps the previous frame's content in the gap.The test body is a macro only because the GL test fixture caches one context per test (
Check failed: !gl_surface_if one test launches two engines), so the two arms have to be separate test cases.Happy to turn this into a PR if you want it as a permanent regression test -- tell me which of the three options in the issue you'd prefer and I'll shape the assertion to match.
Run the shared Vulkan embedder tests under Impeller as well as Skia
Run the shared Vulkan embedder tests under Impeller as well as Skia
Run the shared Vulkan embedder tests under Impeller as well as Skia
Run the shared Vulkan embedder tests under Impeller as well as Skia (f…