Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #undef LOG_TAG |
| 18 | #define LOG_TAG "TransactionTracing" |
| 19 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 20 | |
| 21 | #include <android-base/stringprintf.h> |
| 22 | #include <log/log.h> |
| 23 | #include <utils/SystemClock.h> |
| 24 | #include <utils/Trace.h> |
| 25 | |
| 26 | #include "RingBuffer.h" |
| 27 | #include "TransactionTracing.h" |
| 28 | |
| 29 | namespace android { |
| 30 | |
| 31 | TransactionTracing::TransactionTracing() { |
| 32 | mBuffer = std::make_unique< |
| 33 | RingBuffer<proto::TransactionTraceFile, proto::TransactionTraceEntry>>(); |
| 34 | } |
| 35 | |
| 36 | TransactionTracing::~TransactionTracing() = default; |
| 37 | |
| 38 | bool TransactionTracing::enable() { |
| 39 | std::scoped_lock lock(mTraceLock); |
| 40 | if (mEnabled) { |
| 41 | return false; |
| 42 | } |
| 43 | mBuffer->setSize(mBufferSizeInBytes); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 44 | mStartingTimestamp = systemTime(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 45 | mEnabled = true; |
| 46 | { |
| 47 | std::scoped_lock lock(mMainThreadLock); |
| 48 | mDone = false; |
| 49 | mThread = std::thread(&TransactionTracing::loop, this); |
| 50 | } |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | bool TransactionTracing::disable() { |
| 55 | std::thread thread; |
| 56 | { |
| 57 | std::scoped_lock lock(mMainThreadLock); |
| 58 | mDone = true; |
| 59 | mTransactionsAvailableCv.notify_all(); |
| 60 | thread = std::move(mThread); |
| 61 | } |
| 62 | if (thread.joinable()) { |
| 63 | thread.join(); |
| 64 | } |
| 65 | |
| 66 | std::scoped_lock lock(mTraceLock); |
| 67 | if (!mEnabled) { |
| 68 | return false; |
| 69 | } |
| 70 | mEnabled = false; |
| 71 | |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 72 | writeToFileLocked(); |
| 73 | mBuffer->reset(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 74 | mQueuedTransactions.clear(); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 75 | mStartingStates.clear(); |
| 76 | mLayerHandles.clear(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 77 | return true; |
| 78 | } |
| 79 | |
| 80 | bool TransactionTracing::isEnabled() const { |
| 81 | std::scoped_lock lock(mTraceLock); |
| 82 | return mEnabled; |
| 83 | } |
| 84 | |
| 85 | status_t TransactionTracing::writeToFile() { |
| 86 | std::scoped_lock lock(mTraceLock); |
| 87 | if (!mEnabled) { |
| 88 | return STATUS_OK; |
| 89 | } |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 90 | return writeToFileLocked(); |
| 91 | } |
| 92 | |
| 93 | status_t TransactionTracing::writeToFileLocked() { |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 94 | proto::TransactionTraceFile fileProto = createTraceFileProto(); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 95 | addStartingStateToProtoLocked(fileProto); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 96 | return mBuffer->writeToFile(fileProto, FILE_NAME); |
| 97 | } |
| 98 | |
| 99 | void TransactionTracing::setBufferSize(size_t bufferSizeInBytes) { |
| 100 | std::scoped_lock lock(mTraceLock); |
| 101 | mBufferSizeInBytes = bufferSizeInBytes; |
| 102 | mBuffer->setSize(mBufferSizeInBytes); |
| 103 | } |
| 104 | |
| 105 | proto::TransactionTraceFile TransactionTracing::createTraceFileProto() const { |
| 106 | proto::TransactionTraceFile proto; |
| 107 | proto.set_magic_number(uint64_t(proto::TransactionTraceFile_MagicNumber_MAGIC_NUMBER_H) << 32 | |
| 108 | proto::TransactionTraceFile_MagicNumber_MAGIC_NUMBER_L); |
| 109 | return proto; |
| 110 | } |
| 111 | |
| 112 | void TransactionTracing::dump(std::string& result) const { |
| 113 | std::scoped_lock lock(mTraceLock); |
| 114 | base::StringAppendF(&result, "Transaction tracing state: %s\n", |
| 115 | mEnabled ? "enabled" : "disabled"); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 116 | base::StringAppendF(&result, |
| 117 | " queued transactions=%zu created layers=%zu handles=%zu states=%zu\n", |
| 118 | mQueuedTransactions.size(), mCreatedLayers.size(), mLayerHandles.size(), |
| 119 | mStartingStates.size()); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 120 | mBuffer->dump(result); |
| 121 | } |
| 122 | |
| 123 | void TransactionTracing::addQueuedTransaction(const TransactionState& transaction) { |
| 124 | std::scoped_lock lock(mTraceLock); |
| 125 | ATRACE_CALL(); |
| 126 | if (!mEnabled) { |
| 127 | return; |
| 128 | } |
| 129 | mQueuedTransactions[transaction.id] = |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 130 | TransactionProtoParser::toProto(transaction, |
| 131 | std::bind(&TransactionTracing::getLayerIdLocked, this, |
| 132 | std::placeholders::_1), |
| 133 | nullptr); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | void TransactionTracing::addCommittedTransactions(std::vector<TransactionState>& transactions, |
| 137 | int64_t vsyncId) { |
| 138 | CommittedTransactions committedTransactions; |
| 139 | committedTransactions.vsyncId = vsyncId; |
| 140 | committedTransactions.timestamp = systemTime(); |
| 141 | committedTransactions.transactionIds.reserve(transactions.size()); |
| 142 | for (const auto& transaction : transactions) { |
| 143 | committedTransactions.transactionIds.emplace_back(transaction.id); |
| 144 | } |
| 145 | |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 146 | mPendingTransactions.emplace_back(committedTransactions); |
| 147 | tryPushToTracingThread(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | void TransactionTracing::loop() { |
| 151 | while (true) { |
| 152 | std::vector<CommittedTransactions> committedTransactions; |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 153 | std::vector<int32_t> removedLayers; |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 154 | { |
| 155 | std::unique_lock<std::mutex> lock(mMainThreadLock); |
| 156 | base::ScopedLockAssertion assumeLocked(mMainThreadLock); |
| 157 | mTransactionsAvailableCv.wait(lock, [&]() REQUIRES(mMainThreadLock) { |
| 158 | return mDone || !mCommittedTransactions.empty(); |
| 159 | }); |
| 160 | if (mDone) { |
| 161 | mCommittedTransactions.clear(); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 162 | mRemovedLayers.clear(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 163 | break; |
| 164 | } |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 165 | |
| 166 | removedLayers = std::move(mRemovedLayers); |
| 167 | mRemovedLayers.clear(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 168 | committedTransactions = std::move(mCommittedTransactions); |
| 169 | mCommittedTransactions.clear(); |
| 170 | } // unlock mMainThreadLock |
| 171 | |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 172 | addEntry(committedTransactions, removedLayers); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 173 | } |
| 174 | } |
| 175 | |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 176 | void TransactionTracing::addEntry(const std::vector<CommittedTransactions>& committedTransactions, |
| 177 | const std::vector<int32_t>& removedLayers) { |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 178 | ATRACE_CALL(); |
| 179 | std::scoped_lock lock(mTraceLock); |
Vishnu Nair | 6286355 | 2021-12-10 13:34:48 -0800 | [diff] [blame] | 180 | std::vector<std::string> removedEntries; |
| 181 | proto::TransactionTraceEntry entryProto; |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 182 | for (const CommittedTransactions& entry : committedTransactions) { |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 183 | entryProto.set_elapsed_realtime_nanos(entry.timestamp); |
| 184 | entryProto.set_vsync_id(entry.vsyncId); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 185 | entryProto.mutable_added_layers()->Reserve(static_cast<int32_t>(mCreatedLayers.size())); |
| 186 | for (auto& newLayer : mCreatedLayers) { |
| 187 | entryProto.mutable_added_layers()->Add(std::move(newLayer)); |
| 188 | } |
| 189 | entryProto.mutable_removed_layers()->Reserve(static_cast<int32_t>(removedLayers.size())); |
| 190 | for (auto& removedLayer : removedLayers) { |
| 191 | entryProto.mutable_removed_layers()->Add(removedLayer); |
| 192 | } |
| 193 | mCreatedLayers.clear(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 194 | entryProto.mutable_transactions()->Reserve( |
| 195 | static_cast<int32_t>(entry.transactionIds.size())); |
| 196 | for (const uint64_t& id : entry.transactionIds) { |
| 197 | auto it = mQueuedTransactions.find(id); |
| 198 | if (it != mQueuedTransactions.end()) { |
| 199 | entryProto.mutable_transactions()->Add(std::move(it->second)); |
| 200 | mQueuedTransactions.erase(it); |
| 201 | } else { |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 202 | ALOGW("Could not find transaction id %" PRIu64, id); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 203 | } |
| 204 | } |
Vishnu Nair | 6286355 | 2021-12-10 13:34:48 -0800 | [diff] [blame] | 205 | |
| 206 | std::string serializedProto; |
| 207 | entryProto.SerializeToString(&serializedProto); |
| 208 | entryProto.Clear(); |
| 209 | std::vector<std::string> entries = mBuffer->emplace(std::move(serializedProto)); |
| 210 | removedEntries.reserve(removedEntries.size() + entries.size()); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 211 | removedEntries.insert(removedEntries.end(), std::make_move_iterator(entries.begin()), |
| 212 | std::make_move_iterator(entries.end())); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame^] | 213 | |
| 214 | entryProto.mutable_removed_layer_handles()->Reserve( |
| 215 | static_cast<int32_t>(mRemovedLayerHandles.size())); |
| 216 | for (auto& handle : mRemovedLayerHandles) { |
| 217 | entryProto.mutable_removed_layer_handles()->Add(handle); |
| 218 | } |
| 219 | mRemovedLayerHandles.clear(); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 220 | } |
| 221 | |
Vishnu Nair | 6286355 | 2021-12-10 13:34:48 -0800 | [diff] [blame] | 222 | proto::TransactionTraceEntry removedEntryProto; |
| 223 | for (const std::string& removedEntry : removedEntries) { |
| 224 | removedEntryProto.ParseFromString(removedEntry); |
| 225 | updateStartingStateLocked(removedEntryProto); |
| 226 | removedEntryProto.Clear(); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 227 | } |
| 228 | mTransactionsAddedToBufferCv.notify_one(); |
| 229 | } |
| 230 | |
| 231 | void TransactionTracing::flush(int64_t vsyncId) { |
| 232 | while (!mPendingTransactions.empty() || !mPendingRemovedLayers.empty()) { |
| 233 | tryPushToTracingThread(); |
| 234 | } |
| 235 | std::unique_lock<std::mutex> lock(mTraceLock); |
| 236 | base::ScopedLockAssertion assumeLocked(mTraceLock); |
| 237 | mTransactionsAddedToBufferCv.wait(lock, [&]() REQUIRES(mTraceLock) { |
Vishnu Nair | 6286355 | 2021-12-10 13:34:48 -0800 | [diff] [blame] | 238 | proto::TransactionTraceEntry entry; |
| 239 | if (mBuffer->used() > 0) { |
| 240 | entry.ParseFromString(mBuffer->back()); |
| 241 | } |
| 242 | return mBuffer->used() > 0 && entry.vsync_id() >= vsyncId; |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 243 | }); |
| 244 | } |
| 245 | |
| 246 | void TransactionTracing::onLayerAdded(BBinder* layerHandle, int layerId, const std::string& name, |
| 247 | uint32_t flags, int parentId) { |
| 248 | std::scoped_lock lock(mTraceLock); |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 249 | TracingLayerCreationArgs args{layerId, name, flags, parentId, -1 /* mirrorFromId */}; |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 250 | if (mLayerHandles.find(layerHandle) != mLayerHandles.end()) { |
| 251 | ALOGW("Duplicate handles found. %p", layerHandle); |
| 252 | } |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 253 | mLayerHandles[layerHandle] = layerId; |
| 254 | proto::LayerCreationArgs protoArgs = TransactionProtoParser::toProto(args); |
| 255 | proto::LayerCreationArgs protoArgsCopy = protoArgs; |
| 256 | mCreatedLayers.push_back(protoArgs); |
| 257 | } |
| 258 | |
| 259 | void TransactionTracing::onMirrorLayerAdded(BBinder* layerHandle, int layerId, |
| 260 | const std::string& name, int mirrorFromId) { |
| 261 | std::scoped_lock lock(mTraceLock); |
| 262 | TracingLayerCreationArgs args{layerId, name, 0 /* flags */, -1 /* parentId */, mirrorFromId}; |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 263 | if (mLayerHandles.find(layerHandle) != mLayerHandles.end()) { |
| 264 | ALOGW("Duplicate handles found. %p", layerHandle); |
| 265 | } |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 266 | mLayerHandles[layerHandle] = layerId; |
| 267 | mCreatedLayers.emplace_back(TransactionProtoParser::toProto(args)); |
| 268 | } |
| 269 | |
| 270 | void TransactionTracing::onLayerRemoved(int32_t layerId) { |
| 271 | mPendingRemovedLayers.emplace_back(layerId); |
| 272 | tryPushToTracingThread(); |
| 273 | } |
| 274 | |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 275 | void TransactionTracing::onHandleRemoved(BBinder* layerHandle) { |
| 276 | std::scoped_lock lock(mTraceLock); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame^] | 277 | auto it = mLayerHandles.find(layerHandle); |
| 278 | if (it == mLayerHandles.end()) { |
| 279 | ALOGW("handle not found. %p", layerHandle); |
| 280 | return; |
| 281 | } |
| 282 | |
| 283 | mRemovedLayerHandles.push_back(it->second); |
| 284 | mLayerHandles.erase(it); |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 285 | } |
| 286 | |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 287 | void TransactionTracing::tryPushToTracingThread() { |
| 288 | // Try to acquire the lock from main thread. |
| 289 | if (mMainThreadLock.try_lock()) { |
| 290 | // We got the lock! Collect any pending transactions and continue. |
| 291 | mCommittedTransactions.insert(mCommittedTransactions.end(), |
| 292 | std::make_move_iterator(mPendingTransactions.begin()), |
| 293 | std::make_move_iterator(mPendingTransactions.end())); |
| 294 | mPendingTransactions.clear(); |
| 295 | mRemovedLayers.insert(mRemovedLayers.end(), mPendingRemovedLayers.begin(), |
| 296 | mPendingRemovedLayers.end()); |
| 297 | mPendingRemovedLayers.clear(); |
| 298 | mTransactionsAvailableCv.notify_one(); |
| 299 | mMainThreadLock.unlock(); |
| 300 | } else { |
| 301 | ALOGV("Couldn't get lock"); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 302 | } |
| 303 | } |
| 304 | |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 305 | int32_t TransactionTracing::getLayerIdLocked(const sp<IBinder>& layerHandle) { |
| 306 | if (layerHandle == nullptr) { |
| 307 | return -1; |
| 308 | } |
| 309 | auto it = mLayerHandles.find(layerHandle->localBinder()); |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 310 | if (it == mLayerHandles.end()) { |
| 311 | ALOGW("Could not find layer handle %p", layerHandle->localBinder()); |
| 312 | return -1; |
| 313 | } |
| 314 | return it->second; |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | void TransactionTracing::updateStartingStateLocked( |
| 318 | const proto::TransactionTraceEntry& removedEntry) { |
| 319 | // Keep track of layer starting state so we can reconstruct the layer state as we purge |
| 320 | // transactions from the buffer. |
| 321 | for (const proto::LayerCreationArgs& addedLayer : removedEntry.added_layers()) { |
| 322 | TracingLayerState& startingState = mStartingStates[addedLayer.layer_id()]; |
| 323 | startingState.layerId = addedLayer.layer_id(); |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 324 | TransactionProtoParser::fromProto(addedLayer, startingState.args); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | // Merge layer states to starting transaction state. |
| 328 | for (const proto::TransactionState& transaction : removedEntry.transactions()) { |
| 329 | for (const proto::LayerState& layerState : transaction.layer_changes()) { |
| 330 | auto it = mStartingStates.find(layerState.layer_id()); |
| 331 | if (it == mStartingStates.end()) { |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 332 | ALOGW("Could not find layer id %d", layerState.layer_id()); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 333 | continue; |
| 334 | } |
| 335 | TransactionProtoParser::fromProto(layerState, nullptr, it->second); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | // Clean up stale starting states since the layer has been removed and the buffer does not |
| 340 | // contain any references to the layer. |
| 341 | for (const int32_t removedLayerId : removedEntry.removed_layers()) { |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 342 | mStartingStates.erase(removedLayerId); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | void TransactionTracing::addStartingStateToProtoLocked(proto::TransactionTraceFile& proto) { |
| 347 | proto::TransactionTraceEntry* entryProto = proto.add_entry(); |
| 348 | entryProto->set_elapsed_realtime_nanos(mStartingTimestamp); |
| 349 | entryProto->set_vsync_id(0); |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 350 | if (mStartingStates.size() == 0) { |
| 351 | return; |
| 352 | } |
| 353 | |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 354 | entryProto->mutable_added_layers()->Reserve(static_cast<int32_t>(mStartingStates.size())); |
| 355 | for (auto& [layerId, state] : mStartingStates) { |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 356 | entryProto->mutable_added_layers()->Add(TransactionProtoParser::toProto(state.args)); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | proto::TransactionState transactionProto = TransactionProtoParser::toProto(mStartingStates); |
| 360 | transactionProto.set_vsync_id(0); |
| 361 | transactionProto.set_post_time(mStartingTimestamp); |
| 362 | entryProto->mutable_transactions()->Add(std::move(transactionProto)); |
| 363 | } |
| 364 | |
| 365 | proto::TransactionTraceFile TransactionTracing::writeToProto() { |
| 366 | std::scoped_lock<std::mutex> lock(mTraceLock); |
| 367 | proto::TransactionTraceFile proto = createTraceFileProto(); |
| 368 | addStartingStateToProtoLocked(proto); |
| 369 | mBuffer->writeToProto(proto); |
| 370 | return proto; |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | } // namespace android |