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

[Impeller] Release a texture during Playground teardown #45832

Merged

Conversation

matanlurey
Copy link
Contributor

@matanlurey matanlurey commented Sep 14, 2023

Closes flutter/flutter#134678.

Partial work towards flutter/flutter#133708, flutter/flutter#133506.

This gets us closer to being able to run aiks_unittests with validations enabled, removing a VMA allocation error:

Before

Note: Google Test filter = Play/AiksTest.ReleasesTextureOnTeardown/Vulkan
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from Play/AiksTest
[ RUN      ] Play/AiksTest.ReleasesTextureOnTeardown/Vulkan
[INFO:capabilities_vk.cc(50)] Vulkan validations are enabled.
[FATAL:third_party/vulkan_memory_allocator/include/vk_mem_alloc.h(6179)] Check failed: (false && "Unfreed dedicated allocations found!"). Vulkan Memory Allocator Failure!

After

Note: Google Test filter = Play/AiksTest.ReleasesTextureOnTeardown/Vulkan
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from Play/AiksTest
[ RUN      ] Play/AiksTest.ReleasesTextureOnTeardown/Vulkan
[INFO:capabilities_vk.cc(50)] Vulkan validations are enabled.
[       OK ] Play/AiksTest.ReleasesTextureOnTeardown/Vulkan (1192 ms)
[----------] 1 test from Play/AiksTest (1192 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (1192 ms total)
[  PASSED  ] 1 test.

Added a test that will catch regressions.

// Underlying issue: <https://github.com/flutter/flutter/issues/134678>.
//
// The tear-down code is not running in the right order; it's torn down after
// we shut down the |ContextVK|, which means that the Vulkan allocator still
Copy link
Member

Choose a reason for hiding this comment

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

Its not that VMA still has a reference, its that when shutting down VMA we have retained dedicated allocations without freeing them

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.

@@ -3362,5 +3362,31 @@ TEST_P(AiksTest, CaptureInactivatedByDefault) {
ASSERT_FALSE(GetContext()->capture.IsActive());
}

// Regression test for https://github.com/flutter/flutter/issues/134678.
TEST_P(AiksTest, ReleasesTextureOnTeardown) {
Copy link
Member

Choose a reason for hiding this comment

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

Does this actually work on a "real" backend - does that matter? In theory if we've submitted a frame the fence waiter should keep the weak texture alive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does (a) this test work on a real backend, (b) do we avoid the underlying issue on a real backend?

(a) No, at least I've not tried it. I just want to make sure we can enable validation layers for aiks_unittests.
(flutter/flutter#133506)

(b) This probably is, as you've mentioned, show a weakness in the fence waiter that needs to be fixed as well.

Copy link
Member

Choose a reason for hiding this comment

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

LGTM, though we may need to adjust this further

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, wait - your point is if the fence waiter was working properly we wouldn't need this :)?

Copy link
Member

Choose a reason for hiding this comment

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

I think that if the fence waiter was working this may not be released by the end of the scope

Copy link
Member

Choose a reason for hiding this comment

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

it would only be after Shutdown. So maybe manually call contextvk->Shutdown() and then check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to clarify, this test does fail (100% of the time) before our patch as-is.

Do you think I should add another test or tweak this tests behavior?

Copy link
Member

Choose a reason for hiding this comment

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

I think test may be flaky unless you call context->Shutdown before checking the weak_ptr status

Copy link
Member

Choose a reason for hiding this comment

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

or, will become flaky after we fix fence waiter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, added a comment and ran 1000 times to ensure it's fine right now.

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.

LGTM

@matanlurey matanlurey added autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Sep 14, 2023
@matanlurey matanlurey force-pushed the impeller-vk-fence-waiter-termination branch from 57f5def to 2849afb Compare September 14, 2023 17:49
@matanlurey matanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 14, 2023
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

Changes reported for pull request #45832 at sha 2849afb

@auto-submit auto-submit bot merged commit 741d6e3 into flutter:main Sep 14, 2023
29 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 14, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Sep 14, 2023
…134769)

flutter/engine@035932d...3a3a280

2023-09-14 skia-flutter-autoroll@skia.org Roll Skia from 9bdf01416042 to 0f003d5748bc (4 revisions) (flutter/engine#45841)
2023-09-14 jacksongardner@google.com Declare the js context as nullable in skwasm surface callback (flutter/engine#45810)
2023-09-14 matanlurey@users.noreply.github.com [Impeller] Release a texture during Playground teardown (flutter/engine#45832)
2023-09-14 skia-flutter-autoroll@skia.org Roll Skia from 87025d1e162c to 9bdf01416042 (1 revision) (flutter/engine#45835)
2023-09-14 matanlurey@users.noreply.github.com Make `fml::ScopedCleanupClosure` `std::move`-able and add unit tests. (flutter/engine#45772)

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 bdero@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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Mairramer pushed a commit to Mairramer/flutter that referenced this pull request Oct 10, 2023
…lutter#134769)

flutter/engine@035932d...3a3a280

2023-09-14 skia-flutter-autoroll@skia.org Roll Skia from 9bdf01416042 to 0f003d5748bc (4 revisions) (flutter/engine#45841)
2023-09-14 jacksongardner@google.com Declare the js context as nullable in skwasm surface callback (flutter/engine#45810)
2023-09-14 matanlurey@users.noreply.github.com [Impeller] Release a texture during Playground teardown (flutter/engine#45832)
2023-09-14 skia-flutter-autoroll@skia.org Roll Skia from 87025d1e162c to 9bdf01416042 (1 revision) (flutter/engine#45835)
2023-09-14 matanlurey@users.noreply.github.com Make `fml::ScopedCleanupClosure` `std::move`-able and add unit tests. (flutter/engine#45772)

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 bdero@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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

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
Closes flutter/flutter#134678.

Partial work towards flutter/flutter#133708, flutter/flutter#133506.

This gets us closer to being able to run `aiks_unittests` with validations enabled, removing a VMA allocation error:

## Before

```txt
Note: Google Test filter = Play/AiksTest.ReleasesTextureOnTeardown/Vulkan
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from Play/AiksTest
[ RUN      ] Play/AiksTest.ReleasesTextureOnTeardown/Vulkan
[INFO:capabilities_vk.cc(50)] Vulkan validations are enabled.
[FATAL:third_party/vulkan_memory_allocator/include/vk_mem_alloc.h(6179)] Check failed: (false && "Unfreed dedicated allocations found!"). Vulkan Memory Allocator Failure!
```

## After

```txt
Note: Google Test filter = Play/AiksTest.ReleasesTextureOnTeardown/Vulkan
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from Play/AiksTest
[ RUN      ] Play/AiksTest.ReleasesTextureOnTeardown/Vulkan
[INFO:capabilities_vk.cc(50)] Vulkan validations are enabled.
[       OK ] Play/AiksTest.ReleasesTextureOnTeardown/Vulkan (1192 ms)
[----------] 1 test from Play/AiksTest (1192 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (1192 ms total)
[  PASSED  ] 1 test.
```

---

Added a test that will catch regressions.
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 e: impeller will affect goldens
Projects
No open projects
Archived in project
2 participants