Loading libs/hwui/renderthread/CanvasContext.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -467,11 +467,11 @@ void CanvasContext::notifyFramePending() { mRenderThread.pushBackFrameCallback(this); } void CanvasContext::draw() { nsecs_t CanvasContext::draw() { if (auto grContext = getGrContext()) { if (grContext->abandoned()) { LOG_ALWAYS_FATAL("GrContext is abandoned/device lost at start of CanvasContext::draw"); return; return 0; } } SkRect dirty; Loading @@ -486,7 +486,7 @@ void CanvasContext::draw() { std::invoke(func, mFrameNumber); } mFrameCompleteCallbacks.clear(); return; return 0; } ScopedActiveContext activeContext(this); Loading Loading @@ -616,6 +616,7 @@ void CanvasContext::draw() { } mRenderThread.cacheManager().onFrameCompleted(); return mCurrentFrameInfo->get(FrameInfoIndex::DequeueBufferDuration); } void CanvasContext::reportMetricsWithPresentTime() { Loading libs/hwui/renderthread/CanvasContext.h +2 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,8 @@ public: void setColorMode(ColorMode mode); bool makeCurrent(); void prepareTree(TreeInfo& info, int64_t* uiFrameInfo, int64_t syncQueued, RenderNode* target); void draw(); // Returns the DequeueBufferDuration. nsecs_t draw(); void destroy(); // IFrameCallback, Choreographer-driven frame callback entry point Loading libs/hwui/renderthread/DrawFrameTask.cpp +10 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <utils/Log.h> #include <utils/TraceUtils.h> #include <algorithm> #include "../DeferredLayerUpdater.h" #include "../DisplayList.h" Loading Loading @@ -91,6 +92,7 @@ void DrawFrameTask::postAndWait() { void DrawFrameTask::run() { const int64_t vsyncId = mFrameInfo[static_cast<int>(FrameInfoIndex::FrameTimelineVsyncId)]; ATRACE_FORMAT("DrawFrames %" PRId64, vsyncId); nsecs_t syncDelayDuration = systemTime(SYSTEM_TIME_MONOTONIC) - mSyncQueued; bool canUnblockUiThread; bool canDrawThisFrame; Loading Loading @@ -124,8 +126,9 @@ void DrawFrameTask::run() { [callback, frameNr = context->getFrameNumber()]() { callback(frameNr); }); } nsecs_t dequeueBufferDuration = 0; if (CC_LIKELY(canDrawThisFrame)) { context->draw(); dequeueBufferDuration = context->draw(); } else { // wait on fences so tasks don't overlap next frame context->waitOnFences(); Loading @@ -149,10 +152,14 @@ void DrawFrameTask::run() { mUpdateTargetWorkDuration(targetWorkDuration); } int64_t frameDuration = systemTime(SYSTEM_TIME_MONOTONIC) - frameStartTime; if (frameDuration > kSanityCheckLowerBound && frameDuration < kSanityCheckUpperBound) { mReportActualWorkDuration(frameDuration); int64_t actualDuration = frameDuration - (std::min(syncDelayDuration, mLastDequeueBufferDuration)) - dequeueBufferDuration; if (actualDuration > kSanityCheckLowerBound && actualDuration < kSanityCheckUpperBound) { mReportActualWorkDuration(actualDuration); } } mLastDequeueBufferDuration = dequeueBufferDuration; } bool DrawFrameTask::syncFrameState(TreeInfo& info) { Loading libs/hwui/renderthread/DrawFrameTask.h +1 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ private: std::function<void(int64_t)> mFrameCallback; std::function<void(int64_t)> mFrameCompleteCallback; nsecs_t mLastDequeueBufferDuration = 0; nsecs_t mLastTargetWorkDuration = 0; std::function<void(int64_t)> mUpdateTargetWorkDuration; std::function<void(int64_t)> mReportActualWorkDuration; Loading Loading
libs/hwui/renderthread/CanvasContext.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -467,11 +467,11 @@ void CanvasContext::notifyFramePending() { mRenderThread.pushBackFrameCallback(this); } void CanvasContext::draw() { nsecs_t CanvasContext::draw() { if (auto grContext = getGrContext()) { if (grContext->abandoned()) { LOG_ALWAYS_FATAL("GrContext is abandoned/device lost at start of CanvasContext::draw"); return; return 0; } } SkRect dirty; Loading @@ -486,7 +486,7 @@ void CanvasContext::draw() { std::invoke(func, mFrameNumber); } mFrameCompleteCallbacks.clear(); return; return 0; } ScopedActiveContext activeContext(this); Loading Loading @@ -616,6 +616,7 @@ void CanvasContext::draw() { } mRenderThread.cacheManager().onFrameCompleted(); return mCurrentFrameInfo->get(FrameInfoIndex::DequeueBufferDuration); } void CanvasContext::reportMetricsWithPresentTime() { Loading
libs/hwui/renderthread/CanvasContext.h +2 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,8 @@ public: void setColorMode(ColorMode mode); bool makeCurrent(); void prepareTree(TreeInfo& info, int64_t* uiFrameInfo, int64_t syncQueued, RenderNode* target); void draw(); // Returns the DequeueBufferDuration. nsecs_t draw(); void destroy(); // IFrameCallback, Choreographer-driven frame callback entry point Loading
libs/hwui/renderthread/DrawFrameTask.cpp +10 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <utils/Log.h> #include <utils/TraceUtils.h> #include <algorithm> #include "../DeferredLayerUpdater.h" #include "../DisplayList.h" Loading Loading @@ -91,6 +92,7 @@ void DrawFrameTask::postAndWait() { void DrawFrameTask::run() { const int64_t vsyncId = mFrameInfo[static_cast<int>(FrameInfoIndex::FrameTimelineVsyncId)]; ATRACE_FORMAT("DrawFrames %" PRId64, vsyncId); nsecs_t syncDelayDuration = systemTime(SYSTEM_TIME_MONOTONIC) - mSyncQueued; bool canUnblockUiThread; bool canDrawThisFrame; Loading Loading @@ -124,8 +126,9 @@ void DrawFrameTask::run() { [callback, frameNr = context->getFrameNumber()]() { callback(frameNr); }); } nsecs_t dequeueBufferDuration = 0; if (CC_LIKELY(canDrawThisFrame)) { context->draw(); dequeueBufferDuration = context->draw(); } else { // wait on fences so tasks don't overlap next frame context->waitOnFences(); Loading @@ -149,10 +152,14 @@ void DrawFrameTask::run() { mUpdateTargetWorkDuration(targetWorkDuration); } int64_t frameDuration = systemTime(SYSTEM_TIME_MONOTONIC) - frameStartTime; if (frameDuration > kSanityCheckLowerBound && frameDuration < kSanityCheckUpperBound) { mReportActualWorkDuration(frameDuration); int64_t actualDuration = frameDuration - (std::min(syncDelayDuration, mLastDequeueBufferDuration)) - dequeueBufferDuration; if (actualDuration > kSanityCheckLowerBound && actualDuration < kSanityCheckUpperBound) { mReportActualWorkDuration(actualDuration); } } mLastDequeueBufferDuration = dequeueBufferDuration; } bool DrawFrameTask::syncFrameState(TreeInfo& info) { Loading
libs/hwui/renderthread/DrawFrameTask.h +1 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ private: std::function<void(int64_t)> mFrameCallback; std::function<void(int64_t)> mFrameCompleteCallback; nsecs_t mLastDequeueBufferDuration = 0; nsecs_t mLastTargetWorkDuration = 0; std::function<void(int64_t)> mUpdateTargetWorkDuration; std::function<void(int64_t)> mReportActualWorkDuration; Loading