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

Commit 81cef293 authored by Pascal Muetschard's avatar Pascal Muetschard Committed by Pascal Mütschard
Browse files

Send available JankData in all transaction completion callbacks.

This, effectively, adds JankData to the callbacks also for layers that will not present in the current transaction.

Bug: 235178314
Bug: 221393601
Test: atest SurfaceFlinger_test
Change-Id: Ia6afaa31ad98a71cb6d6dc146f1094b857ab92b2
parent f54181b2
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -3131,6 +3131,7 @@ bool Layer::setTransactionCompletedListeners(const std::vector<sp<CallbackHandle
        return false;
    }

    std::deque<sp<CallbackHandle>> remainingHandles;
    for (const auto& handle : handles) {
        // If this transaction set a buffer on this layer, release its previous buffer
        handle->releasePreviousBuffer = mReleasePreviousBuffer;
@@ -3145,9 +3146,17 @@ bool Layer::setTransactionCompletedListeners(const std::vector<sp<CallbackHandle
            mDrawingState.callbackHandles.push_back(handle);

        } else { // If this layer will NOT need to be relatched and presented this frame
            // Notify the transaction completed thread this handle is done
            mFlinger->getTransactionCallbackInvoker().registerUnpresentedCallbackHandle(handle);
            // Queue this handle to be notified below.
            remainingHandles.push_back(handle);
        }
    }

    if (!remainingHandles.empty()) {
        // Notify the transaction completed threads these handles are done. These are only the
        // handles that were not added to the mDrawingState, which will be notified later.
        std::vector<JankData> jankData;
        transferAvailableJankData(remainingHandles, jankData);
        mFlinger->getTransactionCallbackInvoker().addCallbackHandles(remainingHandles, jankData);
    }

    mReleasePreviousBuffer = false;
+8 −4
Original line number Diff line number Diff line
@@ -4552,8 +4552,10 @@ uint32_t SurfaceFlinger::setClientStateLocked(const FrameTimelineInfo& frameTime
    }
    if (layer == nullptr) {
        for (auto& [listener, callbackIds] : s.listeners) {
            mTransactionCallbackInvoker.registerUnpresentedCallbackHandle(
                    sp<CallbackHandle>::make(listener, callbackIds, s.surface));
            mTransactionCallbackInvoker.addCallbackHandle(sp<CallbackHandle>::make(listener,
                                                                                   callbackIds,
                                                                                   s.surface),
                                                          std::vector<JankData>());
        }
        return 0;
    }
@@ -4891,8 +4893,10 @@ uint32_t SurfaceFlinger::updateLayerCallbacksAndStats(const FrameTimelineInfo& f
    }
    if (layer == nullptr) {
        for (auto& [listener, callbackIds] : s.listeners) {
            mTransactionCallbackInvoker.registerUnpresentedCallbackHandle(
                    sp<CallbackHandle>::make(listener, callbackIds, s.surface));
            mTransactionCallbackInvoker.addCallbackHandle(sp<CallbackHandle>::make(listener,
                                                                                   callbackIds,
                                                                                   s.surface),
                                                          std::vector<JankData>());
        }
        return 0;
    }
+0 −5
Original line number Diff line number Diff line
@@ -92,11 +92,6 @@ status_t TransactionCallbackInvoker::addCallbackHandles(
    return NO_ERROR;
}

status_t TransactionCallbackInvoker::registerUnpresentedCallbackHandle(
        const sp<CallbackHandle>& handle) {
    return addCallbackHandle(handle, std::vector<JankData>());
}

status_t TransactionCallbackInvoker::findOrCreateTransactionStats(
        const sp<IBinder>& listener, const std::vector<CallbackId>& callbackIds,
        TransactionStats** outTransactionStats) {
+0 −3
Original line number Diff line number Diff line
@@ -66,9 +66,6 @@ public:
    status_t addOnCommitCallbackHandles(const std::deque<sp<CallbackHandle>>& handles,
                                             std::deque<sp<CallbackHandle>>& outRemainingHandles);

    // Adds the Transaction CallbackHandle from a layer that does not need to be relatched and
    // presented this frame.
    status_t registerUnpresentedCallbackHandle(const sp<CallbackHandle>& handle);
    void addEmptyTransaction(const ListenerCallbacks& listenerCallbacks);

    void addPresentFence(sp<Fence>);