Skip to content

[Impeller] Fix the text benchmark on Impeller backends - #192677

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
artemkulyk:pr/fix-impeller-text-benchmark
Sep 21, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
artemkulyk:pr/fix-impeller-text-benchmark

Conversation

@artemkulyk

@artemkulyk artemkulyk commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

The DrawTextBlob benchmark always built a DlTextSkia, whose text frame is null on Impeller backends. The dispatcher FML_CHECKs that frame and aborts.

This is a local macOS/iOS benchmark crash. The text benchmark is compiled into display_list_benchmarks via DISPLAY_LIST_BENCHMARK_ALL_OPS (primitive_rendering_benchmarks omits text benchmarks); the Impeller Metal variants are built only when ENABLE_METAL_BENCHMARKS is set. Linux CI does not run those backends.

Build a DlTextImpeller when the surface provider targets Impeller. The backend check is outside the timed loop.

Fixes #192671

test-exempt: benchmark-only crash fix

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Made with Cursor

The DrawTextBlob benchmark always built a DlTextSkia, whose text frame is
null for Impeller backends, crashing the dispatcher. Build a
DlTextImpeller when the surface provider targets Impeller.

Benchmark-only change; no production code is modified.
test-exempt: benchmark-only crash fix.
@github-actions github-actions Bot added the engine flutter/engine related. See also e: labels. label Sep 12, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the display list benchmarks to support Impeller rendering under the IMPELLER_SUPPORTS_RENDERING flag, conditionally drawing text blobs using DlTextImpeller when targeting Impeller. Feedback suggests optimizing performance within the benchmark loop by using std::move(blob) to avoid unnecessary atomic reference count overhead when creating the text blobs.

Comment on lines +1560 to 1566
#ifdef IMPELLER_SUPPORTS_RENDERING
if (targets_impeller) {
builder.DrawText(DlTextImpeller::MakeFromBlob(blob), 50.0f, 50.0f, paint);
continue;
}
#endif // IMPELLER_SUPPORTS_RENDERING
builder.DrawText(DlTextSkia::Make(blob), 50.0f, 50.0f, paint);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since blob is a sk_sp<SkTextBlob> and is not used after being passed to DrawText, we can use std::move(blob) to avoid unnecessary atomic reference count increments and decrements. This is especially beneficial in a benchmark context to minimize overhead.

#ifdef IMPELLER_SUPPORTS_RENDERING
    if (targets_impeller) {
      builder.DrawText(DlTextImpeller::MakeFromBlob(std::move(blob)), 50.0f, 50.0f, paint);
      continue;
    }
#endif  // IMPELLER_SUPPORTS_RENDERING
    builder.DrawText(DlTextSkia::Make(std::move(blob)), 50.0f, 50.0f, paint|

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

MakeFromBlob and DlTextSkia::Make both take const sk_sp&, so std::move at this call site does not transfer ownership. MakeFromBlob does not retain the blob, and DlTextSkia still copies into blob_. This construction is also outside the timed RenderDisplayList loop, so it would not affect the measured numbers.

@gaaclarke gaaclarke added the P2 Important issues not at the top of the work list label Sep 14, 2026
@gaaclarke
gaaclarke requested a review from andywolff September 15, 2026 20:40
@artemkulyk
artemkulyk marked this pull request as draft September 16, 2026 06:19
@artemkulyk
artemkulyk marked this pull request as ready for review September 17, 2026 06:35

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces Impeller-specific rendering logic to the display list benchmarks by adding conditional compilation guards and updating the benchmark loop to utilize DlTextImpeller when the surface provider targets Impeller. A review comment was provided suggesting a null check for the surface_provider before invoking its methods to prevent potential null pointer dereferences.

Comment on lines +1553 to +1555
#ifdef IMPELLER_SUPPORTS_RENDERING
const bool targets_impeller = surface_provider->TargetsImpeller();
#endif // IMPELLER_SUPPORTS_RENDERING

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To prevent a potential null pointer dereference, it is safer to check if surface_provider is non-null before calling TargetsImpeller() on it.

Suggested change
#ifdef IMPELLER_SUPPORTS_RENDERING
const bool targets_impeller = surface_provider->TargetsImpeller();
#endif // IMPELLER_SUPPORTS_RENDERING
#ifdef IMPELLER_SUPPORTS_RENDERING
const bool targets_impeller = surface_provider && surface_provider->TargetsImpeller();
#endif // IMPELLER_SUPPORTS_RENDERING

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No change needed. Create() returns nullptr only when the backend is disabled at build time, and the same defines gate benchmark registration, so surface_provider is always non-null here. It is also dereferenced unconditionally a few lines above (InitializeSurface), like every other benchmark in this file.

@andywolff andywolff added the CICD Run CI/CD label Sep 17, 2026

@andywolff andywolff left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Passed on my local mac. LGTM with one nit: Please update the PR description where primitive_rendering_benchmarks is referenced. BM_DrawTextBlob is compiled under display_list_benchmarks via DISPLAY_LIST_BENCHMARK_ALL_OPS, whereas primitive_rendering_benchmarks omits text benchmarks.

@artemkulyk

Copy link
Copy Markdown
Contributor Author

Updated the description. Thanks for the review!

@andywolff andywolff added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 21, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 21, 2026
@auto-submit

auto-submit Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/192677, because This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.

  • Merge guidelines: A PR needs at least one approved review if the author is already part of flutter-hackers or two member reviews if the author is not a member of flutter-hackers before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. P2 Important issues not at the top of the work list

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DrawTextBlob benchmark crashes on Impeller backends

3 participants