LibVLC for Android - JNI Error

This forum is about all development around libVLC.
liutingdu
New Cone
New Cone
Posts: 9
Joined: 22 Sep 2014 18:05
VLC version: Android 0.9.10
Operating System: Mac OS
Location: Dublin

LibVLC for Android - JNI Error

Postby liutingdu » 22 Sep 2014 19:07

Hi,

I am working on an Android application that embedded LibVLC to play RTSP streams.

I compiled LibVLC for Android(version 0.9.9) and imported the compiled code into my Android project.

I am following this samplehttps://bitbucket.org/edwardcw/libvlc-a ... ?at=master

The main codes are :

Code: Select all

// Create a new media player libvlc = LibVLC.getInstance(); libvlc.setHardwareAcceleration(LibVLC.HW_ACCELERATION_DISABLED); libvlc.setSubtitlesEncoding(""); libvlc.setAout(LibVLC.AOUT_OPENSLES); libvlc.setTimeStretching(true); libvlc.setChroma("RV32"); libvlc.setVerboseMode(true); LibVLC.restart(this); EventHandler.getInstance().addHandler(mHandler); holder.setFormat(PixelFormat.RGBX_8888); holder.setKeepScreenOn(true); MediaList list = libvlc.getMediaList(); list.clear(); list.add(new Media(libvlc, LibVLC.PathToURI(media)), false); libvlc.playIndex(0);
It works well with playing the single URL once.

But if I return to the previous activity and attempt to play it again, it will crash at this line:

Code: Select all

LibVLC.restart(this);
And the error showing in LogCat is: 'JNI ERROR (app bug): attempt to use stale local reference'

After researching about this, it actually crashes at ''destroy_native_crash_handler()' in 'native_crash_handler.c'. It's a very similar issue with https://code.google.com/p/dolphin-playe ... tail?id=19

Then did a temporary fix: deleted this line: '(*env)->DeleteGlobalRef(env, j_libVLC);' from 'native_crash_handler.c', recompiled it and import the recompiled native code into my project, the crash is gone.

But I am afraid that the way I fixed it will cause other problems because I am new to JNI and know nothing about LibVLC.

Is it possible that it's a bug? Or maybe I am not using 'LibVLC.java' in the proper way but I couldn't find any other samples around usage of this class.

Any help in this matter would be highly appreciated.

Thanks a lot!
Liuting

tylerjroach
New Cone
New Cone
Posts: 7
Joined: 22 Sep 2014 21:01

Re: LibVLC for Android - JNI Error

Postby tylerjroach » 22 Sep 2014 21:04

I was able to stop this same crash by removing these two lines from the releasePlayer() method.

libvlc.destroy();
libvlc = null;

liutingdu
New Cone
New Cone
Posts: 9
Joined: 22 Sep 2014 18:05
VLC version: Android 0.9.10
Operating System: Mac OS
Location: Dublin

Re: LibVLC for Android - JNI Error

Postby liutingdu » 23 Sep 2014 10:51

I was able to stop this same crash by removing these two lines from the releasePlayer() method.

libvlc.destroy();
libvlc = null;
Thanks it's working!


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 63 guests