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

Conversation

@cyanglaz
Copy link
Contributor

@cyanglaz cyanglaz commented Jan 11, 2022

The thread merging logic had some race condition in DiscardLayerTreeOnResize test with caused some flakiness. I couldn't reproduce the flakiness with more than 10k runs locally so I decided to remove the thread merging logic in the test. The thread merging logic was unnecessary for the test anyway.

Fixes flutter/flutter#95751

Also remove unnecessary thread merging logic in DiscardResubmittedLayerTreeOnResize test.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@ColdPaleLight
Copy link
Member

Hi, @cyanglaz , It seems that the test DiscardResubmittedLayerTreeOnResize also needs to tweak

@cyanglaz
Copy link
Contributor Author

@ColdPaleLight Is DiscardResubmittedLayerTreeOnResize also failing like this? Is there an issue or log that I can refer to?

@ColdPaleLight
Copy link
Member

ColdPaleLight commented Jan 12, 2022

@ColdPaleLight Is DiscardResubmittedLayerTreeOnResize also failing like this? Is there an issue or log that I can refer to?

DiscardResubmittedLayerTreeOnResize is copied from DiscardLayerTreeOnResize and then modified, so they both have a lot of the same logic. I'm not sure if it have the same issue though.

@cyanglaz
Copy link
Contributor Author

@ColdPaleLight done, please review it to see if the updated test still makes sense.

@ColdPaleLight
Copy link
Member

I’m sorry, but I think updated test DiscardResubmittedLayerTreeOnResize is not quite right. This test was introduced in this PR #28474. It ensures that the discard_callback is passed to Rasterizer::Draw as a param when the frame needs to be resubmitted.

switch (consume_result) {
case PipelineConsumeResult::MoreAvailable: {
delegate_.GetTaskRunners().GetRasterTaskRunner()->PostTask(
fml::MakeCopyable(
[weak_this = weak_factory_.GetWeakPtr(), pipeline,
resubmit_recorder = std::move(resubmit_recorder),
discard_callback = std::move(discard_callback)]() mutable {
if (weak_this) {
weak_this->Draw(std::move(resubmit_recorder), pipeline,
std::move(discard_callback));
}
}));
break;

I tried removing the Thread merging logic at DiscardResubmittedLayerTreeOnResize today, but I didn't succeed.

@cyanglaz
Copy link
Contributor Author

cyanglaz commented Jan 14, 2022

@ColdPaleLight Could you elaborate what needs to be updated for test. It seems to me the current version of the test in this PR makes sure the frame is dropped when the original_size is used, which was the same as the previous version, just without thread merging.

@ColdPaleLight
Copy link
Member

@ColdPaleLight Could you elaborate what needs to be updated for test. It seems to me the current version of the test in this PR makes sure the frame is dropped when the original_size is used, which was the same as the previous version, just without thread merging.

Sorry, I didn't express clearly. This test is to ensure that the discard_callback here is passed to draw when consume_result is PipelineConsumeResult::MoreAvailable

weak_this->Draw(std::move(resubmit_recorder), pipeline,
std::move(discard_callback));

So if someone accidentally makes the following change, the test will fail. You can make the following changes and see if the new version of the test fails, thank you.

--- a/shell/common/rasterizer.cc
+++ b/shell/common/rasterizer.cc
@@ -220,8 +220,7 @@ RasterStatus Rasterizer::Draw(
                resubmit_recorder = std::move(resubmit_recorder),
                discard_callback = std::move(discard_callback)]() mutable {
                 if (weak_this) {
-                  weak_this->Draw(std::move(resubmit_recorder), pipeline,
-                                  std::move(discard_callback));
+                  weak_this->Draw(std::move(resubmit_recorder), pipeline);
                 }
               }));
       break;

@cyanglaz
Copy link
Contributor Author

@ColdPaleLight Ah I see. I think in the resubmit case, thread merging is required ATM because raster_thread_merger_ is required for re-sbumit. See: https://github.com/flutter/engine/blob/main/flow/compositor_context.cc#L116-L123

The test looks fine and we didn't have any flake report so I'd like to keep it there for now.

If in the future, we have a case where we need to resubmit the tree in a embedder that doesn't require thread merging, then it makes sense to create a new similar test but without thread merging.

Does it make sense? I'll remove the change in DiscardResubmittedLayerTreeOnResize if you agree.

@ColdPaleLight
Copy link
Member

@ColdPaleLight Ah I see. I think in the resubmit case, thread merging is required ATM because raster_thread_merger_ is required for re-sbumit. See: https://github.com/flutter/engine/blob/main/flow/compositor_context.cc#L116-L123

The test looks fine and we didn't have any flake report so I'd like to keep it there for now.

If in the future, we have a case where we need to resubmit the tree in a embedder that doesn't require thread merging, then it makes sense to create a new similar test but without thread merging.

Does it make sense? I'll remove the change in DiscardResubmittedLayerTreeOnResize if you agree.

Yeah, It sounds good to me :-)

@cyanglaz cyanglaz force-pushed the discard_layer_tree_test branch from 8cf0bc9 to c051107 Compare January 20, 2022 19:00
Copy link
Member

@ColdPaleLight ColdPaleLight left a comment

Choose a reason for hiding this comment

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

LGTM, nice!

@cyanglaz
Copy link
Contributor Author

@chinmaygarde Friendly ping :)

@ColdPaleLight ColdPaleLight added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jan 29, 2022
@fluttergithubbot fluttergithubbot merged commit fccb9b6 into flutter:main Jan 29, 2022
@cyanglaz cyanglaz deleted the discard_layer_tree_test branch February 7, 2022 18:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ShellTest.DiscardLayerTreeOnResize is flaky on presubmits.

4 participants