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

Commit 3f96592d authored by Ady Abraham's avatar Ady Abraham
Browse files

SF: Min layers should not choose a frame rate override

Due to b/266444890, we need to limit the frame rate override usages
for Min layers (such as infrequent layers) as it creates jank for layers
that just started to animate due to the slow ramp up time.

Bug: 266444890
Test: [v2/android-crystalball-eng/health/microbench/systemui/main/systemui-notification-1-jank-suite] android.platform.test.scenario.notification.ConversationNotificationMicrobenchmark#conversationNotificationTest
Change-Id: Ic42e00a6920b19cc6e972a13c4df54f73a55e1d7
parent 1a1a88bb
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -932,14 +932,22 @@ auto RefreshRateSelector::rankFrameRates(std::optional<int> anchorGroupOpt,
    const char* const whence = __func__;
    std::deque<ScoredFrameRate> ranking;
    const auto rankFrameRate = [&](const FrameRateMode& frameRateMode) REQUIRES(mLock) {
        using fps_approx_ops::operator<;
        const auto& modePtr = frameRateMode.modePtr;
        if (anchorGroupOpt && modePtr->getGroup() != anchorGroupOpt) {
            return;
        }

        const bool ascending = (refreshRateOrder == RefreshRateOrder::Ascending);
        if (ascending && frameRateMode.fps < getMinRefreshRateByPolicyLocked()->getFps()) {
            // TODO(b/266481656): Once this bug is fixed, we can remove this workaround and actually
            //  use a lower frame rate when we want Ascending frame rates.
            return;
        }

        float score = calculateDistanceScoreFromMax(frameRateMode.fps);
        const bool inverseScore = (refreshRateOrder == RefreshRateOrder::Ascending);
        if (inverseScore) {

        if (ascending) {
            score = 1.0f / score;
        }
        if (preferredDisplayModeOpt) {
@@ -951,6 +959,7 @@ auto RefreshRateSelector::rankFrameRates(std::optional<int> anchorGroupOpt,
            constexpr float kNonPreferredModePenalty = 0.95f;
            score *= kNonPreferredModePenalty;
        }

        ALOGV("%s(%s) %s (%s) scored %.2f", whence, ftl::enum_string(refreshRateOrder).c_str(),
              to_string(frameRateMode.fps).c_str(), to_string(modePtr->getFps()).c_str(), score);
        ranking.emplace_back(ScoredFrameRate{frameRateMode, score});
+10 −0
Original line number Diff line number Diff line
@@ -2973,5 +2973,15 @@ TEST_P(RefreshRateSelectorTest, SupportsLowPhysicalRefreshRates) {
    EXPECT_EQ(kMode1, selector.getMinRefreshRateByPolicy());
}

// TODO(b/266481656): Once this bug is fixed, we can remove this test
TEST_P(RefreshRateSelectorTest, noLowerFrameRateOnMinVote) {
    auto selector = createSelector(kModes_60_90, kModeId60);

    std::vector<LayerRequirement> layers = {{.weight = 1.f}};
    layers[0].name = "Test layer";
    layers[0].vote = LayerVoteType::Min;
    EXPECT_FRAME_RATE_MODE(kMode60, 60_Hz, selector.getBestScoredFrameRate(layers).frameRateMode);
}

} // namespace
} // namespace android::scheduler