From 0408363863bc6c5913f4d84fa333d0ddb636b20b Mon Sep 17 00:00:00 2001 From: xiaowei guan Date: Tue, 22 Aug 2023 20:37:05 +0800 Subject: [PATCH] Add lock for thread safe --- flutter/shell/platform/tizen/flutter_tizen_engine.cc | 2 ++ flutter/shell/platform/tizen/flutter_tizen_engine.h | 1 + 2 files changed, 3 insertions(+) diff --git a/flutter/shell/platform/tizen/flutter_tizen_engine.cc b/flutter/shell/platform/tizen/flutter_tizen_engine.cc index 539224f..b106177 100644 --- a/flutter/shell/platform/tizen/flutter_tizen_engine.cc +++ b/flutter/shell/platform/tizen/flutter_tizen_engine.cc @@ -216,6 +216,7 @@ bool FlutterTizenEngine::RunEngine() { vsync_waiter_ = std::make_unique(this); args.vsync_callback = [](void* user_data, intptr_t baton) -> void { auto* engine = static_cast(user_data); + std::lock_guard lock(engine->vsync_mutex_); if (engine->vsync_waiter_) { engine->vsync_waiter_->AsyncWaitForVsync(baton); } @@ -268,6 +269,7 @@ bool FlutterTizenEngine::StopEngine() { callback(registrar); } #ifndef WEARABLE_PROFILE + std::lock_guard lock(vsync_mutex_); if (vsync_waiter_) { vsync_waiter_.reset(); } diff --git a/flutter/shell/platform/tizen/flutter_tizen_engine.h b/flutter/shell/platform/tizen/flutter_tizen_engine.h index 6108d63..d93523f 100644 --- a/flutter/shell/platform/tizen/flutter_tizen_engine.h +++ b/flutter/shell/platform/tizen/flutter_tizen_engine.h @@ -272,6 +272,7 @@ class FlutterTizenEngine { std::unique_ptr renderer_; #ifndef WEARABLE_PROFILE + std::mutex vsync_mutex_; // The vsync waiter for the embedder. std::unique_ptr vsync_waiter_; #endif