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

Conversation

@zhongwuzw
Copy link
Member

@zhongwuzw zhongwuzw commented Oct 23, 2020

Description

All Flutter assets loading(file io operations) called on UI thread, we can move them to IO thread instead. response still called on UI thread.

Related Issues

N/A

Tests

I added the following tests:

Not yet.

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.

Reviewer Checklist

Breaking Change

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

@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 on the #hackers channel in Chat.

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

@google-cla google-cla bot added the cla: yes label Oct 23, 2020
Copy link
Contributor

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

Besides the nit about RunNowOrPostTask, you can add a test for this in the shell_unittests harness where you create a shell with a custom task runner, get its engine, call UpdateAssetManager on the engine with an asset manager you give it with a custom asset provider for the test, in the asset provider, you can assert that the task runner is the same as the one you gave to the caller to create the shell.

@zhongwuzw
Copy link
Member Author

@chinmaygarde I added the test.

@zhongwuzw
Copy link
Member Author

@xster
Copy link
Member

xster commented Dec 3, 2020

@chinmaygarde looks like this PR is ready for another round

@zhongwuzw
Copy link
Member Author

zhongwuzw commented Mar 25, 2021

@chinmaygarde @xster @gaaclarke Hi, anyone can help to review? :)

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.

I reviewed the code, I'll leave it up to @chinmaygarde to decide if this is a good idea. The important thing is to add an assertion to you test.

AssetResolver::AssetResolverType type_;
};

class PlatformMessageResponseTest : public flutter::PlatformMessageResponse {
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 both of these classes could be mocked with gmock which would be less code to maintain.

Comment on lines +330 to +332
SendEnginePlatformMessage(shell.get(), std::move(platform_message));

DestroyShell(std::move(shell), std::move(task_runners));
Copy link
Member

Choose a reason for hiding this comment

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

This test has no assertion.

Comment on lines +526 to +529
fml::RefPtr<PlatformMessageResponse> response = message->response();
if (!response) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this early out should happen on the UI thread since it should be low cost. What line of this code is the heaviest? GetAsMapping? I'd only defer to the IO thread if we are going to hit that since posting to another thread incurs extra cost.

@Hixie
Copy link
Contributor

Hixie commented Oct 19, 2021

Closing this in favour of #29016.

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.

5 participants