diff options
| -rw-r--r-- | libs/binder/trusty/binderRpcTest/rules.mk | 4 | ||||
| -rw-r--r-- | services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp | 6 | ||||
| -rw-r--r-- | services/surfaceflinger/FrontEnd/LayerCreationArgs.cpp | 19 | ||||
| -rw-r--r-- | services/surfaceflinger/FrontEnd/LayerCreationArgs.h | 1 | ||||
| -rw-r--r-- | services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp | 6 | ||||
| -rw-r--r-- | services/surfaceflinger/FrontEnd/LayerLifecycleManager.h | 6 | ||||
| -rw-r--r-- | services/surfaceflinger/Tracing/TransactionTracing.cpp | 1 | ||||
| -rw-r--r-- | services/surfaceflinger/Tracing/tools/LayerTraceGenerator.cpp | 23 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp | 58 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/tracing/testdata/layers_trace_b275630566.winscope | bin | 0 -> 46969 bytes | |||
| -rw-r--r-- | services/surfaceflinger/tests/tracing/testdata/transactions_trace_b275630566.winscope | bin | 0 -> 552698 bytes |
11 files changed, 86 insertions, 38 deletions
diff --git a/libs/binder/trusty/binderRpcTest/rules.mk b/libs/binder/trusty/binderRpcTest/rules.mk index ae3949246d..975f689d1a 100644 --- a/libs/binder/trusty/binderRpcTest/rules.mk +++ b/libs/binder/trusty/binderRpcTest/rules.mk @@ -32,4 +32,8 @@ MODULE_LIBRARY_DEPS += \ trusty/user/base/lib/googletest \ trusty/user/base/lib/libstdc++-trusty \ +# TEST_P tests from binderRpcUniversalTests.cpp don't get linked in +# unless we pass in --whole-archive to the linker (b/275620340). +MODULE_USE_WHOLE_ARCHIVE := true + include make/trusted_app.mk diff --git a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp index bd2680fbb5..f28bfd44cd 100644 --- a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp +++ b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp @@ -1547,6 +1547,8 @@ void AidlComposer::onHotplugDisconnect(Display display) { } bool AidlComposer::hasMultiThreadedPresentSupport(Display display) { +#if 0 + // TODO (b/259132483): Reenable const auto displayId = translate<int64_t>(display); std::vector<AidlDisplayCapability> capabilities; const auto status = mAidlComposerClient->getDisplayCapabilities(displayId, &capabilities); @@ -1556,6 +1558,10 @@ bool AidlComposer::hasMultiThreadedPresentSupport(Display display) { } return std::find(capabilities.begin(), capabilities.end(), AidlDisplayCapability::MULTI_THREADED_PRESENT) != capabilities.end(); +#else + (void) display; + return false; +#endif } void AidlComposer::addReader(Display display) { diff --git a/services/surfaceflinger/FrontEnd/LayerCreationArgs.cpp b/services/surfaceflinger/FrontEnd/LayerCreationArgs.cpp index ce21233424..6af352c9f4 100644 --- a/services/surfaceflinger/FrontEnd/LayerCreationArgs.cpp +++ b/services/surfaceflinger/FrontEnd/LayerCreationArgs.cpp @@ -74,4 +74,23 @@ LayerCreationArgs LayerCreationArgs::fromOtherArgs(const LayerCreationArgs& othe return LayerCreationArgs(other.flinger, other.client, other.name, other.flags, other.metadata); } +std::string LayerCreationArgs::getDebugString() const { + std::stringstream stream; + stream << "LayerCreationArgs{" << name << "[" << sequence << "] flags=" << flags + << " pid=" << ownerPid << " uid=" << ownerUid; + if (addToRoot) { + stream << " addToRoot=" << addToRoot; + } + if (parentId != UNASSIGNED_LAYER_ID) { + stream << " parentId=" << parentId; + } + if (layerIdToMirror != UNASSIGNED_LAYER_ID) { + stream << " layerIdToMirror=" << layerIdToMirror; + } + if (layerStackToMirror != ui::INVALID_LAYER_STACK) { + stream << " layerStackToMirror=" << layerStackToMirror.id; + } + return stream.str(); +} + } // namespace android::surfaceflinger diff --git a/services/surfaceflinger/FrontEnd/LayerCreationArgs.h b/services/surfaceflinger/FrontEnd/LayerCreationArgs.h index 011250c52d..3a0fc6d7a3 100644 --- a/services/surfaceflinger/FrontEnd/LayerCreationArgs.h +++ b/services/surfaceflinger/FrontEnd/LayerCreationArgs.h @@ -44,6 +44,7 @@ struct LayerCreationArgs { bool internalLayer = false); LayerCreationArgs(std::optional<uint32_t> id, bool internalLayer = false); LayerCreationArgs() = default; // for tracing + std::string getDebugString() const; android::SurfaceFlinger* flinger; sp<android::Client> client; diff --git a/services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp b/services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp index 3706225228..33d9dbe796 100644 --- a/services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp +++ b/services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp @@ -164,7 +164,8 @@ void LayerLifecycleManager::onHandlesDestroyed(const std::vector<uint32_t>& dest } } -void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState>& transactions) { +void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState>& transactions, + bool ignoreUnknownLayers) { for (const auto& transaction : transactions) { for (const auto& resolvedComposerState : transaction.states) { const auto& clientState = resolvedComposerState.state; @@ -176,7 +177,8 @@ void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState RequestedLayerState* layer = getLayerFromId(layerId); if (layer == nullptr) { - LOG_ALWAYS_FATAL("%s Layer with layerid=%d not found", __func__, layerId); + LOG_ALWAYS_FATAL_IF(!ignoreUnknownLayers, "%s Layer with layerid=%d not found", + __func__, layerId); continue; } diff --git a/services/surfaceflinger/FrontEnd/LayerLifecycleManager.h b/services/surfaceflinger/FrontEnd/LayerLifecycleManager.h index 3d9a74c843..f258678598 100644 --- a/services/surfaceflinger/FrontEnd/LayerLifecycleManager.h +++ b/services/surfaceflinger/FrontEnd/LayerLifecycleManager.h @@ -39,7 +39,11 @@ class LayerLifecycleManager { public: // External state changes should be updated in the following order: void addLayers(std::vector<std::unique_ptr<RequestedLayerState>>); - void applyTransactions(const std::vector<TransactionState>&); + // Ignore unknown layers when interoping with legacy front end. In legacy we destroy + // the layers it is unreachable. When using the LayerLifecycleManager for layer trace + // generation we may encounter layers which are known because we don't have an explicit + // lifecycle. Ignore these errors while we have to interop with legacy. + void applyTransactions(const std::vector<TransactionState>&, bool ignoreUnknownLayers = false); // 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. diff --git a/services/surfaceflinger/Tracing/TransactionTracing.cpp b/services/surfaceflinger/Tracing/TransactionTracing.cpp index 26ed878396..87a633fc9d 100644 --- a/services/surfaceflinger/Tracing/TransactionTracing.cpp +++ b/services/surfaceflinger/Tracing/TransactionTracing.cpp @@ -271,6 +271,7 @@ void TransactionTracing::updateStartingStateLocked( for (const proto::LayerState& layerState : transaction.layer_changes()) { auto it = mStartingStates.find(layerState.layer_id()); if (it == mStartingStates.end()) { + // TODO(b/238781169) make this log fatal when we switch over to using new fe ALOGW("Could not find layer id %d", layerState.layer_id()); continue; } diff --git a/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.cpp b/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.cpp index 4b4ce1891f..55004c5e70 100644 --- a/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.cpp +++ b/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.cpp @@ -14,14 +14,6 @@ * limitations under the License. */ -#include <ios> -#include <memory> -#include <vector> -#include "FrontEnd/LayerCreationArgs.h" -#include "FrontEnd/RequestedLayerState.h" -#include "Tracing/LayerTracing.h" -#include "TransactionState.h" -#include "cutils/properties.h" #undef LOG_TAG #define LOG_TAG "LayerTraceGenerator" //#define LOG_NDEBUG 0 @@ -33,8 +25,15 @@ #include <utils/String16.h> #include <filesystem> #include <fstream> +#include <ios> #include <string> +#include <vector> +#include "FrontEnd/LayerCreationArgs.h" +#include "FrontEnd/RequestedLayerState.h" #include "LayerProtoHelper.h" +#include "Tracing/LayerTracing.h" +#include "TransactionState.h" +#include "cutils/properties.h" #include "LayerTraceGenerator.h" @@ -84,6 +83,7 @@ bool LayerTraceGenerator::generate(const proto::TransactionTraceFile& traceFile, for (int j = 0; j < entry.added_layers_size(); j++) { LayerCreationArgs args; parser.fromProto(entry.added_layers(j), args); + ALOGV(" %s", args.getDebugString().c_str()); addedLayers.emplace_back(std::make_unique<frontend::RequestedLayerState>(args)); } @@ -105,9 +105,14 @@ bool LayerTraceGenerator::generate(const proto::TransactionTraceFile& traceFile, transactions.emplace_back(std::move(transaction)); } + for (int j = 0; j < entry.destroyed_layers_size(); j++) { + ALOGV(" destroyedHandles=%d", entry.destroyed_layers(j)); + } + std::vector<uint32_t> destroyedHandles; destroyedHandles.reserve((size_t)entry.destroyed_layer_handles_size()); for (int j = 0; j < entry.destroyed_layer_handles_size(); j++) { + ALOGV(" destroyedHandles=%d", entry.destroyed_layer_handles(j)); destroyedHandles.push_back(entry.destroyed_layer_handles(j)); } @@ -118,7 +123,7 @@ bool LayerTraceGenerator::generate(const proto::TransactionTraceFile& traceFile, // apply updates lifecycleManager.addLayers(std::move(addedLayers)); - lifecycleManager.applyTransactions(transactions); + lifecycleManager.applyTransactions(transactions, /*ignoreUnknownHandles=*/true); lifecycleManager.onHandlesDestroyed(destroyedHandles, /*ignoreUnknownHandles=*/true); if (lifecycleManager.getGlobalChanges().test( diff --git a/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp b/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp index 3e3d8f0206..2b295309e7 100644 --- a/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp +++ b/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp @@ -148,42 +148,48 @@ static LayerInfo getLayerInfoFromProto(::android::surfaceflinger::LayerProto& pr touchableRegionBounds}; } -TEST_P(TransactionTraceTestSuite, validateEndState) { - ASSERT_GT(mActualLayersTraceProto.entry_size(), 0); - ASSERT_GT(mExpectedLayersTraceProto.entry_size(), 0); - - auto expectedLastEntry = - mExpectedLayersTraceProto.entry(mExpectedLayersTraceProto.entry_size() - 1); - auto actualLastEntry = mActualLayersTraceProto.entry(mActualLayersTraceProto.entry_size() - 1); - - EXPECT_EQ(expectedLastEntry.layers().layers_size(), actualLastEntry.layers().layers_size()); - - std::vector<LayerInfo> expectedLayers; - expectedLayers.reserve(static_cast<size_t>(expectedLastEntry.layers().layers_size())); - for (int i = 0; i < expectedLastEntry.layers().layers_size(); i++) { - auto layer = expectedLastEntry.layers().layers(i); - LayerInfo layerInfo = getLayerInfoFromProto(layer); - expectedLayers.push_back(layerInfo); - } - std::sort(expectedLayers.begin(), expectedLayers.end(), compareById); - +static std::vector<LayerInfo> getLayerInfosFromProto( + android::surfaceflinger::LayersTraceProto& entry) { std::unordered_map<int32_t /* snapshotId*/, int32_t /*layerId*/> snapshotIdToLayerId; - std::vector<LayerInfo> actualLayers; - actualLayers.reserve(static_cast<size_t>(actualLastEntry.layers().layers_size())); - for (int i = 0; i < actualLastEntry.layers().layers_size(); i++) { - auto layer = actualLastEntry.layers().layers(i); + std::vector<LayerInfo> layers; + layers.reserve(static_cast<size_t>(entry.layers().layers_size())); + bool mapSnapshotIdToLayerId = false; + for (int i = 0; i < entry.layers().layers_size(); i++) { + auto layer = entry.layers().layers(i); LayerInfo layerInfo = getLayerInfoFromProto(layer); + snapshotIdToLayerId[layerInfo.id] = static_cast<int32_t>(layer.original_id()); - actualLayers.push_back(layerInfo); + if (layer.original_id() != 0) { + mapSnapshotIdToLayerId = true; + } + layers.push_back(layerInfo); } + std::sort(layers.begin(), layers.end(), compareById); - for (auto& layer : actualLayers) { + if (!mapSnapshotIdToLayerId) { + return layers; + } + for (auto& layer : layers) { layer.id = snapshotIdToLayerId[layer.id]; auto it = snapshotIdToLayerId.find(layer.parent); layer.parent = it == snapshotIdToLayerId.end() ? -1 : it->second; } + return layers; +} + +TEST_P(TransactionTraceTestSuite, validateEndState) { + ASSERT_GT(mActualLayersTraceProto.entry_size(), 0); + ASSERT_GT(mExpectedLayersTraceProto.entry_size(), 0); + + auto expectedLastEntry = + mExpectedLayersTraceProto.entry(mExpectedLayersTraceProto.entry_size() - 1); + auto actualLastEntry = mActualLayersTraceProto.entry(mActualLayersTraceProto.entry_size() - 1); + + EXPECT_EQ(expectedLastEntry.layers().layers_size(), actualLastEntry.layers().layers_size()); - std::sort(actualLayers.begin(), actualLayers.end(), compareById); + std::vector<LayerInfo> expectedLayers = getLayerInfosFromProto(expectedLastEntry); + std::vector<LayerInfo> actualLayers = getLayerInfosFromProto(actualLastEntry); + ; size_t i = 0; for (; i < actualLayers.size() && i < expectedLayers.size(); i++) { diff --git a/services/surfaceflinger/tests/tracing/testdata/layers_trace_b275630566.winscope b/services/surfaceflinger/tests/tracing/testdata/layers_trace_b275630566.winscope Binary files differnew file mode 100644 index 0000000000..fe504d741b --- /dev/null +++ b/services/surfaceflinger/tests/tracing/testdata/layers_trace_b275630566.winscope diff --git a/services/surfaceflinger/tests/tracing/testdata/transactions_trace_b275630566.winscope b/services/surfaceflinger/tests/tracing/testdata/transactions_trace_b275630566.winscope Binary files differnew file mode 100644 index 0000000000..6f7ba15421 --- /dev/null +++ b/services/surfaceflinger/tests/tracing/testdata/transactions_trace_b275630566.winscope |