mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-26 05:10:20 +00:00
only try locking the mutex for an animation frame
the animation_frame_callback function shall never be blocked by waiting for the mutex to unlock. This is because the CVDiplayLink* funtions will try to acquire a mutex that is locked during the call to animation_frame_callback. This can lead to a dead lock scenario when one thread handles an event, the animation thread waits for this event to be handled but the handling of said event requires to unlock the CVDisplayLink mutex...
This commit is contained in:
parent
baeca7d182
commit
e75afe9474
1 changed files with 8 additions and 1 deletions
|
@ -363,7 +363,14 @@ static callback_type* event_handler[] = {
|
|||
|
||||
extern pthread_mutex_t g_event_mutex;
|
||||
void event_post(struct event *event) {
|
||||
pthread_mutex_lock(&g_event_mutex);
|
||||
if (event->type == ANIMATOR_REFRESH) {
|
||||
// If the mutex is locked, we drop the animation refresh cycle to avoid
|
||||
// deadlocking occuring due to the CVDisplayLink
|
||||
if (pthread_mutex_trylock(&g_event_mutex) != 0) return;
|
||||
} else {
|
||||
pthread_mutex_lock(&g_event_mutex);
|
||||
}
|
||||
|
||||
event_handler[event->type](event->context);
|
||||
windows_unfreeze();
|
||||
pthread_mutex_unlock(&g_event_mutex);
|
||||
|
|
Loading…
Reference in a new issue