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

Commit 643f0949 authored by Kalle Raita's avatar Kalle Raita
Browse files

Do not drop MonitoredProducer in binder calls

Currently the MonitoredProducer is left out when the producer is
marshalled for binder calls. If others than the owning layer have
references to the underlying surface, clearing the layer leads to the
surface being removed from the SF tracking list. This is in clear
contradiction with the test case
libgui_test.SurfaceTest#QueuesToWindowComposerIsTrueWhenPurgatorized.

Unfortunately the test case has not accounted for the async nature of
the operation and has been only intermittently failing for a long
while. Change also changes the test to wait for the clear operation to
complete.

Test: libgui_test, AUPT on Pixel XL
Bug: 31045556
Change-Id: Iddb1cef82c492e8b3beeb32de7e11587e0c1ebed
parent 75b45262
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -29,8 +29,12 @@
#include <private/gui/ComposerService.h>
#include <private/gui/ComposerService.h>
#include <binder/ProcessState.h>
#include <binder/ProcessState.h>


#include <thread>

namespace android {
namespace android {


using namespace std::chrono_literals;

class SurfaceTest : public ::testing::Test {
class SurfaceTest : public ::testing::Test {
protected:
protected:


@@ -77,6 +81,8 @@ TEST_F(SurfaceTest, QueuesToWindowComposerIsTrueWhenVisible) {


TEST_F(SurfaceTest, QueuesToWindowComposerIsTrueWhenPurgatorized) {
TEST_F(SurfaceTest, QueuesToWindowComposerIsTrueWhenPurgatorized) {
    mSurfaceControl.clear();
    mSurfaceControl.clear();
    // Wait for the async clean-up to complete.
    std::this_thread::sleep_for(50ms);


    sp<ANativeWindow> anw(mSurface);
    sp<ANativeWindow> anw(mSurface);
    int result = -123;
    int result = -123;
+2 −2
Original line number Original line Diff line number Diff line
@@ -49,7 +49,7 @@ MonitoredProducer::~MonitoredProducer() {
        wp<IBinder> mProducer;
        wp<IBinder> mProducer;
    };
    };


    mFlinger->postMessageAsync(new MessageCleanUpList(mFlinger, asBinder(this)));
    mFlinger->postMessageAsync(new MessageCleanUpList(mFlinger, asBinder(mProducer)));
}
}


status_t MonitoredProducer::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
status_t MonitoredProducer::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
@@ -156,7 +156,7 @@ status_t MonitoredProducer::getUniqueId(uint64_t* outId) const {
}
}


IBinder* MonitoredProducer::onAsBinder() {
IBinder* MonitoredProducer::onAsBinder() {
    return IInterface::asBinder(mProducer).get();
    return this;
}
}


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
+1 −1
Original line number Original line Diff line number Diff line
@@ -27,7 +27,7 @@ class SurfaceFlinger;


// MonitoredProducer wraps an IGraphicBufferProducer so that SurfaceFlinger will
// MonitoredProducer wraps an IGraphicBufferProducer so that SurfaceFlinger will
// be notified upon its destruction
// be notified upon its destruction
class MonitoredProducer : public IGraphicBufferProducer {
class MonitoredProducer : public BnGraphicBufferProducer {
public:
public:
    MonitoredProducer(const sp<IGraphicBufferProducer>& producer,
    MonitoredProducer(const sp<IGraphicBufferProducer>& producer,
            const sp<SurfaceFlinger>& flinger);
            const sp<SurfaceFlinger>& flinger);