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

Fix npe during skia dispatch of drawAtlas #55497

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jonahwilliams
Copy link
Member

Colors are optionally provided, so make sure to null check the array.

Fixes flutter/flutter#155783

sk_colors.reserve(count);
for (int i = 0; i < count; ++i) {
sk_colors.push_back(colors[i].argb());
}
}
canvas_->drawAtlas(skia_atlas.get(), xform, ToSkRects(tex), sk_colors.data(),
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately .data() is not guaranteed to return nullptr for empty std::vector. We need to explicitly send it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

damn you STL

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

lgtm, just a suggestion and a question

canvas_->drawAtlas(skia_atlas.get(), xform, ToSkRects(tex), sk_colors.data(),
count, ToSk(mode), ToSk(sampling), ToSkRect(cullRect),
canvas_->drawAtlas(skia_atlas.get(), xform, ToSkRects(tex),
colors == nullptr ? nullptr : sk_colors.data(), count,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
colors == nullptr ? nullptr : sk_colors.data(), count,
sk_colors.empty() ? nullptr : sk_colors.data(), count,

This is a more direct condition =)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


final Image resultImage = await recorder.endRecording().toImage(1, 1);
final ByteData? data = await resultImage.toByteData();
if (data == null) {
Copy link
Member

Choose a reason for hiding this comment

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

why not use an expect?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I guess this is from old litetest days.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 27, 2024
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 27, 2024
Copy link
Contributor

auto-submit bot commented Sep 27, 2024

auto label is removed for flutter/engine/55497, due to - The status or check suite Mac mac_host_engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

@Solido
Copy link

Solido commented Sep 28, 2024

You were fast to correct the ticket, thanks!!
When can we expect the correction into dev or master please.
Not blocking it's just that it difficult to estimate real app perfs without drawAtlas.
Best regards.

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 28, 2024
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 28, 2024
Copy link
Contributor

auto-submit bot commented Sep 28, 2024

auto label is removed for flutter/engine/55497, due to - The status or check suite Mac mac_host_engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MacOS] App crashes when using canvas.drawAtlas() on beta & master
3 participants