Skip to content

Impeller reports a smaller paint_region than Skia for the same frame; layer is still fully cleared #192973

Open

Description

@jwinarske

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

  1. 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.
  2. Leave the region accurate and stop clearing what is not in it. Bigger change; the clear is what makes the target deterministic.
  3. Document that paint_region is 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

  1. added
    in triage
    engine
    e: embedder
    c: rendering
    e: impeller
    team-engine
    and removed
    in triage
    on Sep 18, 2026
  2. gaaclarke commented on Sep 21, 2026

    @gaaclarke
    Member

    @jwinarske can you provide a reproduction please?

  3. added
    P2
    triaged-engine
    on Sep 21, 2026
  4. jwinarske commented on Sep 21, 2026

    @jwinarske
    ContributorAuthor

    Reproduction against master aae258a564233b5b3eda8d63e13566e177b7b2f2, as two tests in embedder_gl_unittests.cc. They render one frame of the existing render_gradient_on_non_root_backing_store fixture and report the root layer's paint_region. The only difference between them is --enable-impeller; same fixture, same surface, same compositor, same render target type.

    [ RUN      ] EmbedderTest.PaintRegionRootLayerSkia
    #192973 root paint_region (Skia): rects=1 [0,0,800,600]
    [       OK ] EmbedderTest.PaintRegionRootLayerSkia (185 ms)
    
    [ RUN      ] EmbedderTest.PaintRegionRootLayerImpeller
    Using the Impeller rendering backend (OpenGLES).
    #192973 root paint_region (Impeller): rects=1 [10,10,800,600]
    [       OK ] EmbedderTest.PaintRegionRootLayerImpeller (209 ms)
    
    [  PASSED  ] 2 tests.
    

    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 PaintLayerTreeSkia records the frame-start clear into the slice and PaintLayerTreeImpeller does not. Still the case on this revision:

    // PaintLayerTreeSkia
        canvas()->Clear(DlColor::kTransparent());
      }
      layer_tree.Paint(*this, ignore_raster_cache);
    
    // PaintLayerTreeImpeller
      if (canvas()) {
        if (clip_rect) { canvas()->ClipRect(clip_rect.value()); }
      }
      layer_tree.Paint(*this, ignore_raster_cache);

    EmbedderExternalView::Render clears 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 only paint_region keeps 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2c: renderingcustomer: toyotae: embeddere: impellerengineteam-enginetriaged-engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions