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

Commit 10d75fc5 authored by Matt Buckley's avatar Matt Buckley
Browse files

Fix possible leaks in CanvasContext HintSessionWrapper

Ensure the mHintSessionFuture is accounted for correctly in the
destructor, and proper destruction is taken in CanvasContext::destroy()
in addition to the destructor.

Bug: b/297230599
Test: manual
Change-Id: Idcbd0f2ba87290f090d693f0a64cb46fe8270b95
Merged-In: Idcbd0f2ba87290f090d693f0a64cb46fe8270b95
(cherry picked from commit ac620f64)
parent 21c98807
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ void CanvasContext::destroy() {
    destroyHardwareResources();
    mAnimationContext->destroy();
    mRenderThread.cacheManager().onContextStopped(this);
    mHintSessionWrapper.destroy();
}

static void setBufferCount(ANativeWindow* window) {
@@ -193,6 +194,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;