From 9fc8d1afb9268cb4062f5a4f93ba90f42807c020 Mon Sep 17 00:00:00 2001 From: low-batt <86170219+low-batt@users.noreply.github.com> Date: Sat, 1 Jan 2022 15:57:36 -0500 Subject: [PATCH] Fix deadlock in VideoView.uninit method, #11 This commit will add locking of the OpenGL context to the VideoView.uninit method in order to match the order of lock acquisition the ViewLayer.draw methods use. --- iina/VideoView.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/iina/VideoView.swift b/iina/VideoView.swift index e4990d4a1c2..4284c5068aa 100644 --- a/iina/VideoView.swift +++ b/iina/VideoView.swift @@ -79,16 +79,18 @@ class VideoView: NSView { } func uninit() { + // Order of locking must match the draw methods in ViewLayer. + player.mpv?.lockAndSetOpenGLContext() uninitLock.lock() - - guard !isUninited else { + defer { uninitLock.unlock() - return + player.mpv?.unlockOpenGLContext() } + guard !isUninited else { return } + player.mpv.mpvUninitRendering() isUninited = true - uninitLock.unlock() } deinit {