From fe4d05cd44be3ee805c14c49e59b88d8cf67c4a1 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Mon, 30 Aug 2021 15:31:08 -0700 Subject: Surface: Release references to BlastBufferQueue and SurfaceControl on Surface#destroy SurfaceView clients may hold on to surface references. In S this means they would extend the lifetime of the SurfaceControl resulting in "leaking" buffers until the references are cleared or the app is terminated. Fix this by calling a new destroy function on Surface which will explicitly remove references to the SurfaceControl and BBQ it holds. This is safe because SurfaceView controls the lifecycle of the Surface and knows when the Surface will become invalid. Once invalid, the Surface cannot become valid again. Test: repro steps in bug Bug: 198133921 Change-Id: I88fe98fa275dd76e20a5403c24bd2cb3bee5346d Merged-In: I88fe98fa275dd76e20a5403c24bd2cb3bee5346d --- libs/gui/Surface.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libs/gui/Surface.cpp') diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index 2edb4e4ba4..353a91d062 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -2622,4 +2622,14 @@ status_t Surface::setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInf return composerService()->setFrameTimelineInfo(mGraphicBufferProducer, frameTimelineInfo); } +sp Surface::getSurfaceControlHandle() const { + Mutex::Autolock lock(mMutex); + return mSurfaceControlHandle; +} + +void Surface::destroy() { + Mutex::Autolock lock(mMutex); + mSurfaceControlHandle = nullptr; +} + }; // namespace android -- cgit v1.2.3-59-g8ed1b