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

Commit 7eb7ee7e authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Add ids to transactions and dump them in transaction trace

This is required for associating dumped transactions merges on the client side to dump transaction traces on the server side

Test: Make sure a transaction id is present in the dump
Change-Id: I8d3ad102bedb839901f0a818779c7d35519c669a
parent fa2663e2
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ message Transaction {
    required bool   synchronous      = 3;
    required bool   synchronous      = 3;
    required bool   animation        = 4;
    required bool   animation        = 4;
    optional Origin origin           = 5;
    optional Origin origin           = 5;
    optional uint64 id               = 6;
}
}


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


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


        SAFE_PARCEL(data.writeUint64, transactionId);

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


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

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

            return setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
            return setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
                                       desiredPresentTime, uncachedBuffer, hasListenerCallbacks,
                                       desiredPresentTime, uncachedBuffer, hasListenerCallbacks,
                                       listenerCallbacks);
                                       listenerCallbacks, transactionId);
        }
        }
        case BOOT_FINISHED: {
        case BOOT_FINISHED: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
+20 −3
Original line number Original line 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)
SurfaceComposerClient::Transaction::Transaction(const Transaction& other)
      : mForceSynchronous(other.mForceSynchronous),
      : mId(other.mId),
        mForceSynchronous(other.mForceSynchronous),
        mTransactionNestCount(other.mTransactionNestCount),
        mTransactionNestCount(other.mTransactionNestCount),
        mAnimation(other.mAnimation),
        mAnimation(other.mAnimation),
        mEarlyWakeup(other.mEarlyWakeup),
        mEarlyWakeup(other.mEarlyWakeup),
@@ -372,6 +381,10 @@ SurfaceComposerClient::Transaction::createFromParcel(const Parcel* parcel) {
    return nullptr;
    return nullptr;
}
}


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

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


    sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance());
    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() {
void SurfaceComposerClient::Transaction::cacheBuffers() {
@@ -709,11 +723,14 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) {
    mExplicitEarlyWakeupStart = false;
    mExplicitEarlyWakeupStart = false;
    mExplicitEarlyWakeupEnd = false;
    mExplicitEarlyWakeupEnd = false;


    uint64_t transactionId = mId;
    mId = generateId();

    sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance());
    sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance());
    sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands,
    sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands,
                            mDesiredPresentTime,
                            mDesiredPresentTime,
                            {} /*uncacheBuffer - only set in doUncacheBufferTransaction*/,
                            {} /*uncacheBuffer - only set in doUncacheBufferTransaction*/,
                            hasListenerCallbacks, listenerCallbacks);
                            hasListenerCallbacks, listenerCallbacks, transactionId);
    mInputWindowCommands.clear();
    mInputWindowCommands.clear();
    mStatus = NO_ERROR;
    mStatus = NO_ERROR;
    return NO_ERROR;
    return NO_ERROR;
+1 −1
Original line number Original line Diff line number Diff line
@@ -157,7 +157,7 @@ public:
            uint32_t flags, const sp<IBinder>& applyToken,
            uint32_t flags, const sp<IBinder>& applyToken,
            const InputWindowCommands& inputWindowCommands, int64_t desiredPresentTime,
            const InputWindowCommands& inputWindowCommands, int64_t desiredPresentTime,
            const client_cache_t& uncacheBuffer, bool hasListenerCallbacks,
            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.
    /* signal that we're done booting.
     * Requires ACCESS_SURFACE_FLINGER permission
     * Requires ACCESS_SURFACE_FLINGER permission
+7 −1
Original line number Original line Diff line number Diff line
@@ -339,12 +339,18 @@ public:
    };
    };


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

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


        uint64_t mId;

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


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


Loading