diff --git a/shell/gpu/gpu_surface_metal_impeller.mm b/shell/gpu/gpu_surface_metal_impeller.mm index c9c020fd1717b..509383130b109 100644 --- a/shell/gpu/gpu_surface_metal_impeller.mm +++ b/shell/gpu/gpu_surface_metal_impeller.mm @@ -150,6 +150,12 @@ auto surface = impeller::SurfaceMTL::MakeFromMetalLayerDrawable(renderer->GetContext(), drawable, clip_rect); + // The surface may be null if we failed to allocate the onscreen render target + // due to running out of memory. + if (!surface) { + return false; + } + if (clip_rect && clip_rect->IsEmpty()) { return surface->Present(); }