From 0b26710528eb69f3883f295f3e6146e6466fd082 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Mon, 29 Jan 2018 16:39:21 +0100 Subject: Fix issue with Surface loss Some remote animations didn't use all surfaces, meaning that these became unreachable objects in the object tree, meaning that they we're finalized during the animation, causing the leash to be destroyed in SurfaceFlinger, causing to suffering because the AWT surface got released, meaning that we can never allocate the main windows Surface anymore. Fix this by not releasing surfaces that you don't own. Test: go/wm-smoke Test: Notification launch animation over app Change-Id: Ia99b4e814bfb286ae1d3639c525fc8f6c42c0e0f Fixes: No bug yet, but expect to have a chaselist bug soon! --- libs/gui/SurfaceControl.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'libs/gui/SurfaceControl.cpp') diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp index f5fb8acf44..5eafbb3555 100644 --- a/libs/gui/SurfaceControl.cpp +++ b/libs/gui/SurfaceControl.cpp @@ -48,8 +48,9 @@ namespace android { SurfaceControl::SurfaceControl( const sp& client, const sp& handle, - const sp& gbp) - : mClient(client), mHandle(handle), mGraphicBufferProducer(gbp) + const sp& gbp, + bool owned) + : mClient(client), mHandle(handle), mGraphicBufferProducer(gbp), mOwned(owned) { } @@ -60,7 +61,9 @@ SurfaceControl::~SurfaceControl() void SurfaceControl::destroy() { - if (isValid()) { + // Avoid destroying the server-side surface if we are not the owner of it, meaning that we + // retrieved it from another process. + if (isValid() && mOwned) { mClient->destroySurface(mHandle); } // clear all references and trigger an IPC now, to make sure things @@ -184,9 +187,11 @@ sp SurfaceControl::readFromParcel(Parcel* parcel) } sp gbp; parcel->readNullableStrongBinder(&gbp); + + // We aren't the original owner of the surface. return new SurfaceControl(new SurfaceComposerClient( interface_cast(client)), - handle.get(), interface_cast(gbp)); + handle.get(), interface_cast(gbp), false /* owned */); } // ---------------------------------------------------------------------------- -- cgit v1.2.3-59-g8ed1b