Skip to content

Commit

Permalink
fix(ios): occasional crash of CFRunloop in looper driver (#4164)
Browse files Browse the repository at this point in the history
Co-authored-by: OpenHippy <124017524+open-hippy@users.noreply.github.com>
  • Loading branch information
wwwcg and open-hippy authored Jan 3, 2025
1 parent 3b59a7d commit ee70684
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/footstone/src/platform/ios/looper_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,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() {
Expand All @@ -66,7 +68,9 @@ void LooperDriver::WaitFor(const TimeDelta& delta, std::unique_lock<std::mutex>&
}

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()) {
Expand Down

0 comments on commit ee70684

Please sign in to comment.