From 785aa6c3325aa7f71602e7c381800caa3b392d91 Mon Sep 17 00:00:00 2001 From: wwwcg Date: Fri, 3 Jan 2025 19:01:36 +0800 Subject: [PATCH] fix(ios): occasional crash of CFRunloop in looper driver --- modules/footstone/src/platform/ios/looper_driver.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/footstone/src/platform/ios/looper_driver.cc b/modules/footstone/src/platform/ios/looper_driver.cc index eac5e0d0bcb..f46cd245eca 100644 --- a/modules/footstone/src/platform/ios/looper_driver.cc +++ b/modules/footstone/src/platform/ios/looper_driver.cc @@ -48,6 +48,8 @@ LooperDriver::LooperDriver(): loop_() { LooperDriver::~LooperDriver() { CFRunLoopTimerInvalidate(delayed_wake_timer_); CFRunLoopRemoveTimer(loop_, delayed_wake_timer_, kCFRunLoopDefaultMode); + CFRelease(delayed_wake_timer_); + CFRelease(loop_); } void LooperDriver::Notify() { @@ -63,7 +65,9 @@ void LooperDriver::WaitFor(const TimeDelta& delta, std::unique_lock& } void LooperDriver::Start() { + // note that `loop_` created on dom thread but release on main thread loop_ = CFRunLoopGetCurrent(); + CFRetain(loop_); CFRunLoopAddTimer(loop_, delayed_wake_timer_, kCFRunLoopDefaultMode); while (true) { if (IsExitImmediately()) {