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

Commit 31635688 authored by Chris Craik's avatar Chris Craik
Browse files

Change swap chain stuffed detection logic

bug:29771461
bug:29413700
bug:30181577

Changes frame interval gap detection to look for wider gaps, as they
were incorrectly firing all the time.

Also adds a 500ms minimum gap between frames dropped because of stuffed
swap chain, to prevent dropping too often.

Change-Id: If16ed637d54bf37015704be102c5c2e3731a0824
parent 2f8bf1f0
Loading
Loading
Loading
Loading
+10 −5
Original line number Original line Diff line number Diff line
@@ -217,9 +217,9 @@ bool CanvasContext::isSwapChainStuffed() {
    for (size_t i = 1; i < mSwapHistory.size(); i++) {
    for (size_t i = 1; i < mSwapHistory.size(); i++) {
        auto& swapB = mSwapHistory[i];
        auto& swapB = mSwapHistory[i];


        // If there's a frameInterval gap we effectively already dropped a frame,
        // If there's a multi-frameInterval gap we effectively already dropped a frame,
        // so consider the queue healthy.
        // so consider the queue healthy.
        if (swapA.swapCompletedTime - swapB.swapCompletedTime > frameInterval) {
        if (swapA.swapCompletedTime - swapB.swapCompletedTime > frameInterval * 3) {
            return false;
            return false;
        }
        }


@@ -298,12 +298,17 @@ void CanvasContext::prepareTree(TreeInfo& info, int64_t* uiFrameInfo,
            // Already drew for this vsync pulse, UI draw request missed
            // Already drew for this vsync pulse, UI draw request missed
            // the deadline for RT animations
            // the deadline for RT animations
            info.out.canDrawThisFrame = false;
            info.out.canDrawThisFrame = false;
        } else if (vsyncDelta >= mRenderThread.timeLord().frameIntervalNanos()) {
        } else if (vsyncDelta >= mRenderThread.timeLord().frameIntervalNanos() * 3
            // It's been at least an entire frame interval, assume
                || (latestVsync - mLastDropVsync) < 500_ms) {
            // the buffer queue is fine
            // It's been several frame intervals, assume the buffer queue is fine
            // or the last drop was too recent
            info.out.canDrawThisFrame = true;
            info.out.canDrawThisFrame = true;
        } else {
        } else {
            info.out.canDrawThisFrame = !isSwapChainStuffed();
            info.out.canDrawThisFrame = !isSwapChainStuffed();
            if (!info.out.canDrawThisFrame) {
                // dropping frame
                mLastDropVsync = mRenderThread.timeLord().latestVsync();
            }
        }
        }
    } else {
    } else {
        info.out.canDrawThisFrame = true;
        info.out.canDrawThisFrame = true;
+3 −0
Original line number Original line Diff line number Diff line
@@ -208,6 +208,9 @@ private:
    RingBuffer<SwapHistory, 3> mSwapHistory;
    RingBuffer<SwapHistory, 3> mSwapHistory;
    int64_t mFrameNumber = -1;
    int64_t mFrameNumber = -1;


    // last vsync for a dropped frame due to stuffed queue
    nsecs_t mLastDropVsync = 0;

    bool mOpaque;
    bool mOpaque;
#if HWUI_NEW_OPS
#if HWUI_NEW_OPS
    BakedOpRenderer::LightInfo mLightInfo;
    BakedOpRenderer::LightInfo mLightInfo;