Loading services/surfaceflinger/FrameTimeline/FrameTimeline.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -681,6 +681,15 @@ void SurfaceFrame::onPresent(nsecs_t presentTime, int32_t displayFrameJankType, } } void SurfaceFrame::onCommitNotComposited(Fps refreshRate, Fps displayFrameRenderRate) { std::scoped_lock lock(mMutex); mDisplayFrameRenderRate = displayFrameRenderRate; mActuals.presentTime = mPredictions.presentTime; nsecs_t deadlineDelta = 0; classifyJankLocked(JankType::None, refreshRate, displayFrameRenderRate, deadlineDelta); } void SurfaceFrame::tracePredictions(int64_t displayFrameToken, nsecs_t monoBootOffset) const { int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing(); Loading Loading @@ -912,6 +921,15 @@ void FrameTimeline::setSfPresent(nsecs_t sfPresentTime, finalizeCurrentDisplayFrame(); } void FrameTimeline::onCommitNotComposited() { ATRACE_CALL(); std::scoped_lock lock(mMutex); mCurrentDisplayFrame->onCommitNotComposited(); mCurrentDisplayFrame.reset(); mCurrentDisplayFrame = std::make_shared<DisplayFrame>(mTimeStats, mJankClassificationThresholds, &mTraceCookieCounter); } void FrameTimeline::DisplayFrame::addSurfaceFrame(std::shared_ptr<SurfaceFrame> surfaceFrame) { mSurfaceFrames.push_back(surfaceFrame); } Loading Loading @@ -1094,6 +1112,12 @@ void FrameTimeline::DisplayFrame::onPresent(nsecs_t signalTime, nsecs_t previous } } void FrameTimeline::DisplayFrame::onCommitNotComposited() { for (auto& surfaceFrame : mSurfaceFrames) { surfaceFrame->onCommitNotComposited(mRefreshRate, mRenderRate); } } void FrameTimeline::DisplayFrame::tracePredictions(pid_t surfaceFlingerPid, nsecs_t monoBootOffset) const { int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing(); Loading services/surfaceflinger/FrameTimeline/FrameTimeline.h +9 −0 Original line number Diff line number Diff line Loading @@ -204,6 +204,8 @@ public: void onPresent(nsecs_t presentTime, int32_t displayFrameJankType, Fps refreshRate, Fps displayFrameRenderRate, nsecs_t displayDeadlineDelta, nsecs_t displayPresentDelta); // Sets the frame as none janky as there was no real display frame. void onCommitNotComposited(Fps refreshRate, Fps displayFrameRenderRate); // All the timestamps are dumped relative to the baseTime void dump(std::string& result, const std::string& indent, nsecs_t baseTime) const; // Dumps only the layer, token, is buffer, jank metadata, prediction and present states. Loading Loading @@ -318,6 +320,10 @@ public: virtual void setSfPresent(nsecs_t sfPresentTime, const std::shared_ptr<FenceTime>& presentFence, const std::shared_ptr<FenceTime>& gpuFence) = 0; // Tells FrameTimeline that a frame was committed but not composited. This is used to flush // all the associated surface frames. virtual void onCommitNotComposited() = 0; // Args: // -jank : Dumps only the Display Frames that are either janky themselves // or contain janky Surface Frames. Loading Loading @@ -390,6 +396,8 @@ public: std::optional<TimelineItem> predictions, nsecs_t wakeUpTime); // Sets the appropriate metadata and classifies the jank. void onPresent(nsecs_t signalTime, nsecs_t previousPresentTime); // Flushes all the surface frames as those were not generating any actual display frames. void onCommitNotComposited(); // Adds the provided SurfaceFrame to the current display frame. void addSurfaceFrame(std::shared_ptr<SurfaceFrame> surfaceFrame); Loading Loading @@ -475,6 +483,7 @@ public: void setSfWakeUp(int64_t token, nsecs_t wakeupTime, Fps refreshRate, Fps renderRate) override; void setSfPresent(nsecs_t sfPresentTime, const std::shared_ptr<FenceTime>& presentFence, const std::shared_ptr<FenceTime>& gpuFence = FenceTime::NO_FENCE) override; void onCommitNotComposited() override; void parseArgs(const Vector<String16>& args, std::string& result) override; void setMaxDisplayFrames(uint32_t size) override; float computeFps(const std::unordered_set<int32_t>& layerIds) override; Loading services/surfaceflinger/Scheduler/ISchedulerCallback.h +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ struct ISchedulerCallback { virtual void onChoreographerAttached() = 0; virtual void onExpectedPresentTimePosted(TimePoint, ftl::NonNull<DisplayModePtr>, Fps renderRate) = 0; virtual void onCommitNotComposited(PhysicalDisplayId pacesetterDisplayId) = 0; protected: ~ISchedulerCallback() = default; Loading services/surfaceflinger/Scheduler/Scheduler.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -221,6 +221,7 @@ void Scheduler::onFrameSignal(ICompositor& compositor, VsyncId vsyncId, if (FlagManager::getInstance().vrr_config()) { compositor.sendNotifyExpectedPresentHint(pacesetterPtr->displayId); } mSchedulerCallback.onCommitNotComposited(pacesetterPtr->displayId); return; } } Loading services/surfaceflinger/SurfaceFlinger.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -4405,6 +4405,12 @@ void SurfaceFlinger::sendNotifyExpectedPresentHint(PhysicalDisplayId displayId) scheduleNotifyExpectedPresentHint(displayId); } void SurfaceFlinger::onCommitNotComposited(PhysicalDisplayId pacesetterDisplayId) { if (FlagManager::getInstance().commit_not_composited()) { mFrameTimeline->onCommitNotComposited(); } } void SurfaceFlinger::initScheduler(const sp<const DisplayDevice>& display) { using namespace scheduler; Loading Loading
services/surfaceflinger/FrameTimeline/FrameTimeline.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -681,6 +681,15 @@ void SurfaceFrame::onPresent(nsecs_t presentTime, int32_t displayFrameJankType, } } void SurfaceFrame::onCommitNotComposited(Fps refreshRate, Fps displayFrameRenderRate) { std::scoped_lock lock(mMutex); mDisplayFrameRenderRate = displayFrameRenderRate; mActuals.presentTime = mPredictions.presentTime; nsecs_t deadlineDelta = 0; classifyJankLocked(JankType::None, refreshRate, displayFrameRenderRate, deadlineDelta); } void SurfaceFrame::tracePredictions(int64_t displayFrameToken, nsecs_t monoBootOffset) const { int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing(); Loading Loading @@ -912,6 +921,15 @@ void FrameTimeline::setSfPresent(nsecs_t sfPresentTime, finalizeCurrentDisplayFrame(); } void FrameTimeline::onCommitNotComposited() { ATRACE_CALL(); std::scoped_lock lock(mMutex); mCurrentDisplayFrame->onCommitNotComposited(); mCurrentDisplayFrame.reset(); mCurrentDisplayFrame = std::make_shared<DisplayFrame>(mTimeStats, mJankClassificationThresholds, &mTraceCookieCounter); } void FrameTimeline::DisplayFrame::addSurfaceFrame(std::shared_ptr<SurfaceFrame> surfaceFrame) { mSurfaceFrames.push_back(surfaceFrame); } Loading Loading @@ -1094,6 +1112,12 @@ void FrameTimeline::DisplayFrame::onPresent(nsecs_t signalTime, nsecs_t previous } } void FrameTimeline::DisplayFrame::onCommitNotComposited() { for (auto& surfaceFrame : mSurfaceFrames) { surfaceFrame->onCommitNotComposited(mRefreshRate, mRenderRate); } } void FrameTimeline::DisplayFrame::tracePredictions(pid_t surfaceFlingerPid, nsecs_t monoBootOffset) const { int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing(); Loading
services/surfaceflinger/FrameTimeline/FrameTimeline.h +9 −0 Original line number Diff line number Diff line Loading @@ -204,6 +204,8 @@ public: void onPresent(nsecs_t presentTime, int32_t displayFrameJankType, Fps refreshRate, Fps displayFrameRenderRate, nsecs_t displayDeadlineDelta, nsecs_t displayPresentDelta); // Sets the frame as none janky as there was no real display frame. void onCommitNotComposited(Fps refreshRate, Fps displayFrameRenderRate); // All the timestamps are dumped relative to the baseTime void dump(std::string& result, const std::string& indent, nsecs_t baseTime) const; // Dumps only the layer, token, is buffer, jank metadata, prediction and present states. Loading Loading @@ -318,6 +320,10 @@ public: virtual void setSfPresent(nsecs_t sfPresentTime, const std::shared_ptr<FenceTime>& presentFence, const std::shared_ptr<FenceTime>& gpuFence) = 0; // Tells FrameTimeline that a frame was committed but not composited. This is used to flush // all the associated surface frames. virtual void onCommitNotComposited() = 0; // Args: // -jank : Dumps only the Display Frames that are either janky themselves // or contain janky Surface Frames. Loading Loading @@ -390,6 +396,8 @@ public: std::optional<TimelineItem> predictions, nsecs_t wakeUpTime); // Sets the appropriate metadata and classifies the jank. void onPresent(nsecs_t signalTime, nsecs_t previousPresentTime); // Flushes all the surface frames as those were not generating any actual display frames. void onCommitNotComposited(); // Adds the provided SurfaceFrame to the current display frame. void addSurfaceFrame(std::shared_ptr<SurfaceFrame> surfaceFrame); Loading Loading @@ -475,6 +483,7 @@ public: void setSfWakeUp(int64_t token, nsecs_t wakeupTime, Fps refreshRate, Fps renderRate) override; void setSfPresent(nsecs_t sfPresentTime, const std::shared_ptr<FenceTime>& presentFence, const std::shared_ptr<FenceTime>& gpuFence = FenceTime::NO_FENCE) override; void onCommitNotComposited() override; void parseArgs(const Vector<String16>& args, std::string& result) override; void setMaxDisplayFrames(uint32_t size) override; float computeFps(const std::unordered_set<int32_t>& layerIds) override; Loading
services/surfaceflinger/Scheduler/ISchedulerCallback.h +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ struct ISchedulerCallback { virtual void onChoreographerAttached() = 0; virtual void onExpectedPresentTimePosted(TimePoint, ftl::NonNull<DisplayModePtr>, Fps renderRate) = 0; virtual void onCommitNotComposited(PhysicalDisplayId pacesetterDisplayId) = 0; protected: ~ISchedulerCallback() = default; Loading
services/surfaceflinger/Scheduler/Scheduler.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -221,6 +221,7 @@ void Scheduler::onFrameSignal(ICompositor& compositor, VsyncId vsyncId, if (FlagManager::getInstance().vrr_config()) { compositor.sendNotifyExpectedPresentHint(pacesetterPtr->displayId); } mSchedulerCallback.onCommitNotComposited(pacesetterPtr->displayId); return; } } Loading
services/surfaceflinger/SurfaceFlinger.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -4405,6 +4405,12 @@ void SurfaceFlinger::sendNotifyExpectedPresentHint(PhysicalDisplayId displayId) scheduleNotifyExpectedPresentHint(displayId); } void SurfaceFlinger::onCommitNotComposited(PhysicalDisplayId pacesetterDisplayId) { if (FlagManager::getInstance().commit_not_composited()) { mFrameTimeline->onCommitNotComposited(); } } void SurfaceFlinger::initScheduler(const sp<const DisplayDevice>& display) { using namespace scheduler; Loading