diff options
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 65a0ed3065..06560d06ba 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -946,16 +946,20 @@ void SurfaceFlinger::init() FTL_FAKE_GUARD(kMainThreadContext) { })); })); - mLayerTracing.setTakeLayersSnapshotProtoFunction([&](uint32_t traceFlags) { - auto snapshot = perfetto::protos::LayersSnapshotProto{}; - mScheduler - ->schedule([&]() FTL_FAKE_GUARD(mStateLock) FTL_FAKE_GUARD(kMainThreadContext) { - snapshot = takeLayersSnapshotProto(traceFlags, TimePoint::now(), - mLastCommittedVsyncId, true); - }) - .wait(); - return snapshot; - }); + mLayerTracing.setTakeLayersSnapshotProtoFunction( + [&](uint32_t traceFlags, + const LayerTracing::OnLayersSnapshotCallback& onLayersSnapshot) { + // Do not wait the future to avoid deadlocks + // between main and Perfetto threads (b/313130597) + static_cast<void>(mScheduler->schedule( + [&, onLayersSnapshot]() FTL_FAKE_GUARD(mStateLock) + FTL_FAKE_GUARD(kMainThreadContext) { + auto snapshot = + takeLayersSnapshotProto(traceFlags, TimePoint::now(), + mLastCommittedVsyncId, true); + onLayersSnapshot(std::move(snapshot)); + })); + }); // Commit secondary display(s). processDisplayChangesLocked(); |