Android crash: local reference table overflow by AudioTrack AudioRecord

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I’ve got an existing windows based project which uses the base PJSUA API (from release 2.4.5). I’m trying to build an android app using this api.

 

I’ve followed the Getting-Started/Android instructions to build libpjsua2.so without video support.

The framework I’m using for app development allows building  native android extensions (rather than using java) so I’ve grabbed libpjsua2.so and the headers from pjlib, pjlib-util, pjmedia, pjnath and pjsip folders.

I’ve built an extension framework using this which seems to be functional, I’m able to make/receive calls and register with a registrar.

I’ve now set up a longer term test. Essentially a secondary device is calling my android device and hanging up, continuously.

I’m finding that once the android app receives ~250 calls it crashes with the following:
06-21 11:08:53.350  4459  4484 E dalvikvm: JNI ERROR (app bug): local reference table overflow (max=512)

06-21 11:08:53.350  4459  4484 W dalvikvm: JNI local reference table (0x627fa7b0) dump:

06-21 11:08:53.350  4459  4484 W dalvikvm:   Last 10 entries (of 512):

06-21 11:08:53.350  4459  4484 W dalvikvm:       511: 0x418044c0 int[] (1 elements)

06-21 11:08:53.350  4459  4484 W dalvikvm:       510: 0x418044d8 java.lang.ref.WeakReference

06-21 11:08:53.350  4459  4484 W dalvikvm:       509: 0x41804420 android.media.AudioTrack

06-21 11:08:53.350  4459  4484 W dalvikvm:       508: 0x41804420 android.media.AudioTrack

06-21 11:08:53.350  4459  4484 W dalvikvm:       507: 0x41804350 android.media.AudioRecord

06-21 11:08:53.350  4459  4484 W dalvikvm:       506: 0x418f22e8 android.media.AudioTrack

06-21 11:08:53.350  4459  4484 W dalvikvm:       505: 0x418f2228 android.media.AudioRecord

06-21 11:08:53.350  4459  4484 W dalvikvm:       504: 0x419695e0 android.media.AudioTrack

06-21 11:08:53.350  4459  4484 W dalvikvm:       503: 0x41969510 android.media.AudioRecord

06-21 11:08:53.350  4459  4484 W dalvikvm:       502: 0x41997038 android.media.AudioTrack

06-21 11:08:53.350  4459  4484 W dalvikvm:   Summary:

06-21 11:08:53.350  4459  4484 W dalvikvm:         6 of java.lang.String (6 unique instances)

06-21 11:08:53.350  4459  4484 W dalvikvm:         1 of int[] (1 elements)

06-21 11:08:53.350  4459  4484 W dalvikvm:         1 of java.lang.ref.WeakReference

06-21 11:08:53.350  4459  4484 W dalvikvm:       251 of android.media.AudioRecord (251 unique instances)

06-21 11:08:53.350  4459  4484 W dalvikvm:       252 of android.media.AudioTrack (251 unique instances)

06-21 11:08:53.350  4459  4484 W dalvikvm:         1 of com.ideaworks3d.marmalade.LoaderThread

06-21 11:08:53.350  4459  4484 E dalvikvm: Failed adding to JNI local ref table (has 512 entries)

06-21 11:08:53.350  4459  4484 I dalvikvm: "Thread-290" prio=5 tid=11 RUNNABLE

06-21 11:08:53.350  4459  4484 I dalvikvm:   | group="main" sCount=0 dsCount=0 obj=0x410335b8 self=0x59fd8690

06-21 11:08:53.350  4459  4484 I dalvikvm:   | sysTid=4484 nice=0 sched=0/0 cgrp=apps handle=1528506816

06-21 11:08:53.350  4459  4484 I dalvikvm:   | state=R schedstat=( 0 0 0 ) utm=91469 stm=30801 core=1

06-21 11:08:53.350  4459  4484 I dalvikvm:   at android.media.AudioTrack.native_setup(Native Method)

06-21 11:08:53.350  4459  4484 I dalvikvm:   at android.media.AudioTrack.<init>(AudioTrack.java:326)

06-21 11:08:53.350  4459  4484 I dalvikvm:   at android.media.AudioTrack.<init>(AudioTrack.java:267)

06-21 11:08:53.350  4459  4484 I dalvikvm:   at com.ideaworks3d.marmalade.LoaderThread.runNative(Native Method)

06-21 11:08:53.350  4459  4484 I dalvikvm:   at com.ideaworks3d.marmalade.LoaderThread.run(LoaderThread.java:1137)

06-21 11:08:53.350  4459  4484 I dalvikvm:

06-21 11:08:53.350  4459  4484 E dalvikvm: VM aborting

06-21 11:08:53.350  4459  4484 F libc    : Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 4484 (Thread-290)

Looking at the pjsip library sources in android_jni_dev.c, I’ve established the following:

Whenever the record and track class+object references are obtained, ‘Creating Android JNI stream’ is logged.

Whenever the record classes+object references are released ‘Audio record released’ is logged.

Whenever the track classes+object references are released ‘Audio track released’ is logged.

Due to this, I’ve checked the logs over a time period where the android application crashed, verifying that the number of times ‘Audio record released’ is logged matches the number of times ‘Creating Android JNI stream’ is logged (also checked for track as well).

Since these match, I’m confused as to what’s going on. It seems like the references are being released in c++ but not being released in java. The only way I can imagine this could happen is if the release from c++ doesn’t actually release the reference but marks it for later removal and some background process which is meant to do the clean-up isn’t happening.

 

I’m currently looking through the java-swig pjsip interface to see if I can find anything which may resolve this issue, but I’m not entirely sure what I’m looking for.

 

Does anyone know how to fix this/any other ways to approach this than staring at the java-swig interface?



_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux