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 | |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 26 | #include "TransactionTracing.h" |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | TransactionTracing::TransactionTracing() { |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 31 | std::scoped_lock lock(mTraceLock); |
Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 32 | |
| 33 | mBuffer.setSize(mBufferSizeInBytes); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 34 | mStartingTimestamp = systemTime(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 35 | { |
| 36 | std::scoped_lock lock(mMainThreadLock); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 37 | mThread = std::thread(&TransactionTracing::loop, this); |
| 38 | } |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 39 | } |
| 40 | |
Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 41 | TransactionTracing::~TransactionTracing() { |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 42 | std::thread thread; |
| 43 | { |
| 44 | std::scoped_lock lock(mMainThreadLock); |
| 45 | mDone = true; |
| 46 | mTransactionsAvailableCv.notify_all(); |
| 47 | thread = std::move(mThread); |
| 48 | } |
| 49 | if (thread.joinable()) { |
| 50 | thread.join(); |
| 51 | } |
| 52 | |
Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 53 | writeToFile(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | status_t TransactionTracing::writeToFile() { |
| 57 | std::scoped_lock lock(mTraceLock); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 58 | proto::TransactionTraceFile fileProto = createTraceFileProto(); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 59 | addStartingStateToProtoLocked(fileProto); |
Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 60 | return mBuffer.writeToFile(fileProto, FILE_NAME); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | void TransactionTracing::setBufferSize(size_t bufferSizeInBytes) { |
| 64 | std::scoped_lock lock(mTraceLock); |
| 65 | mBufferSizeInBytes = bufferSizeInBytes; |
Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 66 | mBuffer.setSize(mBufferSizeInBytes); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | proto::TransactionTraceFile TransactionTracing::createTraceFileProto() const { |
| 70 | proto::TransactionTraceFile proto; |
| 71 | proto.set_magic_number(uint64_t(proto::TransactionTraceFile_MagicNumber_MAGIC_NUMBER_H) << 32 | |
| 72 | proto::TransactionTraceFile_MagicNumber_MAGIC_NUMBER_L); |
| 73 | return proto; |
| 74 | } |
| 75 | |
| 76 | void TransactionTracing::dump(std::string& result) const { |
| 77 | std::scoped_lock lock(mTraceLock); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 78 | base::StringAppendF(&result, |
| 79 | " queued transactions=%zu created layers=%zu handles=%zu states=%zu\n", |
| 80 | mQueuedTransactions.size(), mCreatedLayers.size(), mLayerHandles.size(), |
| 81 | mStartingStates.size()); |
Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 82 | mBuffer.dump(result); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | void TransactionTracing::addQueuedTransaction(const TransactionState& transaction) { |
| 86 | std::scoped_lock lock(mTraceLock); |
| 87 | ATRACE_CALL(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 88 | mQueuedTransactions[transaction.id] = |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 89 | TransactionProtoParser::toProto(transaction, |
| 90 | std::bind(&TransactionTracing::getLayerIdLocked, this, |
| 91 | std::placeholders::_1), |
| 92 | nullptr); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | void TransactionTracing::addCommittedTransactions(std::vector<TransactionState>& transactions, |
| 96 | int64_t vsyncId) { |
| 97 | CommittedTransactions committedTransactions; |
| 98 | committedTransactions.vsyncId = vsyncId; |
| 99 | committedTransactions.timestamp = systemTime(); |
| 100 | committedTransactions.transactionIds.reserve(transactions.size()); |
| 101 | for (const auto& transaction : transactions) { |
| 102 | committedTransactions.transactionIds.emplace_back(transaction.id); |
| 103 | } |
| 104 | |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 105 | mPendingTransactions.emplace_back(committedTransactions); |
| 106 | tryPushToTracingThread(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | void TransactionTracing::loop() { |
| 110 | while (true) { |
| 111 | std::vector<CommittedTransactions> committedTransactions; |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 112 | std::vector<int32_t> removedLayers; |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 113 | { |
| 114 | std::unique_lock<std::mutex> lock(mMainThreadLock); |
| 115 | base::ScopedLockAssertion assumeLocked(mMainThreadLock); |
| 116 | mTransactionsAvailableCv.wait(lock, [&]() REQUIRES(mMainThreadLock) { |
| 117 | return mDone || !mCommittedTransactions.empty(); |
| 118 | }); |
| 119 | if (mDone) { |
| 120 | mCommittedTransactions.clear(); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 121 | mRemovedLayers.clear(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 122 | break; |
| 123 | } |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 124 | |
| 125 | removedLayers = std::move(mRemovedLayers); |
| 126 | mRemovedLayers.clear(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 127 | committedTransactions = std::move(mCommittedTransactions); |
| 128 | mCommittedTransactions.clear(); |
| 129 | } // unlock mMainThreadLock |
| 130 | |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 131 | addEntry(committedTransactions, removedLayers); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 135 | void TransactionTracing::addEntry(const std::vector<CommittedTransactions>& committedTransactions, |
| 136 | const std::vector<int32_t>& removedLayers) { |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 137 | ATRACE_CALL(); |
| 138 | std::scoped_lock lock(mTraceLock); |
Vishnu Nair | 6286355 | 2021-12-10 13:34:48 -0800 | [diff] [blame] | 139 | std::vector<std::string> removedEntries; |
| 140 | proto::TransactionTraceEntry entryProto; |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 141 | for (const CommittedTransactions& entry : committedTransactions) { |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 142 | entryProto.set_elapsed_realtime_nanos(entry.timestamp); |
| 143 | entryProto.set_vsync_id(entry.vsyncId); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 144 | entryProto.mutable_added_layers()->Reserve(static_cast<int32_t>(mCreatedLayers.size())); |
| 145 | for (auto& newLayer : mCreatedLayers) { |
| 146 | entryProto.mutable_added_layers()->Add(std::move(newLayer)); |
| 147 | } |
| 148 | entryProto.mutable_removed_layers()->Reserve(static_cast<int32_t>(removedLayers.size())); |
| 149 | for (auto& removedLayer : removedLayers) { |
| 150 | entryProto.mutable_removed_layers()->Add(removedLayer); |
| 151 | } |
| 152 | mCreatedLayers.clear(); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 153 | entryProto.mutable_transactions()->Reserve( |
| 154 | static_cast<int32_t>(entry.transactionIds.size())); |
| 155 | for (const uint64_t& id : entry.transactionIds) { |
| 156 | auto it = mQueuedTransactions.find(id); |
| 157 | if (it != mQueuedTransactions.end()) { |
| 158 | entryProto.mutable_transactions()->Add(std::move(it->second)); |
| 159 | mQueuedTransactions.erase(it); |
| 160 | } else { |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 161 | ALOGW("Could not find transaction id %" PRIu64, id); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 162 | } |
| 163 | } |
Vishnu Nair | 6286355 | 2021-12-10 13:34:48 -0800 | [diff] [blame] | 164 | |
| 165 | std::string serializedProto; |
| 166 | entryProto.SerializeToString(&serializedProto); |
| 167 | entryProto.Clear(); |
Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 168 | std::vector<std::string> entries = mBuffer.emplace(std::move(serializedProto)); |
Vishnu Nair | 6286355 | 2021-12-10 13:34:48 -0800 | [diff] [blame] | 169 | removedEntries.reserve(removedEntries.size() + entries.size()); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 170 | removedEntries.insert(removedEntries.end(), std::make_move_iterator(entries.begin()), |
| 171 | std::make_move_iterator(entries.end())); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 172 | |
| 173 | entryProto.mutable_removed_layer_handles()->Reserve( |
| 174 | static_cast<int32_t>(mRemovedLayerHandles.size())); |
| 175 | for (auto& handle : mRemovedLayerHandles) { |
| 176 | entryProto.mutable_removed_layer_handles()->Add(handle); |
| 177 | } |
| 178 | mRemovedLayerHandles.clear(); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 179 | } |
| 180 | |
Vishnu Nair | 6286355 | 2021-12-10 13:34:48 -0800 | [diff] [blame] | 181 | proto::TransactionTraceEntry removedEntryProto; |
| 182 | for (const std::string& removedEntry : removedEntries) { |
| 183 | removedEntryProto.ParseFromString(removedEntry); |
| 184 | updateStartingStateLocked(removedEntryProto); |
| 185 | removedEntryProto.Clear(); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 186 | } |
| 187 | mTransactionsAddedToBufferCv.notify_one(); |
| 188 | } |
| 189 | |
| 190 | void TransactionTracing::flush(int64_t vsyncId) { |
| 191 | while (!mPendingTransactions.empty() || !mPendingRemovedLayers.empty()) { |
| 192 | tryPushToTracingThread(); |
| 193 | } |
| 194 | std::unique_lock<std::mutex> lock(mTraceLock); |
| 195 | base::ScopedLockAssertion assumeLocked(mTraceLock); |
| 196 | mTransactionsAddedToBufferCv.wait(lock, [&]() REQUIRES(mTraceLock) { |
Vishnu Nair | 6286355 | 2021-12-10 13:34:48 -0800 | [diff] [blame] | 197 | proto::TransactionTraceEntry entry; |
Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 198 | if (mBuffer.used() > 0) { |
| 199 | entry.ParseFromString(mBuffer.back()); |
Vishnu Nair | 6286355 | 2021-12-10 13:34:48 -0800 | [diff] [blame] | 200 | } |
Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 201 | return mBuffer.used() > 0 && entry.vsync_id() >= vsyncId; |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 202 | }); |
| 203 | } |
| 204 | |
| 205 | void TransactionTracing::onLayerAdded(BBinder* layerHandle, int layerId, const std::string& name, |
| 206 | uint32_t flags, int parentId) { |
| 207 | std::scoped_lock lock(mTraceLock); |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 208 | TracingLayerCreationArgs args{layerId, name, flags, parentId, -1 /* mirrorFromId */}; |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 209 | if (mLayerHandles.find(layerHandle) != mLayerHandles.end()) { |
| 210 | ALOGW("Duplicate handles found. %p", layerHandle); |
| 211 | } |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 212 | mLayerHandles[layerHandle] = layerId; |
| 213 | proto::LayerCreationArgs protoArgs = TransactionProtoParser::toProto(args); |
| 214 | proto::LayerCreationArgs protoArgsCopy = protoArgs; |
| 215 | mCreatedLayers.push_back(protoArgs); |
| 216 | } |
| 217 | |
| 218 | void TransactionTracing::onMirrorLayerAdded(BBinder* layerHandle, int layerId, |
| 219 | const std::string& name, int mirrorFromId) { |
| 220 | std::scoped_lock lock(mTraceLock); |
| 221 | TracingLayerCreationArgs args{layerId, name, 0 /* flags */, -1 /* parentId */, mirrorFromId}; |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 222 | if (mLayerHandles.find(layerHandle) != mLayerHandles.end()) { |
| 223 | ALOGW("Duplicate handles found. %p", layerHandle); |
| 224 | } |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 225 | mLayerHandles[layerHandle] = layerId; |
| 226 | mCreatedLayers.emplace_back(TransactionProtoParser::toProto(args)); |
| 227 | } |
| 228 | |
| 229 | void TransactionTracing::onLayerRemoved(int32_t layerId) { |
| 230 | mPendingRemovedLayers.emplace_back(layerId); |
| 231 | tryPushToTracingThread(); |
| 232 | } |
| 233 | |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 234 | void TransactionTracing::onHandleRemoved(BBinder* layerHandle) { |
| 235 | std::scoped_lock lock(mTraceLock); |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame] | 236 | auto it = mLayerHandles.find(layerHandle); |
| 237 | if (it == mLayerHandles.end()) { |
| 238 | ALOGW("handle not found. %p", layerHandle); |
| 239 | return; |
| 240 | } |
| 241 | |
| 242 | mRemovedLayerHandles.push_back(it->second); |
| 243 | mLayerHandles.erase(it); |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 244 | } |
| 245 | |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 246 | void TransactionTracing::tryPushToTracingThread() { |
| 247 | // Try to acquire the lock from main thread. |
| 248 | if (mMainThreadLock.try_lock()) { |
| 249 | // We got the lock! Collect any pending transactions and continue. |
| 250 | mCommittedTransactions.insert(mCommittedTransactions.end(), |
| 251 | std::make_move_iterator(mPendingTransactions.begin()), |
| 252 | std::make_move_iterator(mPendingTransactions.end())); |
| 253 | mPendingTransactions.clear(); |
| 254 | mRemovedLayers.insert(mRemovedLayers.end(), mPendingRemovedLayers.begin(), |
| 255 | mPendingRemovedLayers.end()); |
| 256 | mPendingRemovedLayers.clear(); |
| 257 | mTransactionsAvailableCv.notify_one(); |
| 258 | mMainThreadLock.unlock(); |
| 259 | } else { |
| 260 | ALOGV("Couldn't get lock"); |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 261 | } |
| 262 | } |
| 263 | |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 264 | int32_t TransactionTracing::getLayerIdLocked(const sp<IBinder>& layerHandle) { |
| 265 | if (layerHandle == nullptr) { |
| 266 | return -1; |
| 267 | } |
| 268 | auto it = mLayerHandles.find(layerHandle->localBinder()); |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 269 | if (it == mLayerHandles.end()) { |
| 270 | ALOGW("Could not find layer handle %p", layerHandle->localBinder()); |
| 271 | return -1; |
| 272 | } |
| 273 | return it->second; |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | void TransactionTracing::updateStartingStateLocked( |
| 277 | const proto::TransactionTraceEntry& removedEntry) { |
| 278 | // Keep track of layer starting state so we can reconstruct the layer state as we purge |
| 279 | // transactions from the buffer. |
| 280 | for (const proto::LayerCreationArgs& addedLayer : removedEntry.added_layers()) { |
| 281 | TracingLayerState& startingState = mStartingStates[addedLayer.layer_id()]; |
| 282 | startingState.layerId = addedLayer.layer_id(); |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 283 | TransactionProtoParser::fromProto(addedLayer, startingState.args); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | // Merge layer states to starting transaction state. |
| 287 | for (const proto::TransactionState& transaction : removedEntry.transactions()) { |
| 288 | for (const proto::LayerState& layerState : transaction.layer_changes()) { |
| 289 | auto it = mStartingStates.find(layerState.layer_id()); |
| 290 | if (it == mStartingStates.end()) { |
Vishnu Nair | 047fb33 | 2021-12-09 09:54:36 -0800 | [diff] [blame] | 291 | ALOGW("Could not find layer id %d", layerState.layer_id()); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 292 | continue; |
| 293 | } |
Vishnu Nair | 7b0f18b | 2022-01-12 16:39:08 -0800 | [diff] [blame] | 294 | TransactionProtoParser::mergeFromProto(layerState, nullptr, it->second); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 295 | } |
| 296 | } |
| 297 | |
| 298 | // Clean up stale starting states since the layer has been removed and the buffer does not |
| 299 | // contain any references to the layer. |
| 300 | for (const int32_t removedLayerId : removedEntry.removed_layers()) { |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 301 | mStartingStates.erase(removedLayerId); |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | void TransactionTracing::addStartingStateToProtoLocked(proto::TransactionTraceFile& proto) { |
| 306 | proto::TransactionTraceEntry* entryProto = proto.add_entry(); |
| 307 | entryProto->set_elapsed_realtime_nanos(mStartingTimestamp); |
| 308 | entryProto->set_vsync_id(0); |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 309 | if (mStartingStates.size() == 0) { |
| 310 | return; |
| 311 | } |
| 312 | |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 313 | entryProto->mutable_added_layers()->Reserve(static_cast<int32_t>(mStartingStates.size())); |
| 314 | for (auto& [layerId, state] : mStartingStates) { |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 315 | entryProto->mutable_added_layers()->Add(TransactionProtoParser::toProto(state.args)); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | proto::TransactionState transactionProto = TransactionProtoParser::toProto(mStartingStates); |
| 319 | transactionProto.set_vsync_id(0); |
| 320 | transactionProto.set_post_time(mStartingTimestamp); |
| 321 | entryProto->mutable_transactions()->Add(std::move(transactionProto)); |
| 322 | } |
| 323 | |
| 324 | proto::TransactionTraceFile TransactionTracing::writeToProto() { |
| 325 | std::scoped_lock<std::mutex> lock(mTraceLock); |
| 326 | proto::TransactionTraceFile proto = createTraceFileProto(); |
| 327 | addStartingStateToProtoLocked(proto); |
Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 328 | mBuffer.writeToProto(proto); |
Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 329 | return proto; |
Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | } // namespace android |