From 99548085ed3ca3c3c37e399ed6400839a2f2b922 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 18 Oct 2023 12:07:46 -0700 Subject: [PATCH] [Impeller] Guard execution of ReactorGLES operations with a mutex Both the raster and IO threads can flush the ops queue. The reactor must ensure that execution of queued ops is serialized. Fixes https://github.com/flutter/flutter/issues/135524 --- impeller/renderer/backend/gles/reactor_gles.cc | 4 ++++ impeller/renderer/backend/gles/reactor_gles.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/impeller/renderer/backend/gles/reactor_gles.cc b/impeller/renderer/backend/gles/reactor_gles.cc index dfd26f3dde09d..df22c68573a80 100644 --- a/impeller/renderer/backend/gles/reactor_gles.cc +++ b/impeller/renderer/backend/gles/reactor_gles.cc @@ -159,6 +159,10 @@ bool ReactorGLES::React() { } TRACE_EVENT0("impeller", "ReactorGLES::React"); while (HasPendingOperations()) { + // Both the raster thread and the IO thread can flush queued operations. + // Ensure that execution of the ops is serialized. + Lock execution_lock(ops_execution_mutex_); + if (!ReactOnce()) { return false; } diff --git a/impeller/renderer/backend/gles/reactor_gles.h b/impeller/renderer/backend/gles/reactor_gles.h index 801542b4fb27a..00cd7ceff4656 100644 --- a/impeller/renderer/backend/gles/reactor_gles.h +++ b/impeller/renderer/backend/gles/reactor_gles.h @@ -69,6 +69,7 @@ class ReactorGLES { std::unique_ptr proc_table_; + Mutex ops_execution_mutex_; mutable Mutex ops_mutex_; std::vector ops_ IPLR_GUARDED_BY(ops_mutex_); @@ -88,7 +89,7 @@ class ReactorGLES { bool can_set_debug_labels_ = false; bool is_valid_ = false; - bool ReactOnce(); + bool ReactOnce() IPLR_REQUIRES(ops_execution_mutex_); bool HasPendingOperations() const;