summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/Tracing
AgeCommit message (Collapse)Author
2025-03-20Revert^2 "Use TransactionState in SurfaceFlinger." Anton Ivanov
This reverts commit 4f8b4f371947dce3abece1c0d64af0b5c990e0c2. Reason for revert: Rolling forward with fix for use-after-move in SurfaceFlinger::setTransactionState Flag: EXEMPT refactor Bug: 385156191 Test: presubmit Change-Id: I66d45b1e125dcb50cbe7a3cfcefa8eaa02705419
2025-03-17Revert "Use TransactionState in SurfaceFlinger." Anton Ivanov
This reverts commit ed63243743079eb4531cb4a9e5ed4dccb7965d6d. Reason for revert: Droidmonitor created revert due to Jank regression b/403375000. Change-Id: I558338084124764026028b21667b45afb73b9e06
2025-03-11Use TransactionState in SurfaceFlinger. Anton Ivanov
Eliminates code duplication and unnecessary copies of state components. Flag: EXEMPT refactor Bug: 385156191 Test: presubmit Change-Id: Ic57f3203d94f41cd1a97014a546c1852d9b5f390
2025-03-03Provide classes that logically make up a transaction with == and !=. Anton Ivanov
Primarily this change is intended to support writing test assertions. As a side effect, make some improvements to encapsulation of members. Flag: EXEMPT refactor Bug: 385156191 Test: presubmit Change-Id: I51352c78ccfcb0fc6bff655593d7d31771516668
2024-12-19Rename TransactionState to QueuedTransactionState Vishnu Nair
Clean up some of the logic tracking transaction state on the client. This will help with some of the upcoming optimizations, remove some duplicate parceling code and clean up the interface into SF. Flag: EXEMPT refactor Bug: 385156191 Test: presubmit Change-Id: I701138535000af921e8e026855cd420ff5c8aeea
2024-12-10Create SessionManager in ADPF PowerAdvisor Matt Buckley
Adds the "SessionManager" class, which tracks data associating layers with specific sessions to create updates for the Power HAL when frame composition occurs. It also keeps track of which layers are currently "relevant" and associated with at least one active session to streamline data collection. Flag: com.android.graphics.surfaceflinger.flags.adpf_native_session_manager Bug: 360908317 Bug: 367803904 Test: atest libsurfaceflinger_unittest Change-Id: Ic3a4df9b13a2acd9077c6ba2bc9bbe02088e214d
2024-10-04Merge "Support floating point values for layer crop" into main Vishnu Nair
2024-10-03Support floating point values for layer crop Vishnu Nair
Flag: EXEMPT bug fix Fixes: 310950423 Test: presubmit Change-Id: I05feb4881a95bc8caad90a3d632b3c7881909bf3
2024-09-27Merge "Fix deadlock of main thread and Perfetto thread ↵ Treehugger Robot
(LayerDataSource::OnStart)" into main
2024-08-16Include offscreen layers in generated trace Vishnu Nair
Flag: EXEMPT bugfix Bug: 359854186 Test: winscope Change-Id: Ia8572b4df1ac2921af3c4c686fc75062e1544c8c
2024-08-12Merge "surfaceflinger: Remove unnecessary std::move" into main am: ↵ Treehugger Robot
c36f1c1018 am: 47612c1b2c Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/3213370 Change-Id: I531a77985a67693998fe0f4084d20220bf74971e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-08-12Merge "surfaceflinger: Remove unnecessary std::move" into main am: c36f1c1018 Treehugger Robot
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/3213370 Change-Id: I9e2f995907709025e5ed178fa2ec74165c0c17f4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-08-12surfaceflinger: Remove unnecessary std::move Yi Kong
Moving a temporary object prevents copy elision, and could reduce performance. This fixes -Wpessimizing-move compiler warning. Test: presubmit Bug: 154270751 Change-Id: I745e7dbcbde53eed95111e78d1251bea43b3869f
2024-07-12Modify sftrace macros to go through tracing_perfetto lib Vishnu Nair
If the perfetto trace events are not registered, the library will default to the previous atrace calls. We will enable the perfetto registration with the aconfig flag perfetto_sdk_tracing. Flag: android.os.perfetto_sdk_tracing Bug: 349905670 Test: perfetto Change-Id: I04c3c0d09f36c95b7ac90ffa06b8be3428ddc950
2024-06-28Create a wrapper for atrace macros Vishnu Nair
Create a SF specific macro to call into atrace. This will make the switch to perfetto for capturing atrace tags easier. Flag: EXEMPT refactor Bug: 349905670 Test: perfetto Change-Id: I4d046d837f52ef78b08e3c97556f2eddb06232dd
2024-05-29Pass dequeue timestamp along with buffer data Nergi Rahardi
Avoids performance penalties associated with metadata. Bug: 342174822 Test: atest libsurfaceflinger_unittest Test: Manually verified dequeueTime sent without triggering metadata change Change-Id: Ifed747818ea252b2551780ffcefd3309eb41edbe
2024-05-24Merge Android 24Q2 Release (ab/11526283) to aosp-main-future Xin Li
Bug: 337098550 Merged-In: I8d975b81afd2cde1d543e8bc7e730a6e42393bec Change-Id: I714982d2b0df34afc9f9729deb2636de5d0c7b64
2024-05-22Allow child layers to unset trusted overlay state 2/2 Vishnu Nair
Test: presubmit Bug: 339701674 Change-Id: I1a94b5e5dc1fa64a9e1eb3330b5c5b03af8d2b16
2024-05-09Use a strongly typed LogicalDisplayId for displayId(2/n) Linnan Li
Currently, we use int32_t for displayId, which is not a safe type, and it may also lead to misdefinition of types. Here, we introduce LogicalDisplayId as a strong type for displayId and move all contents of constants.h into LogicalDisplayId.h. Bug: 339106983 Test: atest inputflinger_tests Test: atest InputTests Test: m checkinput Test: m libsurfaceflinger_unittest Test: presubmit Change-Id: If44e56f69553d095af5adb59b595e4a852ab32ce Signed-off-by: Linnan Li <lilinnan@xiaomi.corp-partner.google.com>
2024-03-18Merge "Add missing header." into main am: 67f54a8de6 am: a9177b3cdf Treehugger Robot
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/3000924 Change-Id: I73c8b65b5a711212c5a3dcd8ec142dac7cead5b9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-15Add missing header. Krzysztof Kosiński
Protobuf 22.x no longer pulls in <set>, it needs to be included explicitly. Bug: 329747255 Test: presubmit Change-Id: I8c0b219322b10a655d5687c506d1047ddb8aa99e
2024-02-21Add default_teams John Reck
Test: n/a Change-Id: I6c2426303194df4b94f6181f4b5c71970bc5f7fd
2023-12-21Fix deadlock of main thread and Perfetto thread (LayerDataSource::OnStart) Kean Mariotti
The deadly embrace used to happen in this situation: 1. Perfetto shmem buffer full. 2. Main thread blocked while writing into shmem buffer (active tracing), i.e. main thread waiting for Perfetto thread to signal available shmem chunks. 3. LayerDataSource::OnStart with MODE_DUMP (executed by Perfetto thread) waiting for main thread to capture a layers snapshot. This commit removes the capture of layers snapshot in OnStart. Now OnStop (Perfetto thread) triggers the layers snapshot capture to be performed by the main thread. However, the Perfetto thread doesn't wait for the main thread to complete the capture. The actual stop of the tracing session is deferred and signalled later by the main thread through LayerDataSource::StopArgs::HandleStopAsynchronously() when the capture is complete. Fix: b/313130597 Test: reproduced the issue forcing the main thread to write 100MB into the shmem buffer: mLayerTracing.setTakeLayersSnapshotProtoFunction([&](uint32_t traceFlags) { auto snapshot = perfetto::protos::LayersSnapshotProto{}; mScheduler ->schedule([&]() FTL_FAKE_GUARD(mStateLock) FTL_FAKE_GUARD(kMainThreadContext) { snapshot = takeLayersSnapshotProto(traceFlags, TimePoint::now(), mLastCommittedVsyncId, true); + LayerDataSource::Trace([&](LayerDataSource::TraceContext context) { + auto packet = context.NewTracePacket(); + packet->set_timestamp(0); + packet->set_timestamp_clock_id(perfetto::protos::pbzero::BUILTIN_CLOCK_MONOTONIC); + auto* snapshotProto = packet->set_surfaceflinger_layers_snapshot(); + + auto data = std::string(100000000, 0xaa); + snapshotProto->AppendRawProtoBytes(data.data(), data.size()); + }); }) .wait(); return snapshot; }); Change-Id: Iea253da2a420d186d092521597f4783e5c8d157d
2023-12-18Merge "Avoid capturing always on tracing when generating layers trace" into main Vishnu Nair
2023-12-18Avoid capturing always on tracing when generating layers trace Vishnu Nair
When we encounter unexpected states, we write the always on transaction traces to disk so we can investigate and fix these issues in the field. The states also occur when we generate layers trace since we use the same logic to replay back the transactions. In this case we want to avoid writing the trace to disk. This is only an issue with the perfetto backend since it converts the traces in process. Test: presubmit Fixes: 316896588 Change-Id: I8729328c556f5c0575ac8879d51529cc51259bac
2023-12-18Merge "Detect and recover from relative z loops" into main Vishnu Nair
2023-12-16Detect and recover from relative z loops Vishnu Nair
The caller can create loops in the hierarchy by relatively reparenting layers to each other. This can be done directly or via a chain of layers. The logic to detect and fix this was not being called. Fix this by making loop detection a bit harder to ignore and part of hierarchy builder's update call. Test: presubmit Bug: 316236833 Change-Id: I484f9b8e2742fef22a5d76362a715eb6850c26f6
2023-12-08Add displays to the first tracing entry Vishnu Nair
We were tracking and adding displays to the initial trace entry but we were not marking it as changed. This would cause us to omit the initial display states when generating the layers trace. Fixes: 298003513 Test: main/external/perfetto$ printproto --proto2 --proto protos/perfetto/trace/android/winscope.proto --resolve_protos --message perfetto.protos.TransactionTraceFile --raw_protocol_buffer transactions_trace.winscope --multiline | vi - Test: atest TransactionTracingTest Change-Id: I71d05b62d0cfd845e78b0b2b2350f3b9410d178f
2023-12-01Remove unnecessary atrace event Zim
We have some evidence to show that the atrace_call in addEntry is causing trace fd contention which affects binder calls like createSurface(). Remove this atrace event as its cost doesn't outweigh its value. Bug: 314305938 Test: Manual Change-Id: I3d86b788656bf9dd5bc62cd78a3afbdeefd9dbff
2023-10-27Merge changes from topic "sf-perfetto-bugreport-integration" into main Kean Mariotti
* changes: Adapt dumpstate to perfetto-based SurfaceFlinger tracing Add layer tracing's MODE_GENERATED_BUGREPORT_ONLY
2023-10-20Add layer tracing's MODE_GENERATED_BUGREPORT_ONLY Kean Mariotti
The generated layers trace can be quite large (100-400 MB), which is way above the perfetto's field upload budget. On the field (AOT) we want the layers trace to be generated only when a bugreport is taken and not when a perfetto's field upload happens. We achieve it as follows: - In the AOT configuration, enable the 'android.surfaceflinger_layers' data source with MODE_GENERATED_BUGREPORT_ONLY. - When LayerTracing receives perfetto's OnFlush event and MODE_GENERATED_BUGREPORT_ONLY is enabled, generate the layers trace only if the OnFlush event is due to a bugreport being taken: args.flush_flags.reason() == perfetto::FlushFlags::Reason::kTraceClone && args.flush_flags.clone_target() == perfetto::FlushFlags::CloneTarget::kBugreport In a test environment instead, we can use MODE_GENERATED to test the layers trace generation without having to take a bugreport. Bug: b/293429094 Test: 1. Manually start the perfetto's android.surfaceflinger_layers data source with MODE_GENERATED_BUGREPORT_ONLY setting a high bugreport_score (e.g. 50000) 2. Take a bugreport (adb bugreport) 3. Verify that FS/data/misc/perfetto-traces/bugreport/systrace.pftrace (in the bugreport) contains the generated layers trace. E.g. inspect bugreport with go/winscope. Change-Id: I5b3ce59cc762fd5a22170e677e48be987380c94e
2023-10-20Fix file permissions of generated layers trace Kean Mariotti
Fix: 305129514 Test: adb shell rm /data/misc/wmtrace/layers_trace_from_transactions.winscope \ && adb bugreport \ && check generated bugreport contains FS/data/misc/wmtrace/layers_trace_from_transactions.winscope Change-Id: I7cf087265df9ce1cc5da8536d6b03285685cd26e
2023-10-06Clean up duplicate shadow lengths in layer snapshot Vishnu Nair
The shadow length is currently tracked in both the LayerFE CompositionState and the shadow settings, which are used by the RenderEngine. We can consolidate these fields and track shadow settings in the LayerFE CompositionState. This makes sense because we want the LayerFE CompositionState to contain all relevant information that it can pass to the RenderEngine without calling back into the frontend. Bug: 302551905 Test: presubmit Change-Id: I583c43993cf73784c6fec9ec2d40f2c76d21adeb
2023-09-26Fix output stream creation in layertracegenerator Kean Mariotti
layertracegenerator creates the output layers trace file specifying std::ios::app (append mode). Meaning, if an output file already exists layertracegenerator appends the new layers trace to it. This commit solves the issue replacing std::ios::app with std::ios::out. Bug: 301539901 Test: execute multiple times \ adb shell layertracegenerator transaction.winscope test.winscope and make sure the size of test.winscope remains constant \ and doesn't increase after each execution of layertracegenerator Change-Id: I23bf4e689cee450b055a0451aa0301ce34131739
2023-09-21Do not create new LayerTracing instance within LayerTraceGenerator Kean Mariotti
LayerDataSource holds a reference to LayerTracing in order to notify LayerTracing about perfetto events (OnSetup, OnStart, OnFlush, OnStop). Having multiple instances of LayerTracing complicates things, as it arises the question of which instance(s) should be referenced and notified by LayerDataSource. This commit eliminates the problem at its root, by avoiding to create an extra LayerTracing instance within LayerTraceGenerator. Bug: b/293429094 Test: atest transactiontrace_testsuite && atest SurfaceFlinger_test Change-Id: Id2cf232d1198f9470b476d9a9d9eb86c21246c61
2023-09-21Change log level of key tracing events Kean Mariotti
Change log level (from verbose to debug) for the following tracing events: - tracing start - tracing stop - tracing flush to disk Bug: b/293429094 Test: N/A Change-Id: I54b18bd9b9ae2d418d42c9cf754cc266b1746ab5
2023-09-01Revert^2 Integrate transaction tracing with perfetto Kean Mariotti
Define the perfetto custom data source TransactionDataSource. TransactionDataSource is registered with perfetto and is used to listen to perfetto events (setup, start, stop, flush) and to write trace packets to perfetto. The user can configure/start/stop tracing via /system/bin/perfetto. Tracing can operate in the following modes. ACTIVE mode: The transactions ring buffer (starting state + following committed transactions) is written (only once) to perfetto when the 'start' event is received. Transactions are then written to perfetto each time they are committed. On the receiver side, the data source is to be configured to periodically flush data to disk providing a virtually infinite storage. CONTINUOUS mode: Listens to the perfetto 'flush' event (e.g. when a bugreport is taken). When a 'flush' event is received, the ring buffer (starting state + following committed transactions) hold by TransactionTracing is written to perfetto. On the receiver side, the data source is to be configured with a dedicated buffer large enough to store all the flushed data. Bug: b/284424784 Test: atest libsurfaceflinger_unittest && atest transactiontrace_testsuite Change-Id: I703ed53e71f442e2f6af7c4a638d2f847107167a
2023-09-01Revert^2 Integrate layer tracing with perfetto Kean Mariotti
Define the perfetto custom data source LayerDataSource. LayerDataSource is registered with perfetto. The data source is used to listen to perfetto events (setup, start, stop, flush) and to write trace packets to perfetto. The user can configure/start/stop tracing via /system/bin/perfetto. Tracing can operate in the following modes. ACTIVE mode: A layers snapshot is taken and written to perfetto for each vsyncid commit. GENERATED mode: Listens to the perfetto 'flush' event (e.g. when a bugreport is taken). When a 'flush' event is received, the ring buffer of transactions (hold by TransactionTracing) is processed by LayerTraceGenerator, a sequence of layers snapshots is generated and written to perfetto. DUMP mode: When the 'start' event is received a single layers snapshot is taken and written to perfetto. Bug: b/284424784 Test: atest libsurfaceflinger_unittest && atest transactiontrace_testsuite Change-Id: Ic1b10a040ec4533f0b56a4c8087c5a2898e3e34d
2023-09-01Revert^2 Move proto definitions to external/perfetto Kean Mariotti
This commit moves the layer and transaction .proto files to external/perfetto/protos/perfetto/trace/android/. Test: atest libsurfaceflinger_unittest && atest transactiontrace_testsuite Bug: b/284424784 Change-Id: Ia7e446c528d188c748a800fbf16ab3b8b9a7b9d1
2023-09-01Revert "Move proto definitions to external/perfetto" Diwas Sharma
This reverts commit bec51fdc3c8a42cbcb833d7d14800fbb0a14a7f3. Reason for revert: 298512106 Change-Id: Icb9d6d5a23176a809c3b71bcaa3928b03dfb0622
2023-09-01Revert "Integrate layer tracing with perfetto" Diwas Sharma
This reverts commit 22cbec5335e84a18ed913d3272609828e7c9c649. Reason for revert: 298512106 Change-Id: Ief74f64ace55cd3a2a802be5f8890654aa8c757d
2023-09-01Revert "Integrate transaction tracing with perfetto" Diwas Sharma
This reverts commit 8a5640ab9c305b2e03929f2255aabed3ec1b40b3. Reason for revert: 298512106 Change-Id: I0182c3b75d4b38580430c9ba6b94666e03d48efb
2023-08-28Integrate transaction tracing with perfetto Kean Mariotti
Define the perfetto custom data source TransactionDataSource. TransactionDataSource is registered with perfetto and is used to listen to perfetto events (setup, start, stop, flush) and to write trace packets to perfetto. The user can configure/start/stop tracing via /system/bin/perfetto. Tracing can operate in the following modes. ACTIVE mode: The transactions ring buffer (starting state + following committed transactions) is written (only once) to perfetto when the 'start' event is received. Transactions are then written to perfetto each time they are committed. On the receiver side, the data source is to be configured to periodically flush data to disk providing a virtually infinite storage. CONTINUOUS mode: Listens to the perfetto 'flush' event (e.g. when a bugreport is taken). When a 'flush' event is received, the ring buffer (starting state + following committed transactions) hold by TransactionTracing is written to perfetto. On the receiver side, the data source is to be configured with a dedicated buffer large enough to store all the flushed data. Bug: b/284424784 Test: atest libsurfaceflinger_unittest && atest transactiontrace_testsuite Change-Id: I342db500bf258b25aac071c1759b5de924df45dc
2023-08-28Integrate layer tracing with perfetto Kean Mariotti
Define the perfetto custom data source LayerDataSource. LayerDataSource is registered with perfetto. The data source is used to listen to perfetto events (setup, start, stop, flush) and to write trace packets to perfetto. The user can configure/start/stop tracing via /system/bin/perfetto. Tracing can operate in the following modes. ACTIVE mode: A layers snapshot is taken and written to perfetto for each vsyncid commit. GENERATED mode: Listens to the perfetto 'flush' event (e.g. when a bugreport is taken). When a 'flush' event is received, the ring buffer of transactions (hold by TransactionTracing) is processed by LayerTraceGenerator, a sequence of layers snapshots is generated and written to perfetto. DUMP mode: When the 'start' event is received a single layers snapshot is taken and written to perfetto. Bug: b/284424784 Test: atest libsurfaceflinger_unittest && atest transactiontrace_testsuite Change-Id: I8baaae9c512284a0d4fc926094dd8ed6eb23a43f
2023-08-28Move proto definitions to external/perfetto Kean Mariotti
This commit moves the layer and transaction .proto files to external/perfetto/protos/perfetto/trace/android/. Test: atest libsurfaceflinger_unittest && atest transactiontrace_testsuite Bug: b/284424784 Change-Id: I60b4a51fbb092d44759b7085536e1299815597f8
2023-08-21[sf] Add traces with log fatals Vishnu Nair
If we have to abort flinger, capture a transaction trace to disk as well. This will help us understand what lead to the unexpected state. Test: presubmit Bug: 238781169 Change-Id: I3ba9004ef8fc3cc2b9f7f431f9ceefafda858db7
2023-08-21[sf] Add TransactionTraceWriterTests Vishnu Nair
Bug: 238781169, 294989213 Test: presubmit Change-Id: Ibeb4118b08424ae28f4f48442f977a433aeff18e
2023-08-17Add dump of hdr event history John Reck
Track & dump the HDRLayerInfo callback history to aid debugging when HDR brightness changes aren't happening Bug: 234181960 Test: adb shell dumpsys surfaceflinger --hdrinfo Change-Id: Ia8376517877d4c7844af6be4d488299554c164f5
2023-06-23Merge "[sf] fix transaction tracing path typo" into udc-qpr-dev Vishnu Nair
2023-06-22[sf] fix transaction tracing path typo Vishnu Nair
Bug: 282110579, 238781169 Fixes: 277265947 Test: presubmit Change-Id: I2066f606337005eb049ad721ff80f34c9989b8c1