Skip to content

Commit

Permalink
Better fix for macOS deadlock
Browse files Browse the repository at this point in the history
Fix it in glfw. Dont hold the tick lock when calling the tick callback
as the tick callback might be waiting on a lock.
  • Loading branch information
kovidgoyal committed Oct 25, 2023
1 parent 61c4f80 commit ae4a13b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions glfw/cocoa_init.m
Original file line number Diff line number Diff line change
Expand Up @@ -1020,12 +1020,15 @@ void _glfwPlatformTerminate(void)

void _glfwDispatchTickCallback(void) {
if (tick_lock && tick_callback) {
[tick_lock lock];
while(tick_callback_requested) {
while(true) {
bool do_call = true;
[tick_lock lock];
if (!tick_callback_requested) do_call = false;
tick_callback_requested = false;
tick_callback(tick_callback_data);
[tick_lock unlock];
if (do_call) tick_callback(tick_callback_data);
else break;
}
[tick_lock unlock];
}
}

Expand Down

0 comments on commit ae4a13b

Please sign in to comment.