Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impeller] Ensure that missing color attachment 0u does not cause crash in embedder API #43705

Merged
merged 2 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions impeller/entity/entity_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ bool EntityPass::Render(ContentContext& renderer,
const RenderTarget& render_target) const {
auto root_render_target = render_target;

if (root_render_target.GetColorAttachments().empty()) {
if (root_render_target.GetColorAttachments().find(0u) ==
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linux embedder API was sending a bad value through here, so the map wasn't empty. It doesn't matter that its empty though, it matters that 0u exists because that is what we use below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth extracting a named constant for this to avoid the magic number.

root_render_target.GetColorAttachments().end()) {
VALIDATION_LOG << "The root RenderTarget must have a color attachment.";
return false;
}
Expand Down Expand Up @@ -341,7 +342,7 @@ bool EntityPass::Render(ContentContext& renderer,

// The safety check for fetching this color attachment is at the beginning of
// this method.
auto color0 = root_render_target.GetColorAttachments().find(0)->second;
auto color0 = root_render_target.GetColorAttachments().find(0u)->second;

// If a root stencil was provided by the caller, then verify that it has a
// configuration which can be used to render this pass.
Expand Down
1 change: 0 additions & 1 deletion shell/gpu/gpu_surface_gl_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ std::unique_ptr<SurfaceFrame> GPUSurfaceGLImpeller::AcquireFrame(
GLFrameInfo frame_info = {static_cast<uint32_t>(size.width()),
static_cast<uint32_t>(size.height())};
const GLFBOInfo fbo_info = delegate_->GLContextFBO(frame_info);

auto surface = impeller::SurfaceGLES::WrapFBO(
impeller_context_, // context
swap_callback, // swap_callback
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/embedder/embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ MakeRenderTargetFromBackingStoreImpeller(

impeller::RenderTarget render_target_desc;

render_target_desc.SetColorAttachment(color0, framebuffer->target);
render_target_desc.SetColorAttachment(color0, 0u);
render_target_desc.SetStencilAttachment(stencil0);

return std::make_unique<flutter::EmbedderRenderTargetImpeller>(
Expand Down