Skip to content

Commit

Permalink
fix(ios): occasional crash of CFRunloop in looper driver
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Jan 3, 2025
1 parent ea8f280 commit 785aa6c
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 @@ -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() {
Expand All @@ -63,7 +65,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 785aa6c

Please sign in to comment.