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

Conversation

@blasten
Copy link

@blasten blasten commented Jun 5, 2020

Description

Runs the rasterizer on the platform thread if a platform view is in the current frame.

Related Issues

flutter/flutter#58292

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.


class MessageLoop {
public:
FML_EMBEDDER_ONLY
Copy link
Author

Choose a reason for hiding this comment

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

can this cause issues @chinmaygarde ?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is to prevent the accidental use of fml::MessageLoop::GetCurrent() in a unit-test. The current message loop cannot be accessed from the cross platform engine components because message loop management is an embedder concern. But, if you want to use in in a unit-test, you can #define FML_USED_ON_EMBEDDER in your unit-test before including any other files.

But, you shouldn't have to do this in the first place. Instead of using raw threads, use fml::Thread which have their own task runners that you can access without resorting to removing this sanity check.

Copy link
Contributor

Choose a reason for hiding this comment

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

TL;DR: Please don't remove this and use fml::Thread with the GetTaskRunner call on that thread to access task runners.


class MessageLoop {
public:
FML_EMBEDDER_ONLY
Copy link
Contributor

Choose a reason for hiding this comment

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

This is to prevent the accidental use of fml::MessageLoop::GetCurrent() in a unit-test. The current message loop cannot be accessed from the cross platform engine components because message loop management is an embedder concern. But, if you want to use in in a unit-test, you can #define FML_USED_ON_EMBEDDER in your unit-test before including any other files.

But, you shouldn't have to do this in the first place. Instead of using raw threads, use fml::Thread which have their own task runners that you can access without resorting to removing this sanity check.


class MessageLoop {
public:
FML_EMBEDDER_ONLY
Copy link
Contributor

Choose a reason for hiding this comment

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

TL;DR: Please don't remove this and use fml::Thread with the GetTaskRunner call on that thread to access task runners.

@blasten blasten requested a review from chinmaygarde June 5, 2020 19:03
TRACE_EVENT0("flutter", "AndroidExternalViewEmbedder::SubmitFrame");
if (should_run_rasterizer_on_platform_thread_) {
// Don't submit the current frame if the frame will be resubmitted.
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the result actually used? Or it is the same with iOS (the result is not used) If the result is not used, and we don't do anything based on a false result, I'd suggest to keep it as true.

Copy link
Author

Choose a reason for hiding this comment

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

Done. SubmitFrame should return void. I will change that in a separate PR.

// |ExternalViewEmbedder|
PostPrerollResult AndroidExternalViewEmbedder::PostPrerollAction(
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
bool has_platform_views = composition_order_.size() > 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does composition_order_ represent the platform views in this frame or existing platform views.
For example, if you have 2 platform views on the screen, and this frame is going to remove both platform views making a total of 0 platform views on the screen after this frame. Is the size of composition_order_ 0 or 2?
If it is 0, then we still need the threads to be merged. Because there are still 2 platform views on the screen and this frame is going to remove then, the removing process need to happen on the platform thread.

Copy link
Contributor

Choose a reason for hiding this comment

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

Although having a kDefaultMergedLeaseDuration > 1 might already cover this case tho. Your call. On iOS, we sticked on the safe side to have the threads kept merged until we are sure there are no platform views both the previous frame and the current frame.

Copy link
Author

Choose a reason for hiding this comment

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

I like that kDefaultMergedLeaseDuration > 1 covers this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool. maybe we can put a comment on it.

Copy link
Author

Choose a reason for hiding this comment

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

Done in fb0f53b.

@blasten blasten requested a review from cyanglaz June 9, 2020 04:59
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

@blasten blasten merged commit 17aead3 into flutter:master Jun 9, 2020
@blasten blasten deleted the android_thread_merge branch June 9, 2020 21:52
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 10, 2020
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