diff options
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 21 | ||||
| -rw-r--r-- | services/surfaceflinger/Tracing/LayerTracing.cpp | 10 | ||||
| -rw-r--r-- | services/surfaceflinger/Tracing/LayerTracing.h | 2 |
3 files changed, 22 insertions, 11 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index e765c9b6f4..417417d654 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2179,6 +2179,11 @@ bool SurfaceFlinger::commit(nsecs_t frameTime, int64_t vsyncId, nsecs_t expected updateCursorAsync(); updateInputFlinger(); + if (mLayerTracingEnabled && !mLayerTracing.flagIsSet(LayerTracing::TRACE_COMPOSITION)) { + // This will block and tracing should only be enabled for debugging. + mLayerTracing.notify(mVisibleRegionsDirty, frameTime); + } + MAIN_THREAD_GUARD(persistDisplayBrightness(mustComposite)); return mustComposite && CC_LIKELY(mBootStage != BootStage::BOOTLOADER); @@ -2280,13 +2285,9 @@ void SurfaceFlinger::composite(nsecs_t frameTime) { modulateVsync(&VsyncModulator::onDisplayRefresh, usedGpuComposition); mLayersWithQueuedFrames.clear(); - if (mLayerTracingEnabled) { + if (mLayerTracingEnabled && mLayerTracing.flagIsSet(LayerTracing::TRACE_COMPOSITION)) { // This will block and should only be used for debugging. - if (mVisibleRegionsDirty) { - mLayerTracing.notify("visibleRegionsDirty"); - } else if (mLayerTracing.flagIsSet(LayerTracing::TRACE_BUFFERS)) { - mLayerTracing.notify("bufferLatched"); - } + mLayerTracing.notify(mVisibleRegionsDirty, frameTime); } mVisibleRegionsWereDirtyThisFrame = mVisibleRegionsDirty; // Cache value for use in post-comp @@ -5773,12 +5774,18 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r } case 1025: { // Set layer tracing n = data.readInt32(); + int64_t fixedStartingTime = data.readInt64(); bool tracingEnabledChanged; if (n) { ALOGD("LayerTracing enabled"); tracingEnabledChanged = mLayerTracing.enable(); if (tracingEnabledChanged) { - mScheduler->schedule([&]() MAIN_THREAD { mLayerTracing.notify("start"); }) + int64_t startingTime = + (fixedStartingTime) ? fixedStartingTime : systemTime(); + mScheduler + ->schedule([&]() MAIN_THREAD { + mLayerTracing.notify("start", startingTime); + }) .wait(); } } else { diff --git a/services/surfaceflinger/Tracing/LayerTracing.cpp b/services/surfaceflinger/Tracing/LayerTracing.cpp index d136e0b6c8..006efdfd61 100644 --- a/services/surfaceflinger/Tracing/LayerTracing.cpp +++ b/services/surfaceflinger/Tracing/LayerTracing.cpp @@ -98,16 +98,20 @@ void LayerTracing::dump(std::string& result) const { mBuffer->dump(result); } -void LayerTracing::notify(const char* where) { - ATRACE_CALL(); +void LayerTracing::notify(bool visibleRegionDirty, int64_t time) { std::scoped_lock lock(mTraceLock); if (!mEnabled) { return; } + if (!visibleRegionDirty && !flagIsSet(LayerTracing::TRACE_BUFFERS)) { + return; + } + ATRACE_CALL(); LayersTraceProto entry; - entry.set_elapsed_realtime_nanos(elapsedRealtimeNano()); + entry.set_elapsed_realtime_nanos(time); + const char* where = visibleRegionDirty ? "visibleRegionsDirty" : "bufferLatched"; entry.set_where(where); LayersProto layers(mFlinger.dumpDrawingStateProto(mFlags)); diff --git a/services/surfaceflinger/Tracing/LayerTracing.h b/services/surfaceflinger/Tracing/LayerTracing.h index 8ca3587dbc..bd448c956d 100644 --- a/services/surfaceflinger/Tracing/LayerTracing.h +++ b/services/surfaceflinger/Tracing/LayerTracing.h @@ -47,7 +47,7 @@ public: bool isEnabled() const; status_t writeToFile(); LayersTraceFileProto createTraceFileProto() const; - void notify(const char* where); + void notify(bool visibleRegionDirty, int64_t time); enum : uint32_t { TRACE_INPUT = 1 << 1, |