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

Commit e60041e0 authored by Alec Mouri's avatar Alec Mouri
Browse files

[SurfaceFlinger] Add deferred txn trace points.

Currently there is not enough trace information to track down jank that
is suspected to be related to deferred transactions, so adding some
trace points in this patch.

Bug: 134583193
Test: systrace
Change-Id: Iecc367dcfaa85877be0b9d9c179986bac52473f5
parent 4f65d337
Loading
Loading
Loading
Loading
+9 −5
Original line number Original line Diff line number Diff line
@@ -19,9 +19,7 @@
#define LOG_TAG "BufferLayer"
#define LOG_TAG "BufferLayer"
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#define ATRACE_TAG ATRACE_TAG_GRAPHICS


#include <cmath>
#include "BufferLayer.h"
#include <cstdlib>
#include <mutex>


#include <compositionengine/CompositionEngine.h>
#include <compositionengine/CompositionEngine.h>
#include <compositionengine/Display.h>
#include <compositionengine/Display.h>
@@ -45,11 +43,14 @@
#include <utils/StopWatch.h>
#include <utils/StopWatch.h>
#include <utils/Trace.h>
#include <utils/Trace.h>


#include "BufferLayer.h"
#include <cmath>
#include <cstdlib>
#include <mutex>
#include <sstream>

#include "Colorizer.h"
#include "Colorizer.h"
#include "DisplayDevice.h"
#include "DisplayDevice.h"
#include "LayerRejecter.h"
#include "LayerRejecter.h"

#include "TimeStats/TimeStats.h"
#include "TimeStats/TimeStats.h"


namespace android {
namespace android {
@@ -525,6 +526,9 @@ bool BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime)
            }
            }


            if ((*point)->getFrameNumber() <= mCurrentFrameNumber) {
            if ((*point)->getFrameNumber() <= mCurrentFrameNumber) {
                std::stringstream ss;
                ss << "Dropping sync point " << (*point)->getFrameNumber();
                ATRACE_NAME(ss.str().c_str());
                point = mLocalSyncPoints.erase(point);
                point = mLocalSyncPoints.erase(point);
            } else {
            } else {
                ++point;
                ++point;
+17 −7
Original line number Original line Diff line number Diff line
@@ -19,12 +19,7 @@
#define LOG_TAG "Layer"
#define LOG_TAG "Layer"
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#define ATRACE_TAG ATRACE_TAG_GRAPHICS


#include <math.h>
#include "Layer.h"
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <algorithm>
#include <mutex>


#include <android-base/stringprintf.h>
#include <android-base/stringprintf.h>
#include <compositionengine/Display.h>
#include <compositionengine/Display.h>
@@ -39,7 +34,11 @@
#include <gui/BufferItem.h>
#include <gui/BufferItem.h>
#include <gui/LayerDebugInfo.h>
#include <gui/LayerDebugInfo.h>
#include <gui/Surface.h>
#include <gui/Surface.h>
#include <math.h>
#include <renderengine/RenderEngine.h>
#include <renderengine/RenderEngine.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <ui/DebugUtils.h>
#include <ui/DebugUtils.h>
#include <ui/GraphicBuffer.h>
#include <ui/GraphicBuffer.h>
#include <ui/PixelFormat.h>
#include <ui/PixelFormat.h>
@@ -49,12 +48,15 @@
#include <utils/StopWatch.h>
#include <utils/StopWatch.h>
#include <utils/Trace.h>
#include <utils/Trace.h>


#include <algorithm>
#include <mutex>
#include <sstream>

#include "BufferLayer.h"
#include "BufferLayer.h"
#include "ColorLayer.h"
#include "ColorLayer.h"
#include "Colorizer.h"
#include "Colorizer.h"
#include "DisplayDevice.h"
#include "DisplayDevice.h"
#include "DisplayHardware/HWComposer.h"
#include "DisplayHardware/HWComposer.h"
#include "Layer.h"
#include "LayerProtoHelper.h"
#include "LayerProtoHelper.h"
#include "LayerRejecter.h"
#include "LayerRejecter.h"
#include "MonitoredProducer.h"
#include "MonitoredProducer.h"
@@ -677,6 +679,7 @@ void Layer::pushPendingState() {
    if (!mCurrentState.modified) {
    if (!mCurrentState.modified) {
        return;
        return;
    }
    }
    ATRACE_CALL();


    // If this transaction is waiting on the receipt of a frame, generate a sync
    // If this transaction is waiting on the receipt of a frame, generate a sync
    // point and send it to the remote layer.
    // point and send it to the remote layer.
@@ -693,6 +696,9 @@ void Layer::pushPendingState() {
        } else {
        } else {
            auto syncPoint = std::make_shared<SyncPoint>(mCurrentState.frameNumber_legacy, this);
            auto syncPoint = std::make_shared<SyncPoint>(mCurrentState.frameNumber_legacy, this);
            if (barrierLayer->addSyncPoint(syncPoint)) {
            if (barrierLayer->addSyncPoint(syncPoint)) {
                std::stringstream ss;
                ss << "Adding sync point " << mCurrentState.frameNumber_legacy;
                ATRACE_NAME(ss.str().c_str());
                mRemoteSyncPoints.push_back(std::move(syncPoint));
                mRemoteSyncPoints.push_back(std::move(syncPoint));
            } else {
            } else {
                // We already missed the frame we're supposed to synchronize
                // We already missed the frame we're supposed to synchronize
@@ -710,6 +716,7 @@ void Layer::pushPendingState() {
}
}


void Layer::popPendingState(State* stateToCommit) {
void Layer::popPendingState(State* stateToCommit) {
    ATRACE_CALL();
    *stateToCommit = mPendingStates[0];
    *stateToCommit = mPendingStates[0];


    mPendingStates.removeAt(0);
    mPendingStates.removeAt(0);
@@ -741,6 +748,7 @@ bool Layer::applyPendingStates(State* stateToCommit) {
            }
            }


            if (mRemoteSyncPoints.front()->frameIsAvailable()) {
            if (mRemoteSyncPoints.front()->frameIsAvailable()) {
                ATRACE_NAME("frameIsAvailable");
                // Apply the state update
                // Apply the state update
                popPendingState(stateToCommit);
                popPendingState(stateToCommit);
                stateUpdateAvailable = true;
                stateUpdateAvailable = true;
@@ -749,6 +757,7 @@ bool Layer::applyPendingStates(State* stateToCommit) {
                mRemoteSyncPoints.front()->setTransactionApplied();
                mRemoteSyncPoints.front()->setTransactionApplied();
                mRemoteSyncPoints.pop_front();
                mRemoteSyncPoints.pop_front();
            } else {
            } else {
                ATRACE_NAME("!frameIsAvailable");
                break;
                break;
            }
            }
        } else {
        } else {
@@ -1195,6 +1204,7 @@ uint32_t Layer::getLayerStack() const {
}
}


void Layer::deferTransactionUntil_legacy(const sp<Layer>& barrierLayer, uint64_t frameNumber) {
void Layer::deferTransactionUntil_legacy(const sp<Layer>& barrierLayer, uint64_t frameNumber) {
    ATRACE_CALL();
    mCurrentState.barrierLayer_legacy = barrierLayer;
    mCurrentState.barrierLayer_legacy = barrierLayer;
    mCurrentState.frameNumber_legacy = frameNumber;
    mCurrentState.frameNumber_legacy = frameNumber;
    // We don't set eTransactionNeeded, because just receiving a deferral
    // We don't set eTransactionNeeded, because just receiving a deferral