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

Commit 8f464508 authored by Matt Buckley's avatar Matt Buckley Committed by Android (Google) Code Review
Browse files

Merge "Fix possible leaks in CanvasContext HintSessionWrapper" into main

parents 8fcaebb0 ac620f64
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@ void CanvasContext::destroy() {
    destroyHardwareResources();
    mAnimationContext->destroy();
    mRenderThread.cacheManager().onContextStopped(this);
    mHintSessionWrapper.destroy();
}

static void setBufferCount(ANativeWindow* window) {
@@ -195,6 +196,7 @@ void CanvasContext::setHardwareBuffer(AHardwareBuffer* buffer) {
void CanvasContext::setSurface(ANativeWindow* window, bool enableTimeout) {
    ATRACE_CALL();

    startHintSession();
    if (window) {
        mNativeSurface = std::make_unique<ReliableSurface>(window);
        mNativeSurface->init();
+9 −0
Original line number Diff line number Diff line
@@ -93,8 +93,17 @@ HintSessionWrapper::HintSessionWrapper(pid_t uiThreadId, pid_t renderThreadId)
        : mUiThreadId(uiThreadId), mRenderThreadId(renderThreadId) {}

HintSessionWrapper::~HintSessionWrapper() {
    destroy();
}

void HintSessionWrapper::destroy() {
    if (mHintSessionFuture.valid()) {
        mHintSession = mHintSessionFuture.get();
    }
    if (mHintSession) {
        gAPH_closeSessionFn(mHintSession);
        mSessionValid = true;
        mHintSession = nullptr;
    }
}

+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public:
    void sendLoadResetHint();
    void sendLoadIncreaseHint();
    bool init();
    void destroy();

private:
    APerformanceHintSession* mHintSession = nullptr;