diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index 6a2c2ee1f189d..f80ab4a8edc1d 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -467,16 +467,19 @@ RasterStatus Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) { FireNextFrameCallbackIfPresent(); - if (surface_->GetContext()) { - TRACE_EVENT0("flutter", "PerformDeferredSkiaCleanup"); - surface_->GetContext()->performDeferredCleanup(kSkiaCleanupExpiration); - } - // Clear the render context after submitting the frame. // This ensures that the GL context is released after drawing to the // surface. + // + // The GL context must be clear before performing Gr context deferred + // cleanup. surface_->ClearRenderContext(); + if (surface_->GetContext()) { + TRACE_EVENT0("flutter", "PerformDeferredSkiaCleanup"); + surface_->GetContext()->performDeferredCleanup(kSkiaCleanupExpiration); + } + return raster_status; }