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

Commit cd119a21 authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge changes I3244e9d8,I71d05b62,I19aabc20 into main

* changes:
  Fix crash when cloning layers
  Add displays to the first tracing entry
  Capture traces when we encounter fatal errors
parents 2c61de69 83d9162e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2687,6 +2687,7 @@ Region Layer::getVisibleRegion(const DisplayDevice* display) const {
}

void Layer::setInitialValuesForClone(const sp<Layer>& clonedFrom, uint32_t mirrorRootId) {
    if (mFlinger->mLayerLifecycleManagerEnabled) return;
    mSnapshot->path.id = clonedFrom->getSequence();
    mSnapshot->path.mirrorRootIds.emplace_back(mirrorRootId);

+18 −15
Original line number Diff line number Diff line
@@ -2237,7 +2237,8 @@ void SurfaceFlinger::updateLayerHistory(nsecs_t now) {
        }

        auto it = mLegacyLayers.find(snapshot->sequence);
        LOG_ALWAYS_FATAL_IF(it == mLegacyLayers.end(), "Couldn't find layer object for %s",
        LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mLegacyLayers.end(),
                                        "Couldn't find layer object for %s",
                                        snapshot->getDebugString().c_str());

        if (updateSmallDirty) {
@@ -2391,7 +2392,8 @@ bool SurfaceFlinger::updateLayerSnapshots(VsyncId vsyncId, nsecs_t frameTimeNs,
            const bool willReleaseBufferOnLatch = layer->willReleaseBufferOnLatch();

            auto it = mLegacyLayers.find(layer->id);
            LOG_ALWAYS_FATAL_IF(it == mLegacyLayers.end(), "Couldnt find layer object for %s",
            LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mLegacyLayers.end(),
                                            "Couldnt find layer object for %s",
                                            layer->getDebugString().c_str());
            if (!layer->hasReadyFrame() && !willReleaseBufferOnLatch) {
                if (!it->second->hasBuffer()) {
@@ -3091,7 +3093,7 @@ void SurfaceFlinger::onCompositionPresented(PhysicalDisplayId pacesetterId,
                        [&, compositionDisplay = compositionDisplay](
                                std::unique_ptr<frontend::LayerSnapshot>& snapshot) {
                            auto it = mLegacyLayers.find(snapshot->sequence);
                            LOG_ALWAYS_FATAL_IF(it == mLegacyLayers.end(),
                            LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mLegacyLayers.end(),
                                                            "Couldnt find layer object for %s",
                                                            snapshot->getDebugString().c_str());
                            auto& legacyLayer = it->second;
@@ -6429,7 +6431,8 @@ void SurfaceFlinger::dumpHwcLayersMinidump(std::string& result) const {
                return;
            }
            auto it = mLegacyLayers.find(snapshot.sequence);
            LOG_ALWAYS_FATAL_IF(it == mLegacyLayers.end(), "Couldnt find layer object for %s",
            LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mLegacyLayers.end(),
                                            "Couldnt find layer object for %s",
                                            snapshot.getDebugString().c_str());
            it->second->miniDump(result, snapshot, ref);
        });
@@ -8827,7 +8830,7 @@ std::vector<std::pair<Layer*, LayerFE*>> SurfaceFlinger::moveSnapshotsToComposit
                    }

                    auto it = mLegacyLayers.find(snapshot->sequence);
                    LOG_ALWAYS_FATAL_IF(it == mLegacyLayers.end(),
                    LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mLegacyLayers.end(),
                                                    "Couldnt find layer object for %s",
                                                    snapshot->getDebugString().c_str());
                    auto& legacyLayer = it->second;
@@ -8898,7 +8901,7 @@ SurfaceFlinger::getLayerSnapshotsForScreenshots(
                    }

                    auto it = mLegacyLayers.find(snapshot->sequence);
                    LOG_ALWAYS_FATAL_IF(it == mLegacyLayers.end(),
                    LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mLegacyLayers.end(),
                                                    "Couldnt find layer object for %s",
                                                    snapshot->getDebugString().c_str());
                    Layer* legacyLayer = (it == mLegacyLayers.end()) ? nullptr : it->second.get();
+1 −0
Original line number Diff line number Diff line
@@ -438,6 +438,7 @@ TransactionTracing::createStartingStateProtoLocked() {
    for (auto& [layerStack, displayInfo] : mStartingDisplayInfos) {
        entryProto.mutable_displays()->Add(mProtoParser.toProto(displayInfo, layerStack.id));
    }
    entryProto.set_displays_changed(true);

    return entryProto;
}
+4 −0
Original line number Diff line number Diff line
@@ -214,6 +214,7 @@ TEST_F(TransactionTracingLayerHandlingTest, addStartingState) {
    EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(0).z(), 42);
    EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(1).layer_id(), mChildLayerId);
    EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(1).z(), 43);
    EXPECT_TRUE(proto.entry(0).displays_changed());
}

TEST_F(TransactionTracingLayerHandlingTest, updateStartingState) {
@@ -224,6 +225,7 @@ TEST_F(TransactionTracingLayerHandlingTest, updateStartingState) {
    perfetto::protos::TransactionTraceFile proto = writeToProto();
    // verify starting states are updated correctly
    EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(0).z(), 41);
    EXPECT_TRUE(proto.entry(0).displays_changed());
}

TEST_F(TransactionTracingLayerHandlingTest, removeStartingState) {
@@ -235,6 +237,7 @@ TEST_F(TransactionTracingLayerHandlingTest, removeStartingState) {
    // verify the child layer has been removed from the trace
    EXPECT_EQ(proto.entry(0).transactions(0).layer_changes().size(), 1);
    EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(0).layer_id(), mParentLayerId);
    EXPECT_TRUE(proto.entry(0).displays_changed());
}

TEST_F(TransactionTracingLayerHandlingTest, startingStateSurvivesBufferFlush) {
@@ -254,6 +257,7 @@ TEST_F(TransactionTracingLayerHandlingTest, startingStateSurvivesBufferFlush) {
    // verify we still have the parent layer state
    EXPECT_EQ(proto.entry(0).transactions(0).layer_changes().size(), 1);
    EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(0).layer_id(), mParentLayerId);
    EXPECT_TRUE(proto.entry(0).displays_changed());
}

class TransactionTracingMirrorLayerTest : public TransactionTracingTest {