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];