diff --git a/wm/include/vsync_station.h b/wm/include/vsync_station.h index 4fe4720771ec6edd6dfb1137b20f88706b7e76f5..3fdedaa24c1d630cb2595a3df27f95b240cbec13 100644 --- a/wm/include/vsync_station.h +++ b/wm/include/vsync_station.h @@ -48,6 +48,7 @@ private: VsyncStation() = default; static void OnVsync(int64_t nanoTimestamp, void* client); void VsyncCallbackInner(int64_t nanoTimestamp); + const std::string VSYNC_THREAD_ID = "vsync_thread"; std::shared_ptr mainHandler_ = nullptr; std::mutex lock_; std::atomic_bool hasRequestedVsync_ {false}; diff --git a/wm/src/vsync_station.cpp b/wm/src/vsync_station.cpp index a55d17d6cc91de15cb4713fe9f171d9241a65b11..39a5117f7f9d6a77795d74cf42b001bef957109b 100644 --- a/wm/src/vsync_station.cpp +++ b/wm/src/vsync_station.cpp @@ -33,11 +33,8 @@ void VsyncStation::RequestVsync(CallbackType type, std::shared_ptrsecond.insert(vsyncCallback); if (mainHandler_ == nullptr) { - if (AppExecFwk::EventRunner::GetMainEventRunner() == nullptr) { - WLOGFE("can not get main event runner."); - return; - } - mainHandler_ = std::make_shared(AppExecFwk::EventRunner::GetMainEventRunner()); + auto runner = AppExecFwk::EventRunner::Create(VSYNC_THREAD_ID); + mainHandler_ = std::make_shared(runner); } if (!hasRequestedVsync_) { mainHandler_->PostTask([this]() {