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] reland: switch Pipeline to use raw ptr instead of shared ptr for recorded references. #57086

Merged
merged 11 commits into from
Dec 10, 2024

Conversation

jonahwilliams
Copy link
Member

Prev: #57015

There is a unit test that is clearing out the pipeline storage, manually null out captured PipelineRef.

@jonahwilliams jonahwilliams marked this pull request as ready for review December 10, 2024 15:33
@@ -1751,6 +1753,7 @@ TEST_P(EntityTest, RuntimeEffect) {

ASSERT_TRUE(runtime_stage->IsDirty());
expect_dirty = true;
first_pipeline = PipelineRef{nullptr};
Copy link
Member Author

Choose a reason for hiding this comment

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

Changing this test to null out the pipeline. The test is clearing out the shader cache which invalidates this ptr.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if this is the right fix. The reason being that the failure was Expected: (first_pipeline) != (pass.GetCommands().back().pipeline). It's an assertion that doesn't even look into the validity of the pointer, it just performs a computation on the address. Were you able to validate locally this removed the failure?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure exactly what happens here. Right now we're holding onto a raw_ptr. The structure that keeps the shared_ptr alive is being cleared out. So that raw_ptr is no longer valid.

I don't know why they do match but only sometimes.

Copy link
Member

Choose a reason for hiding this comment

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

I'm wary of changing this test to fix the failure. I'm afraid we may be masking a bug. My intuition on this assertion is that the render pass's commands should point to a different pipeline if the runtime stage has been updated. That makes sense. This change just removes that assertion by just asserting that the pipeline is not null. So this probably removes the flakiness but not the bug it's demonstrating.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't really think that this is a meaningful assertion

Copy link
Member

Choose a reason for hiding this comment

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

Chatted offline: The most likely reason that sometimes this fails is that we get (un)lucky and we're creating a new pipeline that has the same address. Jonah's right that this is not a good assertion. I'd say that usually not equals assertions are kind of trash anyways. We should have some sort of positive assertion about the rebuild having happened.

Copy link
Member

Choose a reason for hiding this comment

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

I can't come up with a better alternative to this assert. This is fine for me. Although I think it's better to just delete that EXPECT_NE or replace it with EXPECT_NE(nullptr, pass.GetCommands().back().pipeline.get()); instead of fiddling with state.

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

Glad we came up with a probable explanation, thanks.

@@ -1751,6 +1753,7 @@ TEST_P(EntityTest, RuntimeEffect) {

ASSERT_TRUE(runtime_stage->IsDirty());
expect_dirty = true;
first_pipeline = PipelineRef{nullptr};
Copy link
Member

Choose a reason for hiding this comment

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

I can't come up with a better alternative to this assert. This is fine for me. Although I think it's better to just delete that EXPECT_NE or replace it with EXPECT_NE(nullptr, pass.GetCommands().back().pipeline.get()); instead of fiddling with state.

@@ -1724,13 +1724,9 @@ TEST_P(EntityTest, RuntimeEffect) {
entity.SetContents(contents);
bool result = contents->Render(context, entity, pass);

if (expect_dirty) {
EXPECT_NE(first_pipeline, pass.GetCommands().back().pipeline);
first_pipeline = pass.GetCommands().back().pipeline;
Copy link
Member

Choose a reason for hiding this comment

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

You're going to still want this so the else condition passes. I'd remove that resetting of first_pipeline you added too.

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 10, 2024
@auto-submit auto-submit bot merged commit bfda83b into flutter:main Dec 10, 2024
33 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 10, 2024
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Dec 11, 2024
…160052)

flutter/engine@23fc43d...3a641b6

2024-12-10 [email protected] Clean up key embedder responder
tests (flutter/engine#57054)
2024-12-10 [email protected] [Impeller] reland: switch Pipeline
to use raw ptr instead of shared ptr for recorded references.
(flutter/engine#57086)
2024-12-10 [email protected] Roll Skia from bd7d952398d5 to
d541f1aa0c9b (3 revisions) (flutter/engine#57098)

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 [email protected],[email protected] 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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants