[vlc-devel] [PATCH] vout/macosx: simplify close and make sure all AppKit objects are released on the main thread
Thomas Guillem
thomas at gllm.fr
Wed Sep 18 08:58:33 CEST 2019
We already know that we should not wait for the mainthread from the Close function, so it should be async.
Why not using something like this ?
[sys->glView performSelectorOnMainThread:@selector(release)
withObject:nil
waitUntilDone:NO];
On Wed, Sep 18, 2019, at 07:11, Felix Paul Kühne wrote:
> Hi David,
>
> > On 17. Sep 2019, at 23:10, David Fuhrmann <david.fuhrmann at gmail.com> wrote:
> >
> >
> >> Am 17.09.2019 um 22:12 schrieb Felix Paul Kühne <fkuehne at videolan.org>:
> >>
> >> From: Felix Paul Kühne <felix at feepk.net>
> >>
> >> Note that this does _not_ solve #22766.
> >> ---
> >> modules/video_output/macosx.m | 29 +++++++++++++----------------
> >> 1 file changed, 13 insertions(+), 16 deletions(-)
> >>
> >> diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
> >> index 6290bbf763..5f618a0716 100644
> >> --- a/modules/video_output/macosx.m
> >> +++ b/modules/video_output/macosx.m
> >> @@ -265,21 +265,20 @@ static void Close(vout_display_t *vd)
> >> [sys->glView setVoutDisplay:nil];
> >>
> >> var_Destroy (vd, "drawable-nsobject");
> >> - if ([(id)sys->container respondsToSelector:@selector(removeVoutSubview:)])
> >> - /* This will retain sys->glView */
> >> - [(id)sys->container performSelectorOnMainThread:@selector(removeVoutSubview:)
> >> - withObject:sys->glView
> >> - waitUntilDone:NO];
> >> -
> >> - /* release on main thread as explained in Open() */
> >> - [(id)sys->container performSelectorOnMainThread:@selector(release)
> >> - withObject:nil
> >> - waitUntilDone:NO];
> >> - [sys->glView performSelectorOnMainThread:@selector(removeFromSuperview)
> >> - withObject:nil
> >> - waitUntilDone:NO];
> >> -
> >> var_Destroy(vlc_object_parent(vd), "macosx-glcontext");
> >> +
> >> + dispatch_sync(dispatch_get_main_queue(), ^{
> >
> > As briefly discussed over chat, my fear is that this switch from async to sync deadlocks once closing VLC with a running video.
> >
> > In fact, I can easily reproduce this with your patch applied, just try to quit VLC while a video is running:
>
> I don’t oppose using async here. The main issue I want to resolve is
> that [sys->glView release]; is currently called from a background
> thread while this AppKit object is created on the main thread, so the
> release should happen on the main thread, too.
>
> Best regards,
>
> Felix
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list