diff --git a/gfx/webrender_bindings/RenderThread.cpp b/gfx/webrender_bindings/RenderThread.cpp index bd52e4e6e7fa..f6ff301380cf 100644 --- a/gfx/webrender_bindings/RenderThread.cpp +++ b/gfx/webrender_bindings/RenderThread.cpp @@ -657,10 +657,12 @@ void RenderThread::HandleFrameOneDocInner(wr::WindowId aWindowId, bool aRender, SetFramePublishId(aWindowId, aPublishId.ref()); } + RendererStats stats = {0}; + UpdateAndRender(aWindowId, frame.mStartId, frame.mStartTime, render, /* aReadbackSize */ Nothing(), /* aReadbackFormat */ Nothing(), - /* aReadbackBuffer */ Nothing()); + /* aReadbackBuffer */ Nothing(), &stats); // The start time is from WebRenderBridgeParent::CompositeToTarget. From that // point until now (when the frame is finally pushed to the screen) is @@ -669,6 +671,12 @@ void RenderThread::HandleFrameOneDocInner(wr::WindowId aWindowId, bool aRender, mozilla::glean::gfx::composite_time.AccumulateRawDuration(compositeDuration); PerfStats::RecordMeasurement(PerfStats::Metric::Compositing, compositeDuration); + if (stats.frame_build_time > 0.0) { + TimeDuration fbTime = + TimeDuration::FromMilliseconds(stats.frame_build_time); + mozilla::glean::wr::framebuild_time.AccumulateRawDuration(fbTime); + PerfStats::RecordMeasurement(PerfStats::Metric::FrameBuilding, fbTime); + } } void RenderThread::SetClearColor(wr::WindowId aWindowId, wr::ColorF aColor) { @@ -780,7 +788,8 @@ void RenderThread::UpdateAndRender( const TimeStamp& aStartTime, bool aRender, const Maybe& aReadbackSize, const Maybe& aReadbackFormat, - const Maybe>& aReadbackBuffer, bool* aNeedsYFlip) { + const Maybe>& aReadbackBuffer, RendererStats* aStats, + bool* aNeedsYFlip) { AUTO_PROFILER_LABEL("RenderThread::UpdateAndRender", GRAPHICS); MOZ_ASSERT(IsInRenderThread()); MOZ_ASSERT(aRender || aReadbackBuffer.isNothing()); @@ -811,10 +820,9 @@ void RenderThread::UpdateAndRender( renderer->GetCompositorBridge())); wr::RenderedFrameId latestFrameId; - RendererStats stats = {0}; if (aRender) { latestFrameId = renderer->UpdateAndRender( - aReadbackSize, aReadbackFormat, aReadbackBuffer, aNeedsYFlip, &stats); + aReadbackSize, aReadbackFormat, aReadbackBuffer, aNeedsYFlip, aStats); } else { renderer->Update(); } @@ -829,7 +837,7 @@ void RenderThread::UpdateAndRender( layers::CompositorThread()->Dispatch( NewRunnableFunction("NotifyDidRenderRunnable", &NotifyDidRender, renderer->GetCompositorBridge(), info, aStartId, - aStartTime, start, end, aRender, stats)); + aStartTime, start, end, aRender, *aStats)); ipc::FileDescriptor fenceFd; diff --git a/gfx/webrender_bindings/RenderThread.h b/gfx/webrender_bindings/RenderThread.h index a1ccd8f716fe..35349da49793 100644 --- a/gfx/webrender_bindings/RenderThread.h +++ b/gfx/webrender_bindings/RenderThread.h @@ -204,7 +204,7 @@ class RenderThread final { const Maybe& aReadbackSize, const Maybe& aReadbackFormat, const Maybe>& aReadbackBuffer, - bool* aNeedsYFlip = nullptr); + RendererStats* aStats, bool* aNeedsYFlip = nullptr); void Pause(wr::WindowId aWindowId); bool Resume(wr::WindowId aWindowId); diff --git a/gfx/webrender_bindings/WebRenderAPI.cpp b/gfx/webrender_bindings/WebRenderAPI.cpp index 4bc098d7a69a..af4144414280 100644 --- a/gfx/webrender_bindings/WebRenderAPI.cpp +++ b/gfx/webrender_bindings/WebRenderAPI.cpp @@ -695,10 +695,11 @@ void WebRenderAPI::Readback(const TimeStamp& aStartTime, gfx::IntSize size, MOZ_COUNTED_DTOR_OVERRIDE(Readback) void Run(RenderThread& aRenderThread, WindowId aWindowId) override { + RendererStats stats = {0}; aRenderThread.UpdateAndRender(aWindowId, VsyncId(), mStartTime, /* aRender */ true, Some(mSize), wr::SurfaceFormatToImageFormat(mFormat), - Some(mBuffer), mNeedsYFlip); + Some(mBuffer), &stats, mNeedsYFlip); layers::AutoCompleteTask complete(mTask); } diff --git a/tools/performance/PerfStats.h b/tools/performance/PerfStats.h index a1f7e37fdde3..0e2baa990f3a 100644 --- a/tools/performance/PerfStats.h +++ b/tools/performance/PerfStats.h @@ -38,6 +38,7 @@ MACRO(Rasterizing) \ MACRO(WrDisplayListBuilding) \ MACRO(LayerTransactions) \ + MACRO(FrameBuilding) \ MACRO(Compositing) \ MACRO(Reflowing) \ MACRO(Styling) \