Skip to content

[Impeller] Playground tests will always run one frame#187603

Open
flar wants to merge 1 commit into
flutter:masterfrom
flar:playground-tests-always-run-one-frame
Open

[Impeller] Playground tests will always run one frame#187603
flar wants to merge 1 commit into
flutter:masterfrom
flar:playground-tests-always-run-one-frame

Conversation

@flar
Copy link
Copy Markdown
Contributor

@flar flar commented Jun 5, 2026

Currently the playground tests do not do any rendering unless they are run as part of a golden test or if the --enable_playground flag is specified. In that state they test very little except that the associated DisplayList is successfully constructed. These changes will cause them to render the initial frame, thus also testing the Impeller pipelines, even if the playground window is not requested and no goldens are being generated.

Additionally some tests were fixed:

  • Any test that tried to create an ImGui controls panel must first check if the playground window is active
  • Some tests were not successful but we never discovered this unless a developer ran them with enable_playground. (These tests are not included in the golden test generation either so that workflow also did not uncover this problem).
  • Some tests fail on FML_DCHECK checks, but the standard CI flow does not run them with DCHECKs enabled.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

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.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 5, 2026
@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Jun 5, 2026
Copy link
Copy Markdown
Contributor

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

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 refactors the Impeller playground and unit tests by removing custom ImGuiBegin wrappers and instead guarding direct ImGui::Begin calls with IsPlaygroundEnabled(). It also updates Playground::OpenPlaygroundHere to execute the render callback and flush command buffers when the playground is disabled, and transitions dl_unittests.cc to use DlTextImpeller instead of DlTextSkia. Feedback on these changes identifies a potential null pointer dereference in Playground::OpenPlaygroundHere if AcquireSurfaceFrame returns nullptr when the playground is disabled, suggesting a null check be added.

Comment on lines +218 to 225
if (!switches_.enable_playground) {
std::unique_ptr<Surface> surface = impl_->AcquireSurfaceFrame(context_);
RenderTarget render_target = surface->GetRenderTarget();
if (render_callback(render_target)) {
return impl_->GetContext()->FlushCommandBuffers();
}
return false;
}
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.

high

If AcquireSurfaceFrame fails to acquire a surface (for example, in headless environments or if the context is lost), it can return nullptr. Calling GetRenderTarget() on a nullptr will result in a null pointer dereference and crash the test. A null check should be added for surface before using it.

Suggested change
if (!switches_.enable_playground) {
std::unique_ptr<Surface> surface = impl_->AcquireSurfaceFrame(context_);
RenderTarget render_target = surface->GetRenderTarget();
if (render_callback(render_target)) {
return impl_->GetContext()->FlushCommandBuffers();
}
return false;
}
if (!switches_.enable_playground) {
std::unique_ptr<Surface> surface = impl_->AcquireSurfaceFrame(context_);
if (!surface) {
return false;
}
RenderTarget render_target = surface->GetRenderTarget();
if (render_callback(render_target)) {
return impl_->GetContext()->FlushCommandBuffers();
}
return false;
}

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

Labels

a: text input Entering text in a text field or keyboard related problems CICD Run CI/CD e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant