New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add onReportTimings and FrameRasterizedCallback API #8983
Conversation
CC @kenzieschmoll @devoncarew : please let me know if this helps DevTools or other IDE tools to plot the performance information (e.g., GPU thread frame raster time). |
I'll also try to see if we can add the C++ callback API defined in #8970 and https://fuchsia-review.googlesource.com/c/topaz/+/281255/1/runtime/flutter_runner/frame_stats.cc#42 |
Two Questions:
In the current state of determining frame timing, we use the PipelineItem flow events to signal frame start and end, but the corresponding trace events for the frame can have timestamps outside of the flow event timestamps. For example, sometimes the VSYNC event timestamp will be before the PipelineItem start flow event.
|
@kenzieschmoll : I just scheduled a meeting on Wednesday for us to discuss those questions. @nathanrogersgoogle : please check if the API added to settings.h here looks good to you Meanwhile, I'm still figuring out how to add uni test to best exercise this API in the engine repo. |
@chinmaygarde @Hixie @cbracken @nathanrogersgoogle @kenzieschmoll : since flutter/flutter#26154 has a May milestone, it would be really nice if you can start reviewing this PR soon so it can be merged before the end of May. |
@@ -58,6 +59,29 @@ void ShellTest::SetSnapshotsAndAssets(Settings& settings) { | |||
} | |||
} | |||
|
|||
void ShellTest::PlatformViewNotifyCreated(Shell* shell) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call on moving these to the fixture.
lib/stub_ui/lib/src/ui/window.dart
Outdated
@@ -35,6 +35,71 @@ typedef PlatformMessageResponseCallback = void Function(ByteData data); | |||
typedef PlatformMessageCallback = void Function( | |||
String name, ByteData data, PlatformMessageResponseCallback callback); | |||
|
|||
/// Time-related performance metrics of a frame. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs much more documentation. For example, how to get one of these, whether it makes sense to examine the data at all in debug mode, what it measures, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a little more documentation. I'll continue to add more once I come up with other topics while polishing this PR.
Can we disable all this logic in the case where the callback isn't set? |
shell/common/rasterizer.cc
Outdated
|
||
// TODO(liyuqian): in Fuchsia, the rasterization doesn't finish when | ||
// Rasterizer::DoDraw finishes. Future work is needed to adapt the timestamp | ||
// for Fuchsia. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What extra work after |Rasterizer::DoDraw| are you referring to specifically? Are you talking about the GPU work (as opposed to the CPU "GPU thread" work in Flutter)? What does the future work you mention here look like? In some Fuchsia traces I had lying around, the GPU thread's work (covered by the "GPURasterizer::Draw") does nearly end with |Rasterizer::DoDraw| (there's just a couple of microseconds after it). If I'm understanding this correctly, I'd be happy to clarify that this is just Flutter GPU thread work here, and have the burden of measuring GPU work be on Flutter runner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right that Rasterizer::DoDraw
and Rasterizer::Draw
(which adds GPURasterizer::Draw
tracing) are approximately equal. The extra work I referred was SceneUpdateContext::ExecutePaintTasks
in scene_update_context.cc. I've added this info to the code comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you all @Hixie @chinmaygarde @nathanrogersgoogle for your comments! I've updated the PR accordingly. Please check if I missed something.
lib/stub_ui/lib/src/ui/window.dart
Outdated
@@ -35,6 +35,71 @@ typedef PlatformMessageResponseCallback = void Function(ByteData data); | |||
typedef PlatformMessageCallback = void Function( | |||
String name, ByteData data, PlatformMessageResponseCallback callback); | |||
|
|||
/// Time-related performance metrics of a frame. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a little more documentation. I'll continue to add more once I come up with other topics while polishing this PR.
shell/common/rasterizer.cc
Outdated
|
||
// TODO(liyuqian): in Fuchsia, the rasterization doesn't finish when | ||
// Rasterizer::DoDraw finishes. Future work is needed to adapt the timestamp | ||
// for Fuchsia. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right that Rasterizer::DoDraw
and Rasterizer::Draw
(which adds GPURasterizer::Draw
tracing) are approximately equal. The extra work I referred was SceneUpdateContext::ExecutePaintTasks
in scene_update_context.cc. I've added this info to the code comment.
9ec8c6e
to
fd57ac2
Compare
shell/common/shell_test.h
Outdated
@@ -26,11 +26,17 @@ class ShellTest : public ThreadTest { | |||
~ShellTest(); | |||
|
|||
Settings CreateSettingsForFixture(); | |||
|
|||
std::unique_ptr<Shell> CreateShell(Settings&& settings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both the settings and the task runners are copyable and movable. You can get rid of the double &
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
shell/common/shell.cc
Outdated
|
||
// The engine might have been destructed in ~Shell while the rasterizer is | ||
// still alive and calling this from OnFrameRasterized. | ||
if (!engine_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is not possible as the destruction of the shell will only happen after the engine is destroyed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this racy access to unique_ptr<Engine> engine_
on the GPU thread, and modified GetEngine
as we discussed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Updates look safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the renewed LGTM? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Sorry. Yeah :)
Using it, a Flutter app can monitor missing frames in the release mode, and a custom Flutter runner (e.g., Fuchsia) can add a custom FrameRasterizedCallback. Related issues: flutter/flutter#26154 flutter/flutter#31444 flutter/flutter#32447 Need review as soon as possible so we can merge this before the end of May to catch the milestone. Tests added: * NoNeedToReportTimingsByDefault * NeedsReportTimingsIsSetWithCallback * ReportTimingsIsCalled * FrameRasterizedCallbackIsCalled * FrameTimingSetsAndGetsProperly * onReportTimings preserves callback zone * FrameTiming.toString has the correct format This will need a manual engine roll as the TestWindow defined in the framework needs to implement onReportTimings.
This will manually land flutter/engine#8983 in the framework.
This will manually land flutter/engine#8983 in the framework.
Using it, a Flutter app can monitor missing frames in the release mode, and a custom Flutter runner (e.g., Fuchsia) can add a custom FrameRasterizedCallback. Related issues: flutter/flutter#26154 flutter/flutter#31444 flutter/flutter#32447 Need review as soon as possible so we can merge this before the end of May to catch the milestone. Tests added: * NoNeedToReportTimingsByDefault * NeedsReportTimingsIsSetWithCallback * ReportTimingsIsCalled * FrameRasterizedCallbackIsCalled * FrameTimingSetsAndGetsProperly * onReportTimings preserves callback zone * FrameTiming.toString has the correct format This will need a manual engine roll as the TestWindow defined in the framework needs to implement onReportTimings.
This will catch failure early for cases like flutter#9216 (which fixes manual roll for flutter#8983).
This will manually land flutter/engine#8983 in the framework.
Using it, a Flutter app can monitor missing frames in the release mode, and a custom Flutter runner (e.g., Fuchsia) can add a custom FrameRasterizedCallback.
Related issues:
flutter/flutter#26154
flutter/flutter#31444
flutter/flutter#32447
Need review as soon as possible so we can merge this before the end of May to catch the milestone.
Tests added:
This will need a manual engine roll as the TestWindow defined in the framework needs to implement onReportTimings.