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

Commit 384914ae authored by Pablo Gamito's avatar Pablo Gamito Committed by Android (Google) Code Review
Browse files

Merge "Add ids to transactions and dump them in transaction trace"

parents 67df4316 7eb7ee7e
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ message Transaction {
    required bool   synchronous      = 3;
    required bool   animation        = 4;
    optional Origin origin           = 5;
    optional uint64 id               = 6;
}

message SurfaceChange {
+9 −2
Original line number Diff line number Diff line
@@ -72,7 +72,8 @@ public:
            const Vector<ComposerState>& state, const Vector<DisplayState>& displays,
            uint32_t flags, const sp<IBinder>& applyToken, const InputWindowCommands& commands,
            int64_t desiredPresentTime, const client_cache_t& uncacheBuffer,
            bool hasListenerCallbacks, const std::vector<ListenerCallbacks>& listenerCallbacks) {
            bool hasListenerCallbacks, const std::vector<ListenerCallbacks>& listenerCallbacks,
            uint64_t transactionId) {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());

@@ -100,6 +101,8 @@ public:
            SAFE_PARCEL(data.writeInt64Vector, callbackIds);
        }

        SAFE_PARCEL(data.writeUint64, transactionId);

        return remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
    }

@@ -1278,9 +1281,13 @@ status_t BnSurfaceComposer::onTransact(
                SAFE_PARCEL(data.readInt64Vector, &callbackIds);
                listenerCallbacks.emplace_back(tmpBinder, callbackIds);
            }

            uint64_t transactionId = -1;
            SAFE_PARCEL(data.readUint64, &transactionId);

            return setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
                                       desiredPresentTime, uncachedBuffer, hasListenerCallbacks,
                                       listenerCallbacks);
                                       listenerCallbacks, transactionId);
        }
        case BOOT_FINISHED: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
+20 −3
Original line number Diff line number Diff line
@@ -348,8 +348,17 @@ void removeDeadBufferCallback(void* /*context*/, uint64_t graphicBufferId) {

// ---------------------------------------------------------------------------

// Initialize transaction id counter used to generate transaction ids
// Transactions will start counting at 1, 0 is used for invalid transactions
std::atomic<uint32_t> SurfaceComposerClient::Transaction::idCounter = 1;

SurfaceComposerClient::Transaction::Transaction() {
    mId = generateId();
}

SurfaceComposerClient::Transaction::Transaction(const Transaction& other)
      : mForceSynchronous(other.mForceSynchronous),
      : mId(other.mId),
        mForceSynchronous(other.mForceSynchronous),
        mTransactionNestCount(other.mTransactionNestCount),
        mAnimation(other.mAnimation),
        mEarlyWakeup(other.mEarlyWakeup),
@@ -372,6 +381,10 @@ SurfaceComposerClient::Transaction::createFromParcel(const Parcel* parcel) {
    return nullptr;
}

int64_t SurfaceComposerClient::Transaction::generateId() {
    return (((int64_t)getpid()) << 32) | idCounter++;
}

status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel) {
    const uint32_t forceSynchronous = parcel->readUint32();
    const uint32_t transactionNestCount = parcel->readUint32();
@@ -582,7 +595,8 @@ void SurfaceComposerClient::doUncacheBufferTransaction(uint64_t cacheId) {
    uncacheBuffer.id = cacheId;

    sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance());
    sf->setTransactionState({}, {}, 0, applyToken, {}, -1, uncacheBuffer, false, {});
    sf->setTransactionState({}, {}, 0, applyToken, {}, -1, uncacheBuffer, false, {},
                            0 /* Undefined transactionId */);
}

void SurfaceComposerClient::Transaction::cacheBuffers() {
@@ -709,11 +723,14 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) {
    mExplicitEarlyWakeupStart = false;
    mExplicitEarlyWakeupEnd = false;

    uint64_t transactionId = mId;
    mId = generateId();

    sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance());
    sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands,
                            mDesiredPresentTime,
                            {} /*uncacheBuffer - only set in doUncacheBufferTransaction*/,
                            hasListenerCallbacks, listenerCallbacks);
                            hasListenerCallbacks, listenerCallbacks, transactionId);
    mInputWindowCommands.clear();
    mStatus = NO_ERROR;
    return NO_ERROR;
+1 −1
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@ public:
            uint32_t flags, const sp<IBinder>& applyToken,
            const InputWindowCommands& inputWindowCommands, int64_t desiredPresentTime,
            const client_cache_t& uncacheBuffer, bool hasListenerCallbacks,
            const std::vector<ListenerCallbacks>& listenerCallbacks) = 0;
            const std::vector<ListenerCallbacks>& listenerCallbacks, uint64_t transactionId) = 0;

    /* signal that we're done booting.
     * Requires ACCESS_SURFACE_FLINGER permission
+7 −1
Original line number Diff line number Diff line
@@ -339,12 +339,18 @@ public:
    };

    class Transaction : public Parcelable {
    private:
        static std::atomic<uint32_t> idCounter;
        int64_t generateId();

    protected:
        std::unordered_map<sp<IBinder>, ComposerState, IBinderHash> mComposerStates;
        SortedVector<DisplayState > mDisplayStates;
        std::unordered_map<sp<ITransactionCompletedListener>, CallbackInfo, TCLHash>
                mListenerCallbacks;

        uint64_t mId;

        uint32_t mForceSynchronous = 0;
        uint32_t mTransactionNestCount = 0;
        bool mAnimation = false;
@@ -380,7 +386,7 @@ public:
        void registerSurfaceControlForCallback(const sp<SurfaceControl>& sc);

    public:
        Transaction() = default;
        Transaction();
        virtual ~Transaction() = default;
        Transaction(Transaction const& other);

Loading