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

Commit 5bdbaf7

Browse files
author
Chris Yang
committed
draft 0
1 parent 26b3c41 commit 5bdbaf7

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

shell/common/animator.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ void Animator::EnqueueTraceFlowId(uint64_t trace_flow_id) {
7676
});
7777
}
7878

79+
void Animator::RecordFrameDuration(const int64_t frame_duration) {
80+
TRACE_EVENT0("flutter", "Engine::RecordFrameDuration");
81+
FML_DCHECK(frame_duration >= 0);
82+
FML_DLOG(ERROR) << "frame duration " << frame_duration;
83+
}
84+
7985
// This Parity is used by the timeline component to correctly align
8086
// GPU Workloads events with their respective Framework Workload.
8187
const char* Animator::FrameParity() {

shell/common/animator.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ class Animator final {
8383
// active rendering.
8484
void EnqueueTraceFlowId(uint64_t trace_flow_id);
8585

86+
//----------------------------------------------------------------------------
87+
/// @brief Record the frame duration of the last frame.
88+
///
89+
/// @param[in] frame_duration The delta between raster end time and build
90+
/// start time, in milliseconds. This value must
91+
/// be positive
92+
///
93+
void RecordFrameDuration(const int64_t frame_duration);
94+
8695
private:
8796
using LayerTreePipeline = Pipeline<flutter::LayerTree>;
8897

shell/common/engine.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ void Engine::ReportTimings(std::vector<int64_t> timings) {
246246
runtime_controller_->ReportTimings(std::move(timings));
247247
}
248248

249+
void Engine::RecordFrameDuration(const int64_t frame_duration) {
250+
TRACE_EVENT0("flutter", "Engine::RecordFrameDuration");
251+
FML_DCHECK(frame_duration >= 0);
252+
animator_->RecordFrameDuration(frame_duration);
253+
}
254+
249255
void Engine::NotifyIdle(int64_t deadline) {
250256
auto trace_event = std::to_string(deadline - Dart_TimelineGetMicros());
251257
TRACE_EVENT1("flutter", "Engine::NotifyIdle", "deadline_now_delta",

shell/common/engine.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,15 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate {
583583
///
584584
void ReportTimings(std::vector<int64_t> timings);
585585

586+
//----------------------------------------------------------------------------
587+
/// @brief Record the frame duration of the last frame.
588+
///
589+
/// @param[in] frame_duration The delta between raster end time and build
590+
/// start time, in milliseconds. This value must
591+
/// be positive
592+
///
593+
void RecordFrameDuration(const int64_t frame_duration);
594+
586595
//----------------------------------------------------------------------------
587596
/// @brief Gets the main port of the root isolate. Since the isolate is
588597
/// created immediately in the constructor of the engine, it is

shell/common/shell.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,12 @@ void Shell::OnFrameRasterized(const FrameTiming& timing) {
13611361
settings_.frame_rasterized_callback(timing);
13621362
}
13631363

1364+
int64_t frame_duration_ms = (timing.Get(FrameTiming::Phase::kBuildStart) -
1365+
timing.Get(FrameTiming::Phase::kRasterFinish))
1366+
.ToMilliseconds();
1367+
1368+
engine_->RecordFrameDuration(frame_duration_ms);
1369+
13641370
if (!needs_report_timings_) {
13651371
return;
13661372
}

0 commit comments

Comments
 (0)