Switching controllers cause crash
Posted: 01 Aug 2018 22:27
Hello,
I just compiled latest LibVLCKit today for my IOS app and can't resolve a crash problem.
Here is how i get the crash:
Go from Screen A (menu) to Screen B (vlc player) and close Screen B to go back to A.
Repeat this a second time and when back to Screen A, the app crash.
It's a EXC_BAD_ACCESS crash, i guess it try to access closed vlc instance somewhere.
Most of the time i crash in libvlc_MetadataCancel:
Sometimes it crash in BackgroundWorkerCancel, most of the time in mutex lock line:
I use nearly the same code as in the sample Drop in player.
I use this code one time when screen appear:
and a bit later the play part:
To stop the player i use this code, i have test with _mediaplayer = nil at the end too without improvements:
While on the player screen, i can stop/resume and switch stream with some buttons but going screen back and fort make it crash.
It's like calling the initWithOptions line again create a second player somewhere and calling stop ask to stop both player but since one no more exist or is stopped, it crash:
I have found that addind _mediaplayer = nil in the stop part and calling the initWithOptions line again create the same crash after calling stop the second time when i stop/resume the player WHILE on the same screen.
Any idea what i do wrong or what is missing to correctly start/stop/kill the VLCMediaPlayer ?
Edit:
I just found if i replace initWithOptions with init, there is no more crash !!!!
Does it come from my options ?
Edit 2:
No crash with nil as options:
The problem is i need --no-interact
I just compiled latest LibVLCKit today for my IOS app and can't resolve a crash problem.
Here is how i get the crash:
Go from Screen A (menu) to Screen B (vlc player) and close Screen B to go back to A.
Repeat this a second time and when back to Screen A, the app crash.
It's a EXC_BAD_ACCESS crash, i guess it try to access closed vlc instance somewhere.
Most of the time i crash in libvlc_MetadataCancel:
Code: Select all
void libvlc_MetadataCancel(libvlc_int_t *libvlc, void *id)
{
libvlc_priv_t *priv = libvlc_priv(libvlc);
if (unlikely(priv->parser == NULL)) // <--------- crash here
return;
playlist_preparser_Cancel(priv->parser, id);
}
Code: Select all
static void BackgroundWorkerCancel( struct background_worker* worker, void* id)
{
vlc_mutex_lock( &worker->lock );
for( size_t i = 0; i < vlc_array_count( &worker->tail.data ); )
{
struct bg_queued_item* item =
vlc_array_item_at_index( &worker->tail.data, i );
if( id == NULL || item->id == id )
{
vlc_array_remove( &worker->tail.data, i );
worker->conf.pf_release( item->entity );
free( item );
continue;
}
++i;
}
while( ( id == NULL && worker->head.active )
|| ( id != NULL && worker->head.id == id ) )
{
worker->head.deadline = VLC_TS_0;
vlc_cond_signal( &worker->head.worker_wait );
vlc_cond_signal( &worker->tail.wait );
vlc_cond_wait( &worker->head.wait, &worker->lock );
}
vlc_mutex_unlock( &worker->lock );
}
I use nearly the same code as in the sample Drop in player.
I use this code one time when screen appear:
Code: Select all
_mediaplayer = [[VLCMediaPlayer alloc] initWithOptions:options];
Code: Select all
[_mediaplayer stop];
VLCMedia *media = [[VLCMedia alloc] initWithURL:[NSURL URLWithString:mAdresseComplete]];
_mediaplayer.delegate = (id)self;
_mediaplayer.drawable = self.movieView;
_mediaplayer.media = media;
[_mediaplayer play];
Code: Select all
if (_mediaplayer) {
if (_mediaplayer.media)
[_mediaplayer stop];
}
It's like calling the initWithOptions line again create a second player somewhere and calling stop ask to stop both player but since one no more exist or is stopped, it crash:
I have found that addind _mediaplayer = nil in the stop part and calling the initWithOptions line again create the same crash after calling stop the second time when i stop/resume the player WHILE on the same screen.
Any idea what i do wrong or what is missing to correctly start/stop/kill the VLCMediaPlayer ?
Edit:
I just found if i replace initWithOptions with init, there is no more crash !!!!
Does it come from my options ?
Code: Select all
NSArray* options = @[
@"--verbose=0",
@"--no-interact"
];
No crash with nil as options:
Code: Select all
_mediaplayer = [[VLCMediaPlayer alloc] initWithOptions:nil];