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

Commit 73454c33 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Check if the trace was stopped before starting the tracing thread

If a winscope trace is started and stopped quickly, the tracing thread
will not be stopped. The tracing thread waits for a conditional variable
notification that is sent before the thread starts running. To fix the
issue, properly initialize the trace enabled variable in the tracing
thread.

Test: atest FlickerLibTest:LayersTraceMonitorTest
Fixes: 153206487
Change-Id: I0c591c1fc3209327b40323b3ebb4fa4279c6ed05
parent 6aa156ca
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -36,22 +36,21 @@ SurfaceTracing::SurfaceTracing(SurfaceFlinger& flinger)
      : mFlinger(flinger), mSfLock(flinger.mDrawingStateLock) {}

void SurfaceTracing::mainLoop() {
    addFirstEntry();
    bool enabled = true;
    bool enabled = addFirstEntry();
    while (enabled) {
        LayersTraceProto entry = traceWhenNotified();
        enabled = addTraceToBuffer(entry);
    }
}

void SurfaceTracing::addFirstEntry() {
bool SurfaceTracing::addFirstEntry() {
    const auto displayDevice = mFlinger.getDefaultDisplayDevice();
    LayersTraceProto entry;
    {
        std::scoped_lock lock(mSfLock);
        entry = traceLayersLocked("tracing.enable", displayDevice);
    }
    addTraceToBuffer(entry);
    return addTraceToBuffer(entry);
}

LayersTraceProto SurfaceTracing::traceWhenNotified() {
+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ private:
    };

    void mainLoop();
    void addFirstEntry();
    bool addFirstEntry();
    LayersTraceProto traceWhenNotified();
    LayersTraceProto traceLayersLocked(const char* where,
                                       const sp<const DisplayDevice>& displayDevice)