[Impeller] add missing null check. (flutter/engine#51711)

surface can return null if we failed to allocate MSAA or depth/stencil textures.
This commit is contained in:
Jonah Williams 2024-03-27 10:55:04 -07:00 committed by GitHub
parent d93f7f3275
commit b18dfd5fa7

View File

@ -150,6 +150,12 @@ std::unique_ptr<SurfaceFrame> GPUSurfaceMetalImpeller::AcquireFrameFromCAMetalLa
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();
}