Merge "Acquire the context lock before reading color buffer" am: cffc73e893 am: 2fb49c7815 am: fa21dba60f am: 10e1c4ffd0 am: 9f4b095174 am: f17d4ee120

Original change: https://android-review.googlesource.com/c/device/generic/vulkan-cereal/+/2600792

Change-Id: If697c18a317a3c8375a7dd3d8e23d29d3994fc36
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
GitOrigin-RevId: 2d1334cc99846589ee3923676b060808432f0687
diff --git a/host/FrameBuffer.cpp b/host/FrameBuffer.cpp
index 2fb1c7c..967f961 100644
--- a/host/FrameBuffer.cpp
+++ b/host/FrameBuffer.cpp
@@ -3703,6 +3703,12 @@
 }
 
 bool FrameBuffer::invalidateColorBufferForVk(HandleType colorBufferHandle) {
+    // It reads contents from GL, which requires a context lock.
+    // Also we should not do this in PostWorkerGl, otherwise it will deadlock.
+    //
+    // b/283524158
+    // b/273986739
+    AutoLock mutex(m_lock);
     auto colorBuffer = findColorBuffer(colorBufferHandle);
     if (!colorBuffer) {
         ERR("Failed to find ColorBuffer:%d", colorBufferHandle);