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

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

Merge changes I355502fb,I3ba9004e,Ibeb4118b into main

* changes:
  [sf] Set visible regions change flag when layer starts drawing
  [sf] Add traces with log fatals
  [sf] Add TransactionTraceWriterTests
parents 8da3c4bb 854ce1c4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -265,6 +265,7 @@ struct layer_state_t {
    // Changes affecting child states.
    static constexpr uint64_t AFFECTS_CHILDREN = layer_state_t::GEOMETRY_CHANGES |
            layer_state_t::HIERARCHY_CHANGES | layer_state_t::eAlphaChanged |
            layer_state_t::eBackgroundBlurRadiusChanged | layer_state_t::eBlurRegionsChanged |
            layer_state_t::eColorTransformChanged | layer_state_t::eCornerRadiusChanged |
            layer_state_t::eFlagsChanged | layer_state_t::eTrustedOverlayChanged |
            layer_state_t::eFrameRateChanged | layer_state_t::eFrameRateSelectionPriority |
+9 −15
Original line number Diff line number Diff line
@@ -60,9 +60,9 @@ void LayerHierarchy::traverse(const Visitor& visitor,
            return;
        }
    }
    if (traversalPath.hasRelZLoop()) {
        LOG_ALWAYS_FATAL("Found relative z loop layerId:%d", traversalPath.invalidRelativeRootId);
    }

    LLOG_ALWAYS_FATAL_WITH_TRACE_IF(traversalPath.hasRelZLoop(), "Found relative z loop layerId:%d",
                                    traversalPath.invalidRelativeRootId);
    for (auto& [child, childVariant] : mChildren) {
        ScopedAddToTraversalPath addChildToTraversalPath(traversalPath, child->mLayer->id,
                                                         childVariant);
@@ -104,9 +104,7 @@ void LayerHierarchy::removeChild(LayerHierarchy* child) {
                           [child](const std::pair<LayerHierarchy*, Variant>& x) {
                               return x.first == child;
                           });
    if (it == mChildren.end()) {
        LOG_ALWAYS_FATAL("Could not find child!");
    }
    LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mChildren.end(), "Could not find child!");
    mChildren.erase(it);
}

@@ -119,12 +117,9 @@ void LayerHierarchy::updateChild(LayerHierarchy* hierarchy, LayerHierarchy::Vari
                           [hierarchy](std::pair<LayerHierarchy*, Variant>& child) {
                               return child.first == hierarchy;
                           });
    if (it == mChildren.end()) {
        LOG_ALWAYS_FATAL("Could not find child!");
    } else {
    LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mChildren.end(), "Could not find child!");
    it->second = variant;
}
}

const RequestedLayerState* LayerHierarchy::getLayer() const {
    return mLayer;
@@ -422,9 +417,8 @@ LayerHierarchy LayerHierarchyBuilder::getPartialHierarchy(uint32_t layerId,
LayerHierarchy* LayerHierarchyBuilder::getHierarchyFromId(uint32_t layerId, bool crashOnFailure) {
    auto it = mLayerIdToHierarchy.find(layerId);
    if (it == mLayerIdToHierarchy.end()) {
        if (crashOnFailure) {
            LOG_ALWAYS_FATAL("Could not find hierarchy for layer id %d", layerId);
        }
        LLOG_ALWAYS_FATAL_WITH_TRACE_IF(crashOnFailure, "Could not find hierarchy for layer id %d",
                                        layerId);
        return nullptr;
    };

@@ -460,7 +454,7 @@ std::string LayerHierarchy::TraversalPath::toString() const {
}

LayerHierarchy::TraversalPath LayerHierarchy::TraversalPath::getMirrorRoot() const {
    LOG_ALWAYS_FATAL_IF(!isClone(), "Cannot get mirror root of a non cloned node");
    LLOG_ALWAYS_FATAL_WITH_TRACE_IF(!isClone(), "Cannot get mirror root of a non cloned node");
    TraversalPath mirrorRootPath = *this;
    mirrorRootPath.id = mirrorRootId;
    return mirrorRootPath;
+25 −28
Original line number Diff line number Diff line
@@ -45,11 +45,11 @@ void LayerLifecycleManager::addLayers(std::vector<std::unique_ptr<RequestedLayer
    for (auto& newLayer : newLayers) {
        RequestedLayerState& layer = *newLayer.get();
        auto [it, inserted] = mIdToLayer.try_emplace(layer.id, References{.owner = layer});
        if (!inserted) {
            LOG_ALWAYS_FATAL("Duplicate layer id found. New layer: %s Existing layer: %s",
        LLOG_ALWAYS_FATAL_WITH_TRACE_IF(!inserted,
                                        "Duplicate layer id found. New layer: %s Existing layer: "
                                        "%s",
                                        layer.getDebugString().c_str(),
                                        it->second.owner.getDebugString().c_str());
        }
        mAddedLayers.push_back(newLayer.get());
        mChangedLayers.push_back(newLayer.get());
        layer.parentId = linkLayer(layer.parentId, layer.id);
@@ -85,14 +85,15 @@ void LayerLifecycleManager::addLayers(std::vector<std::unique_ptr<RequestedLayer
    }
}

void LayerLifecycleManager::onHandlesDestroyed(const std::vector<uint32_t>& destroyedHandles,
void LayerLifecycleManager::onHandlesDestroyed(
        const std::vector<std::pair<uint32_t, std::string /* debugName */>>& destroyedHandles,
        bool ignoreUnknownHandles) {
    std::vector<uint32_t> layersToBeDestroyed;
    for (const auto& layerId : destroyedHandles) {
    for (const auto& [layerId, name] : destroyedHandles) {
        auto it = mIdToLayer.find(layerId);
        if (it == mIdToLayer.end()) {
            LOG_ALWAYS_FATAL_IF(!ignoreUnknownHandles, "%s Layerid not found %d", __func__,
                                layerId);
            LLOG_ALWAYS_FATAL_WITH_TRACE_IF(!ignoreUnknownHandles, "%s Layerid not found %s[%d]",
                                            __func__, name.c_str(), layerId);
            continue;
        }
        RequestedLayerState& layer = it->second.owner;
@@ -113,10 +114,8 @@ void LayerLifecycleManager::onHandlesDestroyed(const std::vector<uint32_t>& dest
    for (size_t i = 0; i < layersToBeDestroyed.size(); i++) {
        uint32_t layerId = layersToBeDestroyed[i];
        auto it = mIdToLayer.find(layerId);
        if (it == mIdToLayer.end()) {
            LOG_ALWAYS_FATAL("%s Layer with id %d not found", __func__, layerId);
            continue;
        }
        LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mIdToLayer.end(), "%s Layer with id %d not found",
                                        __func__, layerId);

        RequestedLayerState& layer = it->second.owner;

@@ -135,11 +134,9 @@ void LayerLifecycleManager::onHandlesDestroyed(const std::vector<uint32_t>& dest
        auto& references = it->second.references;
        for (uint32_t linkedLayerId : references) {
            RequestedLayerState* linkedLayer = getLayerFromId(linkedLayerId);
            if (!linkedLayer) {
                LOG_ALWAYS_FATAL("%s Layerid reference %d not found for %d", __func__,
            LLOG_ALWAYS_FATAL_WITH_TRACE_IF(!linkedLayer,
                                            "%s Layerid reference %d not found for %d", __func__,
                                            linkedLayerId, layer.id);
                continue;
            };
            if (linkedLayer->parentId == layer.id) {
                linkedLayer->parentId = UNASSIGNED_LAYER_ID;
                if (linkedLayer->canBeDestroyed()) {
@@ -191,17 +188,17 @@ void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState

            RequestedLayerState* layer = getLayerFromId(layerId);
            if (layer == nullptr) {
                LOG_ALWAYS_FATAL_IF(!ignoreUnknownLayers, "%s Layer with layerid=%d not found",
                                    __func__, layerId);
                LLOG_ALWAYS_FATAL_WITH_TRACE_IF(!ignoreUnknownLayers,
                                                "%s Layer with layerid=%d not found", __func__,
                                                layerId);
                continue;
            }

            if (!layer->handleAlive) {
                LOG_ALWAYS_FATAL("%s Layer's with layerid=%d) is not alive. Possible out of "
            LLOG_ALWAYS_FATAL_WITH_TRACE_IF(!layer->handleAlive,
                                            "%s Layer's with layerid=%d) is not alive. Possible "
                                            "out of "
                                            "order LayerLifecycleManager updates",
                                            __func__, layerId);
                continue;
            }

            if (layer->changes.get() == 0) {
                mChangedLayers.push_back(layer);
@@ -241,7 +238,7 @@ void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState
                    RequestedLayerState* bgColorLayer = getLayerFromId(layer->bgColorLayerId);
                    layer->bgColorLayerId = UNASSIGNED_LAYER_ID;
                    bgColorLayer->parentId = unlinkLayer(bgColorLayer->parentId, bgColorLayer->id);
                    onHandlesDestroyed({bgColorLayer->id});
                    onHandlesDestroyed({{bgColorLayer->id, bgColorLayer->debugName}});
                } else if (layer->bgColorLayerId != UNASSIGNED_LAYER_ID) {
                    RequestedLayerState* bgColorLayer = getLayerFromId(layer->bgColorLayerId);
                    bgColorLayer->color = layer->bgColor;
+2 −1
Original line number Diff line number Diff line
@@ -47,7 +47,8 @@ public:
    // Ignore unknown handles when iteroping with legacy front end. In the old world, we
    // would create child layers which are not necessary with the new front end. This means
    // we will get notified for handle changes that don't exist in the new front end.
    void onHandlesDestroyed(const std::vector<uint32_t>&, bool ignoreUnknownHandles = false);
    void onHandlesDestroyed(const std::vector<std::pair<uint32_t, std::string /* debugName */>>&,
                            bool ignoreUnknownHandles = false);

    // Detaches the layer from its relative parent to prevent a loop in the
    // layer hierarchy. This overrides the RequestedLayerState and leaves
+16 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#pragma once

#include "Tracing/TransactionTracing.h"

// Uncomment to trace layer updates for a single layer
// #define LOG_LAYER 1

@@ -27,3 +29,17 @@
#endif

#define LLOGD(LAYER_ID, x, ...) ALOGD("[%d] %s " x, (LAYER_ID), __func__, ##__VA_ARGS__);

#define LLOG_ALWAYS_FATAL_WITH_TRACE(...)                                               \
    do {                                                                                \
        TransactionTraceWriter::getInstance().invoke(__func__, /* overwrite= */ false); \
        LOG_ALWAYS_FATAL(##__VA_ARGS__);                                                \
    } while (false)

#define LLOG_ALWAYS_FATAL_WITH_TRACE_IF(cond, ...)                                          \
    do {                                                                                    \
        if (__predict_false(cond)) {                                                        \
            TransactionTraceWriter::getInstance().invoke(__func__, /* overwrite= */ false); \
        }                                                                                   \
        LOG_ALWAYS_FATAL_IF(cond, ##__VA_ARGS__);                                           \
    } while (false)
 No newline at end of file
Loading