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

Commit fa42dfc5 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10949315 from 7ad6a353 to udc-qpr1-release

Change-Id: I31b2511c7dc7c792c0f5fdfe48217b9db809e122
parents e026422f 7ad6a353
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -342,6 +342,8 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
                    // Keyguard handler cannot handle it, process through original mixed
                    mActiveTransitions.remove(keyguardMixed);
                }
            } else if (mPipHandler != null) {
                mPipHandler.syncPipSurfaceState(info, startTransaction, finishTransaction);
            }
        }

+6 −7
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ CanvasContext::CanvasContext(RenderThread& thread, bool translucent, RenderNode*
        , mProfiler(mJankTracker.frames(), thread.timeLord().frameIntervalNanos())
        , mContentDrawBounds(0, 0, 0, 0)
        , mRenderPipeline(std::move(renderPipeline))
        , mHintSessionWrapper(std::make_shared<HintSessionWrapper>(uiThreadId, renderThreadId)) {
        , mHintSessionWrapper(uiThreadId, renderThreadId) {
    mRenderThread.cacheManager().registerCanvasContext(this);
    rootRenderNode->makeRoot();
    mRenderNodes.emplace_back(rootRenderNode);
@@ -160,7 +160,6 @@ void CanvasContext::destroy() {
    destroyHardwareResources();
    mAnimationContext->destroy();
    mRenderThread.cacheManager().onContextStopped(this);
    mHintSessionWrapper->delayedDestroy(mRenderThread, 2_s, mHintSessionWrapper);
}

static void setBufferCount(ANativeWindow* window) {
@@ -740,7 +739,7 @@ void CanvasContext::draw(bool solelyTextureViewUpdates) {
    int64_t frameDeadline = mCurrentFrameInfo->get(FrameInfoIndex::FrameDeadline);
    int64_t dequeueBufferDuration = mCurrentFrameInfo->get(FrameInfoIndex::DequeueBufferDuration);

    mHintSessionWrapper->updateTargetWorkDuration(frameDeadline - intendedVsync);
    mHintSessionWrapper.updateTargetWorkDuration(frameDeadline - intendedVsync);

    if (didDraw) {
        int64_t frameStartTime = mCurrentFrameInfo->get(FrameInfoIndex::FrameStartTime);
@@ -748,7 +747,7 @@ void CanvasContext::draw(bool solelyTextureViewUpdates) {
        int64_t actualDuration = frameDuration -
                                 (std::min(syncDelayDuration, mLastDequeueBufferDuration)) -
                                 dequeueBufferDuration - idleDuration;
        mHintSessionWrapper->reportActualWorkDuration(actualDuration);
        mHintSessionWrapper.reportActualWorkDuration(actualDuration);
    }

    mLastDequeueBufferDuration = dequeueBufferDuration;
@@ -1082,11 +1081,11 @@ void CanvasContext::prepareSurfaceControlForWebview() {
}

void CanvasContext::sendLoadResetHint() {
    mHintSessionWrapper->sendLoadResetHint();
    mHintSessionWrapper.sendLoadResetHint();
}

void CanvasContext::sendLoadIncreaseHint() {
    mHintSessionWrapper->sendLoadIncreaseHint();
    mHintSessionWrapper.sendLoadIncreaseHint();
}

void CanvasContext::setSyncDelayDuration(nsecs_t duration) {
@@ -1094,7 +1093,7 @@ void CanvasContext::setSyncDelayDuration(nsecs_t duration) {
}

void CanvasContext::startHintSession() {
    mHintSessionWrapper->init();
    mHintSessionWrapper.init();
}

bool CanvasContext::shouldDither() {
+1 −1
Original line number Diff line number Diff line
@@ -359,7 +359,7 @@ private:
    std::function<bool(int64_t, int64_t, int64_t)> mASurfaceTransactionCallback;
    std::function<void()> mPrepareSurfaceControlForWebviewCallback;

    std::shared_ptr<HintSessionWrapper> mHintSessionWrapper;
    HintSessionWrapper mHintSessionWrapper;
    nsecs_t mLastDequeueBufferDuration = 0;
    nsecs_t mSyncDelayDuration = 0;
    nsecs_t mIdleDuration = 0;
+9 −35
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@
#include <vector>

#include "../Properties.h"
#include "RenderThread.h"
#include "thread/CommonPool.h"

using namespace std::chrono_literals;
@@ -63,26 +62,24 @@ HintSessionWrapper::~HintSessionWrapper() {
}

void HintSessionWrapper::destroy() {
    if (mHintSessionFuture.has_value()) {
        mHintSession = mHintSessionFuture->get();
        mHintSessionFuture = std::nullopt;
    if (mHintSessionFuture.valid()) {
        mHintSession = mHintSessionFuture.get();
    }
    if (mHintSession) {
        mBinding->closeSession(mHintSession);
        mSessionValid = true;
        mHintSession = nullptr;
    }
    mResetsSinceLastReport = 0;
}

bool HintSessionWrapper::init() {
    if (mHintSession != nullptr) return true;

    // If we're waiting for the session
    if (mHintSessionFuture.has_value()) {
    if (mHintSessionFuture.valid()) {
        // If the session is here
        if (mHintSessionFuture->wait_for(0s) == std::future_status::ready) {
            mHintSession = mHintSessionFuture->get();
            mHintSessionFuture = std::nullopt;
        if (mHintSessionFuture.wait_for(0s) == std::future_status::ready) {
            mHintSession = mHintSessionFuture.get();
            if (mHintSession != nullptr) {
                mSessionValid = true;
                return true;
@@ -112,10 +109,10 @@ bool HintSessionWrapper::init() {

    // Use a placeholder target value to initialize,
    // this will always be replaced elsewhere before it gets used
    int64_t targetDurationNanos =
            mLastTargetWorkDuration == 0 ? kDefaultTargetDuration : mLastTargetWorkDuration;
    int64_t defaultTargetDurationNanos = 16666667;
    mHintSessionFuture = CommonPool::async([=, this, tids = std::move(tids)] {
        return mBinding->createSession(manager, tids.data(), tids.size(), targetDurationNanos);
        return mBinding->createSession(manager, tids.data(), tids.size(),
                                       defaultTargetDurationNanos);
    });
    return false;
}
@@ -139,7 +136,6 @@ void HintSessionWrapper::reportActualWorkDuration(long actualDurationNanos) {
        actualDurationNanos < kSanityCheckUpperBound) {
        mBinding->reportActualWorkDuration(mHintSession, actualDurationNanos);
    }
    mLastFrameNotification = systemTime();
}

void HintSessionWrapper::sendLoadResetHint() {
@@ -157,28 +153,6 @@ void HintSessionWrapper::sendLoadResetHint() {
void HintSessionWrapper::sendLoadIncreaseHint() {
    if (!init()) return;
    mBinding->sendHint(mHintSession, static_cast<int32_t>(SessionHint::CPU_LOAD_UP));
    mLastFrameNotification = systemTime();
}

bool HintSessionWrapper::alive() {
    return mHintSession != nullptr;
}

nsecs_t HintSessionWrapper::getLastUpdate() {
    return mLastFrameNotification;
}

// Requires passing in its shared_ptr since it shouldn't own a shared_ptr to itself
void HintSessionWrapper::delayedDestroy(RenderThread& rt, nsecs_t delay,
                                        std::shared_ptr<HintSessionWrapper> wrapperPtr) {
    nsecs_t lastUpdate = wrapperPtr->getLastUpdate();
    rt.queue().postDelayed(delay, [lastUpdate = lastUpdate, wrapper = wrapperPtr]() mutable {
        if (wrapper->getLastUpdate() == lastUpdate) {
            wrapper->destroy();
        }
        // Ensure the shared_ptr is killed at the end of the method
        wrapper = nullptr;
    });
}

} /* namespace renderthread */
+1 −10
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@
#include <android/performance_hint.h>

#include <future>
#include <optional>

#include "utils/TimeUtils.h"

@@ -28,8 +27,6 @@ namespace uirenderer {

namespace renderthread {

class RenderThread;

class HintSessionWrapper {
public:
    friend class HintSessionWrapperTests;
@@ -43,15 +40,10 @@ public:
    void sendLoadIncreaseHint();
    bool init();
    void destroy();
    bool alive();
    nsecs_t getLastUpdate();
    void delayedDestroy(renderthread::RenderThread& rt, nsecs_t delay,
                        std::shared_ptr<HintSessionWrapper> wrapperPtr);

private:
    APerformanceHintSession* mHintSession = nullptr;
    // This needs to work concurrently for testing
    std::optional<std::shared_future<APerformanceHintSession*>> mHintSessionFuture;
    std::future<APerformanceHintSession*> mHintSessionFuture;

    int mResetsSinceLastReport = 0;
    nsecs_t mLastFrameNotification = 0;
@@ -65,7 +57,6 @@ private:
    static constexpr nsecs_t kResetHintTimeout = 100_ms;
    static constexpr int64_t kSanityCheckLowerBound = 100_us;
    static constexpr int64_t kSanityCheckUpperBound = 10_s;
    static constexpr int64_t kDefaultTargetDuration = 16666667;

    // Allows easier stub when testing
    class HintSessionBinding {
Loading