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

Commit 0a0158c2 authored by Dan Stoza's avatar Dan Stoza
Browse files

SF: Add IGBP list leak debugging info

Adds a few things intended to make debugging IGBP list leaks easier:
  1) A dumpsys line listing the current and max occupancies of the list
  2) A debug property to set the max: debug.sf.max_igbp_list_size
  3) Printing the current number of Layers when aborting

Since we still have an unknown leak, this also sets the default limit
four times higher to avoid hitting it in dogfood/automation.

Bug: 74616334
Test: Manual, set max to 100 and verify above behaviors
Change-Id: I7a6227a1d6fc05c197ec632db7dd9f875c64c6c9
parent 5f643f8f
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -260,6 +260,11 @@ SurfaceFlinger::SurfaceFlinger()
    mLayerTripleBufferingDisabled = atoi(value);
    ALOGI_IF(mLayerTripleBufferingDisabled, "Disabling Triple Buffering");

    // TODO (b/74616334): Reduce the default value once we isolate the leak
    const size_t defaultListSize = 4 * MAX_LAYERS;
    auto listSize = property_get_int32("debug.sf.max_igbp_list_size", int32_t(defaultListSize));
    mMaxGraphicBufferProducerListSize = (listSize > 0) ? size_t(listSize) : defaultListSize;

    // We should be reading 'persist.sys.sf.color_saturation' here
    // but since /data may be encrypted, we need to wait until after vold
    // comes online to attempt to read the property. The property is
@@ -2896,8 +2901,11 @@ status_t SurfaceFlinger::addClientLayer(const sp<Client>& client,
        }

        mGraphicBufferProducerList.insert(IInterface::asBinder(gbc).get());
        LOG_ALWAYS_FATAL_IF(mGraphicBufferProducerList.size() > MAX_LAYERS,
                            "Suspected IGBP leak");
        // TODO (b/74616334): Change this back to a fatal assert once the leak is fixed
        ALOGE_IF(mGraphicBufferProducerList.size() > mMaxGraphicBufferProducerListSize,
                 "Suspected IGBP leak: %zu IGBPs (%zu max), %zu Layers",
                 mGraphicBufferProducerList.size(), mMaxGraphicBufferProducerListSize,
                 mNumLayers);
        mLayersAdded = true;
        mNumLayers++;
    }
@@ -3966,6 +3974,8 @@ void SurfaceFlinger::dumpAllLocked(const Vector<String16>& args, size_t& index,
     */
    colorizer.bold(result);
    result.appendFormat("Visible layers (count = %zu)\n", mNumLayers);
    result.appendFormat("GraphicBufferProducers: %zu, max %zu\n",
                        mGraphicBufferProducerList.size(), mMaxGraphicBufferProducerListSize);
    colorizer.reset(result);

    LayersProto layersProto = dumpProtoInfo(LayerVector::StateSet::Current);
+1 −0
Original line number Diff line number Diff line
@@ -720,6 +720,7 @@ private:

    // Can't be unordered_set because wp<> isn't hashable
    std::set<wp<IBinder>> mGraphicBufferProducerList;
    size_t mMaxGraphicBufferProducerListSize = MAX_LAYERS;

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