summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vishnu Nair <vishnun@google.com> 2020-04-03 18:56:19 -0700
committer Vishnu Nair <vishnun@google.com> 2020-04-04 01:58:40 +0000
commit73454c3371c6c031c602b6ae90a565a96175e685 (patch)
tree21f54b565ffae7ed645734dd47aa275c8c760989
parent6aa156cad417719c6ed9b84a8ed04e5ab7a2bc31 (diff)
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
-rw-r--r--services/surfaceflinger/SurfaceTracing.cpp7
-rw-r--r--services/surfaceflinger/SurfaceTracing.h2
2 files changed, 4 insertions, 5 deletions
diff --git a/services/surfaceflinger/SurfaceTracing.cpp b/services/surfaceflinger/SurfaceTracing.cpp
index a9c33327c8..68ecfd1b83 100644
--- a/services/surfaceflinger/SurfaceTracing.cpp
+++ b/services/surfaceflinger/SurfaceTracing.cpp
@@ -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() {
diff --git a/services/surfaceflinger/SurfaceTracing.h b/services/surfaceflinger/SurfaceTracing.h
index 83872ed3ae..5dae1697dd 100644
--- a/services/surfaceflinger/SurfaceTracing.h
+++ b/services/surfaceflinger/SurfaceTracing.h
@@ -85,7 +85,7 @@ private:
};
void mainLoop();
- void addFirstEntry();
+ bool addFirstEntry();
LayersTraceProto traceWhenNotified();
LayersTraceProto traceLayersLocked(const char* where,
const sp<const DisplayDevice>& displayDevice)