[vlc-commits] [Git][videolan/vlc][3.0.x] caopengllayer: fix using layer outside of main thread

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Tue Feb 27 11:38:29 UTC 2024



Felix Paul Kühne pushed to branch 3.0.x at VideoLAN / VLC


Commits:
b7843ec8 by Alexandre Janniaux at 2024-02-27T11:14:30+00:00
caopengllayer: fix using layer outside of main thread

When stopping the playback, vout_display_t destructor will call the
[VideoView vlcClose] which references the backing CALayer through [self
layer]. This function is not thread-safe and should only be called from
the main thread, leading to reports and crashes when using the main
thread checker.

Instead, since we allocate the layer and references it from the
vout_display_t implementation, just send the vlcClose message on the
stored layer directly. Since it's only used to pass from the vd from the
view to the layer, and it's initialized from a dispatch_sync() in the
Open() function, there won't be race de-initializing them in a
non-synchronized fashion like done in this commit.

Fixes #27513

(cherry picked from commit 79e1535af5937901636529930a52e70546c6fec5)

- - - - -


1 changed file:

- modules/video_output/caopengllayer.m


Changes:

=====================================
modules/video_output/caopengllayer.m
=====================================
@@ -408,6 +408,7 @@ static void Close(vlc_object_t *p_this)
     vout_display_sys_t *sys = vd->sys;
 
     atomic_store(&sys->is_ready, false);
+    [sys->videoLayer vlcClose];
     [sys->videoView vlcClose];
 
     if (sys->vgl && !vlc_gl_MakeCurrent(sys->gl)) {
@@ -581,7 +582,6 @@ static int Control(vout_display_t *vd, int query, va_list ap)
 - (void)vlcClose
 {
     @synchronized (self) {
-        [(VLCCAOpenGLLayer *)self.layer vlcClose];
         _vlc_vd = NULL;
     }
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b7843ec8915ef2f37e712dd23a3324c00dd2a4a9

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b7843ec8915ef2f37e712dd23a3324c00dd2a4a9
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list