Switching controllers cause crash

iOS, iPad, iPhone, tvOS specific usage questions
linked
Blank Cone
Blank Cone
Posts: 41
Joined: 28 Nov 2014 09:12

Switching controllers cause crash

Postby linked » 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:

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); }
Sometimes it crash in BackgroundWorkerCancel, most of the time in mutex lock line:

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];
and a bit later the play part:

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];
To stop the player i use this code, i have test with _mediaplayer = nil at the end too without improvements:

Code: Select all

if (_mediaplayer) { if (_mediaplayer.media) [_mediaplayer stop]; }
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 ?

Code: Select all

NSArray* options = @[ @"--verbose=0", @"--no-interact" ];
Edit 2:
No crash with nil as options:

Code: Select all

_mediaplayer = [[VLCMediaPlayer alloc] initWithOptions:nil];
The problem is i need --no-interact

Return to “VLC for iOS, iPadOS and Apple TV”

Who is online

Users browsing this forum: No registered users and 9 guests