Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87cf0ef7 authored by Ram Indani's avatar Ram Indani Committed by Android (Google) Code Review
Browse files

Merge changes I6c8dfb52,Iff26902c into main

* changes:
  [SF] increase jank threshold to 4 milliseconds
  Flag to increase jank threshold to 4 milliseconds
parents 5906db4d 29b3d132
Loading
Loading
Loading
Loading
+20 −17
Original line number Original line Diff line number Diff line
@@ -611,7 +611,11 @@ void SurfaceFrame::classifyJankLocked(int32_t displayFrameJankType, const Fps& r
        mFrameReadyMetadata = FrameReadyMetadata::OnTimeFinish;
        mFrameReadyMetadata = FrameReadyMetadata::OnTimeFinish;
    }
    }


    if (std::abs(presentDelta) > mJankClassificationThresholds.presentThreshold) {
    const nsecs_t presentThreshold =
            FlagManager::getInstance().increase_missed_frame_jank_threshold()
            ? mJankClassificationThresholds.presentThresholdExtended
            : mJankClassificationThresholds.presentThresholdLegacy;
    if (std::abs(presentDelta) > presentThreshold) {
        mFramePresentMetadata = presentDelta > 0 ? FramePresentMetadata::LatePresent
        mFramePresentMetadata = presentDelta > 0 ? FramePresentMetadata::LatePresent
                                                 : FramePresentMetadata::EarlyPresent;
                                                 : FramePresentMetadata::EarlyPresent;
        // Jank that is missing by less than the render rate period is classified as partial jank,
        // Jank that is missing by less than the render rate period is classified as partial jank,
@@ -629,9 +633,8 @@ void SurfaceFrame::classifyJankLocked(int32_t displayFrameJankType, const Fps& r
    } else if (mFramePresentMetadata == FramePresentMetadata::EarlyPresent) {
    } else if (mFramePresentMetadata == FramePresentMetadata::EarlyPresent) {
        if (mFrameReadyMetadata == FrameReadyMetadata::OnTimeFinish) {
        if (mFrameReadyMetadata == FrameReadyMetadata::OnTimeFinish) {
            // Finish on time, Present early
            // Finish on time, Present early
            if (deltaToVsync < mJankClassificationThresholds.presentThreshold ||
            if (deltaToVsync < presentThreshold ||
                deltaToVsync >= refreshRate.getPeriodNsecs() -
                deltaToVsync >= refreshRate.getPeriodNsecs() - presentThreshold) {
                                mJankClassificationThresholds.presentThreshold) {
                // Delta factor of vsync
                // Delta factor of vsync
                mJankType = JankType::SurfaceFlingerScheduling;
                mJankType = JankType::SurfaceFlingerScheduling;
            } else {
            } else {
@@ -667,9 +670,8 @@ void SurfaceFrame::classifyJankLocked(int32_t displayFrameJankType, const Fps& r
                if (!(mJankType & JankType::BufferStuffing)) {
                if (!(mJankType & JankType::BufferStuffing)) {
                    // In a stuffed state, if the app finishes on time and there is no display frame
                    // In a stuffed state, if the app finishes on time and there is no display frame
                    // jank, only buffer stuffing is the root cause of the jank.
                    // jank, only buffer stuffing is the root cause of the jank.
                    if (deltaToVsync < mJankClassificationThresholds.presentThreshold ||
                    if (deltaToVsync < presentThreshold ||
                        deltaToVsync >= refreshRate.getPeriodNsecs() -
                        deltaToVsync >= refreshRate.getPeriodNsecs() - presentThreshold) {
                                        mJankClassificationThresholds.presentThreshold) {
                        // Delta factor of vsync
                        // Delta factor of vsync
                        mJankType |= JankType::SurfaceFlingerScheduling;
                        mJankType |= JankType::SurfaceFlingerScheduling;
                    } else {
                    } else {
@@ -1091,7 +1093,11 @@ void FrameTimeline::DisplayFrame::classifyJank(nsecs_t& deadlineDelta, nsecs_t&
            ? std::abs(presentDelta) % mRefreshRate.getPeriodNsecs()
            ? std::abs(presentDelta) % mRefreshRate.getPeriodNsecs()
            : 0;
            : 0;


    if (std::abs(presentDelta) > mJankClassificationThresholds.presentThreshold) {
    nsecs_t presentThreshold = FlagManager::getInstance().increase_missed_frame_jank_threshold()
            ? mJankClassificationThresholds.presentThresholdExtended
            : mJankClassificationThresholds.presentThresholdLegacy;

    if (std::abs(presentDelta) > presentThreshold) {
        mFramePresentMetadata = presentDelta > 0 ? FramePresentMetadata::LatePresent
        mFramePresentMetadata = presentDelta > 0 ? FramePresentMetadata::LatePresent
                                                 : FramePresentMetadata::EarlyPresent;
                                                 : FramePresentMetadata::EarlyPresent;
        // Jank that is missing by less than the render rate period is classified as partial jank,
        // Jank that is missing by less than the render rate period is classified as partial jank,
@@ -1122,9 +1128,8 @@ void FrameTimeline::DisplayFrame::classifyJank(nsecs_t& deadlineDelta, nsecs_t&
        if (mFramePresentMetadata == FramePresentMetadata::EarlyPresent) {
        if (mFramePresentMetadata == FramePresentMetadata::EarlyPresent) {
            if (mFrameReadyMetadata == FrameReadyMetadata::OnTimeFinish) {
            if (mFrameReadyMetadata == FrameReadyMetadata::OnTimeFinish) {
                // Finish on time, Present early
                // Finish on time, Present early
                if (deltaToVsync < mJankClassificationThresholds.presentThreshold ||
                if (deltaToVsync < presentThreshold ||
                    deltaToVsync >= (mRefreshRate.getPeriodNsecs() -
                    deltaToVsync >= (mRefreshRate.getPeriodNsecs() - presentThreshold)) {
                                     mJankClassificationThresholds.presentThreshold)) {
                    // Delta is a factor of vsync if its within the presentTheshold on either side
                    // Delta is a factor of vsync if its within the presentTheshold on either side
                    // of the vsyncPeriod. Example: 0-2ms and 9-11ms are both within the threshold
                    // of the vsyncPeriod. Example: 0-2ms and 9-11ms are both within the threshold
                    // of the vsyncPeriod if the threshold was 2ms and the vsyncPeriod was 11ms.
                    // of the vsyncPeriod if the threshold was 2ms and the vsyncPeriod was 11ms.
@@ -1142,7 +1147,7 @@ void FrameTimeline::DisplayFrame::classifyJank(nsecs_t& deadlineDelta, nsecs_t&
            }
            }
        } else if (mFramePresentMetadata == FramePresentMetadata::LatePresent) {
        } else if (mFramePresentMetadata == FramePresentMetadata::LatePresent) {
            if (std::abs(mSurfaceFlingerPredictions.presentTime - previousPresentTime) <=
            if (std::abs(mSurfaceFlingerPredictions.presentTime - previousPresentTime) <=
                        mJankClassificationThresholds.presentThreshold ||
                        presentThreshold ||
                previousPresentTime > mSurfaceFlingerPredictions.presentTime) {
                previousPresentTime > mSurfaceFlingerPredictions.presentTime) {
                // The previous frame was either presented in the current frame's expected vsync or
                // The previous frame was either presented in the current frame's expected vsync or
                // it was presented even later than the current frame's expected vsync.
                // it was presented even later than the current frame's expected vsync.
@@ -1151,9 +1156,8 @@ void FrameTimeline::DisplayFrame::classifyJank(nsecs_t& deadlineDelta, nsecs_t&
            if (mFrameReadyMetadata == FrameReadyMetadata::OnTimeFinish &&
            if (mFrameReadyMetadata == FrameReadyMetadata::OnTimeFinish &&
                !(mJankType & JankType::SurfaceFlingerStuffing)) {
                !(mJankType & JankType::SurfaceFlingerStuffing)) {
                // Finish on time, Present late
                // Finish on time, Present late
                if (deltaToVsync < mJankClassificationThresholds.presentThreshold ||
                if (deltaToVsync < presentThreshold ||
                    deltaToVsync >= (mRefreshRate.getPeriodNsecs() -
                    deltaToVsync >= (mRefreshRate.getPeriodNsecs() - presentThreshold)) {
                                     mJankClassificationThresholds.presentThreshold)) {
                    // Delta is a factor of vsync if its within the presentTheshold on either side
                    // Delta is a factor of vsync if its within the presentTheshold on either side
                    // of the vsyncPeriod. Example: 0-2ms and 9-11ms are both within the threshold
                    // of the vsyncPeriod. Example: 0-2ms and 9-11ms are both within the threshold
                    // of the vsyncPeriod if the threshold was 2ms and the vsyncPeriod was 11ms.
                    // of the vsyncPeriod if the threshold was 2ms and the vsyncPeriod was 11ms.
@@ -1165,8 +1169,7 @@ void FrameTimeline::DisplayFrame::classifyJank(nsecs_t& deadlineDelta, nsecs_t&
            } else if (mFrameReadyMetadata == FrameReadyMetadata::LateFinish) {
            } else if (mFrameReadyMetadata == FrameReadyMetadata::LateFinish) {
                if (!(mJankType & JankType::SurfaceFlingerStuffing) ||
                if (!(mJankType & JankType::SurfaceFlingerStuffing) ||
                    mSurfaceFlingerActuals.presentTime - previousPresentTime >
                    mSurfaceFlingerActuals.presentTime - previousPresentTime >
                            mRefreshRate.getPeriodNsecs() +
                            mRefreshRate.getPeriodNsecs() + presentThreshold) {
                                    mJankClassificationThresholds.presentThreshold) {
                    // Classify CPU vs GPU if SF wasn't stuffed or if SF was stuffed but this frame
                    // Classify CPU vs GPU if SF wasn't stuffed or if SF was stuffed but this frame
                    // was presented more than a vsync late.
                    // was presented more than a vsync late.
                    if (mGpuFence != FenceTime::NO_FENCE) {
                    if (mGpuFence != FenceTime::NO_FENCE) {
+4 −1
Original line number Original line Diff line number Diff line
@@ -107,7 +107,10 @@ struct TimelineItem {
struct JankClassificationThresholds {
struct JankClassificationThresholds {
    // The various thresholds for App and SF. If the actual timestamp falls within the threshold
    // The various thresholds for App and SF. If the actual timestamp falls within the threshold
    // compared to prediction, we treat it as on time.
    // compared to prediction, we treat it as on time.
    nsecs_t presentThreshold = std::chrono::duration_cast<std::chrono::nanoseconds>(2ms).count();
    nsecs_t presentThresholdLegacy =
            std::chrono::duration_cast<std::chrono::nanoseconds>(2ms).count();
    nsecs_t presentThresholdExtended =
            std::chrono::duration_cast<std::chrono::nanoseconds>(4ms).count();
    nsecs_t deadlineThreshold = std::chrono::duration_cast<std::chrono::nanoseconds>(0ms).count();
    nsecs_t deadlineThreshold = std::chrono::duration_cast<std::chrono::nanoseconds>(0ms).count();
    nsecs_t startThreshold = std::chrono::duration_cast<std::chrono::nanoseconds>(2ms).count();
    nsecs_t startThreshold = std::chrono::duration_cast<std::chrono::nanoseconds>(2ms).count();
};
};
+2 −0
Original line number Original line Diff line number Diff line
@@ -126,6 +126,7 @@ void FlagManager::dump(std::string& result) const {
    DUMP_ACONFIG_FLAG(adpf_native_session_manager);
    DUMP_ACONFIG_FLAG(adpf_native_session_manager);
    DUMP_ACONFIG_FLAG(adpf_use_fmq_channel);
    DUMP_ACONFIG_FLAG(adpf_use_fmq_channel);
    DUMP_ACONFIG_FLAG(graphite_renderengine_preview_rollout);
    DUMP_ACONFIG_FLAG(graphite_renderengine_preview_rollout);
    DUMP_ACONFIG_FLAG(increase_missed_frame_jank_threshold);
    DUMP_ACONFIG_FLAG(refresh_rate_overlay_on_external_display);
    DUMP_ACONFIG_FLAG(refresh_rate_overlay_on_external_display);


    /// Trunk stable readonly flags ///
    /// Trunk stable readonly flags ///
@@ -300,6 +301,7 @@ FLAG_MANAGER_ACONFIG_FLAG(refresh_rate_overlay_on_external_display, "")
FLAG_MANAGER_ACONFIG_FLAG(adpf_gpu_sf, "")
FLAG_MANAGER_ACONFIG_FLAG(adpf_gpu_sf, "")
FLAG_MANAGER_ACONFIG_FLAG(adpf_native_session_manager, "");
FLAG_MANAGER_ACONFIG_FLAG(adpf_native_session_manager, "");
FLAG_MANAGER_ACONFIG_FLAG(graphite_renderengine_preview_rollout, "");
FLAG_MANAGER_ACONFIG_FLAG(graphite_renderengine_preview_rollout, "");
FLAG_MANAGER_ACONFIG_FLAG(increase_missed_frame_jank_threshold, "");


/// Trunk stable server (R/W) flags from outside SurfaceFlinger ///
/// Trunk stable server (R/W) flags from outside SurfaceFlinger ///
FLAG_MANAGER_ACONFIG_FLAG_IMPORTED(adpf_use_fmq_channel, "", android::os)
FLAG_MANAGER_ACONFIG_FLAG_IMPORTED(adpf_use_fmq_channel, "", android::os)
+1 −0
Original line number Original line Diff line number Diff line
@@ -61,6 +61,7 @@ public:
    bool adpf_use_fmq_channel() const;
    bool adpf_use_fmq_channel() const;
    bool adpf_use_fmq_channel_fixed() const;
    bool adpf_use_fmq_channel_fixed() const;
    bool graphite_renderengine_preview_rollout() const;
    bool graphite_renderengine_preview_rollout() const;
    bool increase_missed_frame_jank_threshold() const;
    bool refresh_rate_overlay_on_external_display() const;
    bool refresh_rate_overlay_on_external_display() const;


    /// Trunk stable readonly flags ///
    /// Trunk stable readonly flags ///
+7 −0
Original line number Original line Diff line number Diff line
@@ -189,6 +189,13 @@ flag {
  bug: "293371537"
  bug: "293371537"
} # graphite_renderengine_preview_rollout
} # graphite_renderengine_preview_rollout


flag {
  name: "increase_missed_frame_jank_threshold"
  namespace: "core_graphics"
  description: "Increase the jank threshold to 4 milliseconds"
  bug: "342265411"
} # increase_missed_frame_jank_threshold

flag {
flag {
  name: "latch_unsignaled_with_auto_refresh_changed"
  name: "latch_unsignaled_with_auto_refresh_changed"
  namespace: "core_graphics"
  namespace: "core_graphics"
Loading