Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Fix high FPS screen flicker of Platform Views when using ImageReaderPlatformViewRenderTarget #46724

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

johnmccutchan
Copy link
Contributor

The root bug (b/300627634) was that we were holding onto HardwareBuffers after the owning Image was closed. This CL refactors the C++ code to properly hold a reference to the Image until it is safe to dispose of.

This CL also refactors the Impeller GL and Skia GL code paths to share more code.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie or stuartmorgan on the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

It would be nice to have a way to unit test this, especially if that is possible without mocking everything out. Barring that, if there were a way to simulate the conditions that gave fairly reliable dropped contents that we could run as an integration test...

LGTM

AHardwareBuffer* HardwareBufferExternalTexture::GetLatestHardwareBuffer() {
// Implementing flutter::ContextListener.
void HardwareBufferExternalTexture::OnGrContextDestroyed() {
FML_LOG(ERROR) << "HardwareBufferExternalTexture::OnGrContextDestroyed";
Copy link
Member

Choose a reason for hiding this comment

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

nit: debugging log?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 37 to 38
HardwareBufferExternalTextureGL::~HardwareBufferExternalTextureGL() {}

Copy link
Member

Choose a reason for hiding this comment

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

nit: can this be = default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@johnmccutchan
Copy link
Contributor Author

It would be nice to have a way to unit test this, especially if that is possible without mocking everything out. Barring that, if there were a way to simulate the conditions that gave fairly reliable dropped contents that we could run as an integration test...

LGTM

I don't think we can write a test against the dropped frames, extremely difficult to reproduce as it is entirely timing dependent.

Once the dust settles I plan on expanding golden image tests for Android platform views.

…latformViewRenderTarget

The root bug was that we were holding onto HardwareBuffers after the owning
Image was closed. This CL refactors the C++ code to properly hold a reference
to the Image until it is safe to dispose of.

This CL also refactors the Impeller GL and Skia GL code paths to share more
code.
@johnmccutchan johnmccutchan merged commit bdeb534 into flutter:main Oct 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 10, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Oct 10, 2023
…136292)

flutter/engine@702f366...bdeb534

2023-10-10 john@johnmccutchan.com Fix high FPS screen flicker of Platform Views when using ImageReaderPlatformViewRenderTarget (flutter/engine#46724)
2023-10-10 matanlurey@users.noreply.github.com Prepare to move new folders into `third_party/` by adding a `.gitignore`. (flutter/engine#46729)
2023-10-10 godofredoc@google.com Use x86 machines for ios builds. (flutter/engine#46726)
2023-10-10 chinmaygarde@google.com Remove workaround for older versions of MSVC. (flutter/engine#46689)
2023-10-10 skia-flutter-autoroll@skia.org Roll Skia from 475286f0f6f1 to 06145491fd17 (1 revision) (flutter/engine#46728)
2023-10-10 jonahwilliams@google.com [Impeller] Implement framebuffer fetch support for OpenGLES. (flutter/engine#46585)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jsimmons@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
harryterkelsen pushed a commit that referenced this pull request Oct 23, 2023
…latformViewRenderTarget (#46724)

The root bug (b/300627634) was that we were holding onto HardwareBuffers
after the owning Image was closed. This CL refactors the C++ code to
properly hold a reference to the Image until it is safe to dispose of.

This CL also refactors the Impeller GL and Skia GL code paths to share
more code.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants