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

Commit 40bfa730 authored by Shane's avatar Shane Committed by Jian-Syuan (Shane) Wong
Browse files

[dVRR] Allow the intermittent update to set frame rate category to

NORMAL immediately

Some Views could vote in a very low frequency (e.g., YouTube Short).
With such use case, it would take a while for the ViewRootImpl to set the frame rate category to Normal since we need to wait for mFrameRateCategoryHighCount and mFrameRateCategoryHighHintCount to be 0
before we can set frame rate category to NORMAL.

This CL allows the intermittent update to set frame rate category to NORMAL immediately. Since we have a relatively restricted criteria to detect intermittent update, it's less like to expect the frame frate category fluctuation
after this change.

Bug: 337933990
Test: atest ViewRootImplTest / atest ViewFrameRateTest
Change-Id: I2a61977fa892a12900f60f27a062614e9cca407f
parent 6771c294
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -12532,6 +12532,13 @@ public final class ViewRootImpl implements ViewParent,
            case FRAME_RATE_CATEGORY_HIGH ->
                    mFrameRateCategoryHighCount = FRAME_RATE_CATEGORY_COUNT;
        }
        // If it's currently an intermittent update,
        // we should keep mPreferredFrameRateCategory as NORMAL
        if (intermittentUpdateState() == INTERMITTENT_STATE_INTERMITTENT) {
            return;
        }
        if (mFrameRateCategoryHighCount > 0) {
            mPreferredFrameRateCategory = FRAME_RATE_CATEGORY_HIGH;
        } else if (mFrameRateCategoryHighHintCount > 0) {
+3 −23
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import static android.view.Surface.FRAME_RATE_CATEGORY_HIGH;
import static android.view.Surface.FRAME_RATE_CATEGORY_HIGH_HINT;
import static android.view.Surface.FRAME_RATE_CATEGORY_LOW;
import static android.view.Surface.FRAME_RATE_CATEGORY_NORMAL;
import static android.view.Surface.FRAME_RATE_CATEGORY_NO_PREFERENCE;
import static android.view.Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE;
import static android.view.Surface.FRAME_RATE_COMPATIBILITY_GTE;
import static android.view.View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
@@ -1160,34 +1159,15 @@ public class ViewRootImplTest {
        });
        waitForAfterDraw();

        // reset the frame rate category counts
        for (int i = 0; i < 5; i++) {
            sInstrumentation.runOnMainSync(() -> {
                mView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE);
                mView.invalidate();
            });
            sInstrumentation.waitForIdleSync();
        }

        // In transition from frequent update to infrequent update
        Thread.sleep(delay);
        sInstrumentation.runOnMainSync(() -> {
            mView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE);
            mView.invalidate();
            runAfterDraw(() -> {
                assertEquals(FRAME_RATE_CATEGORY_NO_PREFERENCE,
                        mViewRootImpl.getLastPreferredFrameRateCategory());
            });
        });
        waitForAfterDraw();
        Thread.sleep(delay);
        sInstrumentation.runOnMainSync(() -> {
            mView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_DEFAULT);
            mView.invalidate();
            runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_NO_PREFERENCE,
            int expected = toolkitFrameRateDefaultNormalReadOnly()
                    ? FRAME_RATE_CATEGORY_NORMAL : FRAME_RATE_CATEGORY_HIGH;
            runAfterDraw(() -> assertEquals(expected,
                    mViewRootImpl.getLastPreferredFrameRateCategory()));
        });
        waitForAfterDraw();

        // Infrequent update
        Thread.sleep(delay);