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

Add ability to disable the raster thread merger #20800

Merged
merged 16 commits into from
Aug 29, 2020

Conversation

blasten
Copy link

@blasten blasten commented Aug 26, 2020

Description

Reworks dynamic thread merging, so there isn't need to merge threads on Shell::OnPlatformViewDestroyed(). https://github.com/flutter/engine/pull/19919/files

Related Issues

flutter/flutter#57067

Tests

I added the following tests: Unit tests

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the contributor guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the C++, Objective-C, Java style guides for the engine.
  • I read the tree hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation.
  • All existing and new tests are passing.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read handling breaking changes.

@blasten blasten force-pushed the raster_thread_merger_disable branch from e318fe0 to 7481a1f Compare August 26, 2020 22:23
@blasten blasten force-pushed the raster_thread_merger_disable branch from b658d77 to 1fa8467 Compare August 26, 2020 23:07
@@ -597,201 +597,6 @@ TEST_F(ShellTest,
DestroyShell(std::move(shell));
}

TEST_F(ShellTest, OnPlatformViewDestroyAfterMergingThreads) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, this test should pass with this change.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

DestroyShell(std::move(shell));
}

TEST_F(ShellTest, OnPlatformViewDestroyWhenThreadsAreMerging) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, this test should still pass

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@blasten blasten marked this pull request as ready for review August 27, 2020 04:44
@auto-assign auto-assign bot requested a review from GaryQian August 27, 2020 04:44
@blasten blasten requested review from iskakaushik and removed request for GaryQian August 27, 2020 04:44
@blasten blasten requested a review from cyanglaz August 27, 2020 05:37
@blasten
Copy link
Author

blasten commented Aug 27, 2020

I have verified that this patch fixes the reason #20722 was reverted in #20745.

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

LGTM modulo nits. This is great! Looks like a better and simpler solution than the "always merging threads" solution.
@iskakaushik

const auto raster_thread_merger_ =
fml::MakeRefCounted<fml::RasterThreadMerger>(qid1, qid2);

raster_thread_merger_->Disable();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add some assert after this line to ensure the raster_thread_merge is truely disabled? So we know enable worked.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

//
// This incorrect assumption can lead to dead lock.
// See `should_post_raster_task` for more.
rasterizer_->DisableThreadMergerIfNeeded();
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move this right before should_post_raster_task, so it's clear that should_post_raster_task is checked right after disabling thread merger.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

//
// This incorrect assumption can lead to dead lock.
// See `should_post_raster_task` for more.
rasterizer_->DisableThreadMergerIfNeeded();
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move this right before should_post_raster_task, so it's clear that should_post_raster_task is checked right after disabling thread merger.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

LGTM! This is great! Thanks.

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.

3 participants