Skip to content

[CP-stable][Impeller] Ensure that the TextureGLES destructor cleans up all objects that it holds including the sync fence#187403

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.44-candidate.0from
jason-simmons:cp_187216_stable
Jun 17, 2026
Merged

[CP-stable][Impeller] Ensure that the TextureGLES destructor cleans up all objects that it holds including the sync fence#187403
auto-submit[bot] merged 1 commit into
flutter:flutter-3.44-candidate.0from
jason-simmons:cp_187216_stable

Conversation

@jason-simmons

Copy link
Copy Markdown
Member

TextureGLES owns a texture and may be given ownership of cached FBO and sync fence objects. Use UniqueHandleGLES to manage the lifecycle of these objects.

Fixes #186899

Issue Link:

#186899

Impact Description:

This can cause a resource leak in some scenarios (particularly animated images).

Changelog Description:

The PR ensures that a GLES fence sync object held by a texture will be deleted if the texture is destructed before the fence was used.

Workaround:

No workaround.

Risk:

What is the risk level of this cherry-pick?

  • Low
  • Medium
  • High

Test Coverage:

Are you confident that your fix is well-tested by automated tests?

  • Yes
  • No

Validation Steps:

Run the sample app in #186899 (comment) using Impeller/GLES.

Look at the count of file descriptors in /proc/[pid]/fd for the app process. Without the fix, the count will increase quickly. With the fix, the count will be stable.

The exact behavior of the resource leak may vary across devices, and some devices may not show it as a leak of file descriptors. I was able to reproduce the file descriptor leak on a Pixel 3 with an Adreno GPU.

…p all objects that it holds including the sync fence

TextureGLES owns a texture and may be given ownership of cached FBO and
sync fence objects. Use UniqueHandleGLES to manage the lifecycle of
these objects.

Fixes flutter#186899
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 1, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@jason-simmons jason-simmons requested a review from gaaclarke June 1, 2026 21:16
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Jun 1, 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 refactors TextureGLES to manage its GLES handles (handle_, fence_, and cached_fbo_) using UniqueHandleGLES instead of raw HandleGLES, enabling automated cleanup and the removal of the explicit TextureGLES destructor. It also adds a unit test to verify that the texture destructor deletes its associated fence. The review feedback recommends marking the move constructor and move assignment operator of UniqueHandleGLES as noexcept and refactoring them to use member initializer lists instead of std::swap to optimize performance and adhere to the Google C++ Style Guide.

@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, tested and fixes problems on stable

@jason-simmons jason-simmons added the cp: review Cherry-picks in the review queue label Jun 11, 2026
@LongCatIsLooong LongCatIsLooong added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 17, 2026
@auto-submit auto-submit Bot merged commit 407abe9 into flutter:flutter-3.44-candidate.0 Jun 17, 2026
176 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD cp: review Cherry-picks in the review queue 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.

3 participants