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

Conversation

@nathanrogersgoogle
Copy link
Contributor

Add a new pipeline observer interface, specified via an optionally set
|std::function| on |flutter::Settings|. The callback is called by
|Pipeline|, and provides information similar to what is implied by the
existing pipeline flow events. The difference between the flow events
and the new interface, is that this information is available at runtime
even when tracing isn't enabled, and can be sent to a region of code
that is able to call platform specific APIs. For example, one might
want to provide this information to a system metrics API.

PT-154
CF-776

Add a new pipeline observer interface, specified via an optionally set
|std::function| on |flutter::Settings|.  The callback is called by
|Pipeline|, and provides information similar to what is implied by the
existing pipeline flow events.  The difference between the flow events
and the new interface, is that this information is available at runtime
even when tracing isn't enabled, and can be sent to a region of code
that is able to call platform specific APIs.  For example, one might
want to provide this information to a system metrics API.

PT-154
CF-776
Copy link
Member

@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.

The overall direction seems sound. There are just a few nits and the issue with the abort not being fired. I dont see a unit-test for the pipeline. I'd appreciate if you added one to the "shell_unittests" target. But, if you dont want to set that up, file and issue for that and I'll wire it up. Thanks.

#include "flutter/shell/common/animator.h"

#include "flutter/fml/trace_event.h"
#include "flutter/shell/common/pipeline.h"
Copy link
Member

Choose a reason for hiding this comment

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

How are you able to include this file here? This is in the common library which the shell depends on. This would make it a circular dependency. Did you run GN with the --check option?


enum class PipelineItemStateChange {
// Indicates that a new pipeline item has started.
kBegin,
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion, maybe call this kProducerBegin, kProducerEnd, kConsumerBegin, kConsumerEnd/Abort. Since this is a single producer single consumer queue, I believe that would make the enum values clearer. As you noted, kStep should not happen more than once. So let's just make the names clearer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I think this Pipeline is not UI thread or GPU thread specific, as it can be used in other threads/TaskRunners, right? If so, maybe only mention UI and GPU thread as an example, and explain the high-level concept only using producer/consumer.

// Called when pipeline items change states. See
// |Settings::pipeline_state_observer| for further details.
using PipelineStateObserver =
std::function<void(intptr_t pipeline_id,
Copy link
Member

Choose a reason for hiding this comment

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

A shell is guaranteed to have just one frame pipeline. Specifying the ID here is redundant as that information can just be associated in the std::function captures in the embedder.

// Ensure the queue mutex is not held as that would be a pessimization.
available_.Signal();

if (pipeline_state_observer_) {
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 the resource is always valid. You can probably just assert that here. I case of an aborted item, I believe that item is just dropped on the floor. So I don't actually think you will ever get an abort.

Copy link
Member

Choose a reason for hiding this comment

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

If you add these state observer fire events right next to the calls to TRACE_EVENT_ASYNC BEGIN, STEP and END, you should get the right behavior.

@chinmaygarde
Copy link
Member

Hmm, the presubmits caught the circular include. Maybe you are running this in the Fuchsia buildroot. I would have expected GN checks to be turned on there as well. In any case, if you move the typedef to the common header, it should fix the issue.

@chinmaygarde
Copy link
Member

cc @liyuqian

Copy link
Contributor

@liyuqian liyuqian left a comment

Choose a reason for hiding this comment

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

I think this could be useful to monitor the pipeline items in general.

FYI, I'm also working on a frame build/raster specific API so the Flutter app can get those metrics in Dart: #8983


enum class PipelineItemStateChange {
// Indicates that a new pipeline item has started.
kBegin,
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I think this Pipeline is not UI thread or GPU thread specific, as it can be used in other threads/TaskRunners, right? If so, maybe only mention UI and GPU thread as an example, and explain the high-level concept only using producer/consumer.

@cbracken
Copy link
Member

@nathanrogersgoogle checking as part of weekly PR review -- do you plan to address @chinmaygarde and @liyuqian 's comments and proceed with this PR?

@liyuqian
Copy link
Contributor

@nathanrogersgoogle and I have discussed this with my PR #8983. We concluded that #8983 could help in this use case so I'll first modify my #8983 to add the API that this needs. Nathan could probably modify this later based on #8983. I should have the updated #8983 ready today.

@cbracken
Copy link
Member

@nathanrogersgoogle looks like #8983 is merged. Do you intend to proceed with this PR?

@nathanrogersgoogle
Copy link
Contributor Author

Let me review the final version of #8983 and see if any further changes are required for my use case. Will try and get back to this by tomorrow or Wednesday.

@nathanrogersgoogle
Copy link
Contributor Author

Alright, I had a chance to look over #8983. I think in principle it has the information I'm looking for, however in practice even after setting |flutter::Settings::frame_rasterized_callback|,

// TODO(dnfield): remove once embedders have caught up.
class DummyDelegate : public Delegate {
void OnFrameRasterized(const FrameTiming&) override {}
};
is what ends up getting called (and the callback I locally set at https://fuchsia.googlesource.com/topaz/+/4586d9f55297c881557474da55b49080cab1c1b3/runtime/flutter_runner/component.cc#263 does not get called). I'll sync with Yuqian on what having the callback get called on Fuchsia looks like.

If that ends up requiring a Flutter engine patch, would you prefer me to upload that as a new patch set on this CL, or to start a new CL? I'm happy to do either.

@liyuqian
Copy link
Contributor

liyuqian commented Jun 25, 2019

@nathanrogersgoogle : I think #9484 would solve your delegate problem

@nathanrogersgoogle
Copy link
Contributor Author

@liyuqian #9484 indeed fixes the issue. Thanks!

Given that it looks like we can safely abandon this CL. Thanks everyone.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants