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

Commit 601393fd authored by Alec Mouri's avatar Alec Mouri
Browse files

[SurfaceFlinger] Add log threshold for IGBP leak.

We should emit warning logs if we suspect a leak, so that we have a
better idea what's going on with the system before crashing.

Bug: 149942390
Test: builds, boots
Change-Id: Iff257ad017da19e2866b7a35b6093186da7a4308
parent 9b9629d9
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -374,6 +374,10 @@ SurfaceFlinger::SurfaceFlinger(Factory& factory) : SurfaceFlinger(factory, SkipI
    const size_t defaultListSize = MAX_LAYERS;
    auto listSize = property_get_int32("debug.sf.max_igbp_list_size", int32_t(defaultListSize));
    mMaxGraphicBufferProducerListSize = (listSize > 0) ? size_t(listSize) : defaultListSize;
    mGraphicBufferProducerListSizeLogThreshold =
            std::max(static_cast<int>(0.95 *
                                      static_cast<double>(mMaxGraphicBufferProducerListSize)),
                     1);

    property_get("debug.sf.luma_sampling", value, "1");
    mLumaSampling = atoi(value);
@@ -3030,6 +3034,11 @@ status_t SurfaceFlinger::addClientLayer(const sp<Client>& client, const sp<IBind
                                "Suspected IGBP leak: %zu IGBPs (%zu max), %zu Layers",
                                mGraphicBufferProducerList.size(),
                                mMaxGraphicBufferProducerListSize, mNumLayers.load());
            if (mGraphicBufferProducerList.size() > mGraphicBufferProducerListSizeLogThreshold) {
                ALOGW("Suspected IGBP leak: %zu IGBPs (%zu max), %zu Layers",
                      mGraphicBufferProducerList.size(), mMaxGraphicBufferProducerListSize,
                      mNumLayers.load());
            }
        }
        mLayersAdded = true;
    }
+4 −0
Original line number Diff line number Diff line
@@ -972,6 +972,10 @@ private:
    // Can't be unordered_set because wp<> isn't hashable
    std::set<wp<IBinder>> mGraphicBufferProducerList;
    size_t mMaxGraphicBufferProducerListSize = MAX_LAYERS;
    // If there are more GraphicBufferProducers tracked by SurfaceFlinger than
    // this threshold, then begin logging.
    size_t mGraphicBufferProducerListSizeLogThreshold =
            static_cast<size_t>(0.95 * static_cast<double>(MAX_LAYERS));

    // protected by mStateLock (but we could use another lock)
    bool mLayersRemoved = false;