Re: pjsua2 crash in endpoint.libCreate Android

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

 



I have been able to progress a little bit more. It seems that JNI_OnLoad is not called for Xamarin.Android applications (probably because Xamarin does not load the libraries using the standard System.loadlibrary methods). This leaves the  pj_jni_jvm (JavaVM pointer) as undefined. For Endpoint.LibCreate, JavaVM pointer was used for creating GUIDs. So I went ahead and used the code from guid_simple.c to create GUIDs. So I was able to get around Endpoint.LibCreate crashing and have the application register with the SIP server.

However the JavaVM pointer is used in a couple of other locations, the most important place being android_jni_dev.c. The program would crash when calling Endpoint.audDevManager().setCaptureDev(). If I modify the attach_jvm function in android_jni_dev.c and add the following at the beginning:
if (!pj_jni_jvm) {
    PJ_LOG(1,(THIS_FILE, "ERROR: JNI JavaVM was not initialized."));
    return PJ_FALSE;
}

I don't have the crash anymore but there wouldn’t be any audio during calls obviously since there is no audio devices.

I tried to use JNI_GetCreatedJavaVMs, to get the JavaVM pointer since JNI_OnLoad is not called. However, NDK does not export this method for some reason, so I get undefined reference when linking the code.

Does anybody have any clues on how I can get around this? I’m not sure if anybody has successfully used pjsip with Xamarin.Android. This seems to be the last problem I need to solve, since the application runs through ok, but no audio.

Is there a way to use android audio device without using the JavaVM pointer?

Thanks in advance for any help.

On May 15, 2020, at 1:42 AM, Dirar Abu-Saymeh <dirar.abusaymeh@xxxxxxxxxxxxx> wrote:

After further debugging it seems LibCreate is crashing in the function “attach_jvm. It seems the variable pj_jni_jvm is not defined.

In googling possible reasons, the only solution that was posted to make sure the config_site.h is properly defined for android which in my case it is:

#define PJ_CONFIG_ANDROID 1
#include <pj/config_site_sample.h>

Does anybody have any suggestions on what could be causing this?

Regards
--------
Hi,

I have been trying to integrate pjsip into my Xamarin.Forms app. I have successfully gotten the iOS version to work, but have been facing a crash on the Android version and have not found a solution for it. I tried all pjsip versions from 2.6 to 2.10 with the same issue. I also went back to the sample pjsua2xamarin application and I get the same crash. 

Crash log:
[Mono] Found as 'CSharp_pjsua2xamarinfpjsua2_Endpoint_libCreate___'.
[libc] Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 30101 

What I have done:
1. Followed instructions in ticket 2086.
2. Followed pjsip instructions on how to build for Android https://trac.pjsip.org/repos/wiki/Getting-Started/Android <https://trac.pjsip.org/repos/wiki/Getting-Started/Android>
3. Added the following android permissions in Manifest just to be comprehensive since ticket 2086 mentions that crash in the initialization phase is most probably related to permissions:
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.USE_SIP" />
    <uses-permission android:name="android.permission.CAMERA" />
4. I’m trying to run in an emulator and android sdk version 22, so I don’t have to worry about requesting permissions

5. I have also tried different ndk versions from r13b to r20 and tried targeting various android sdk levels

6. I used the following configure parameters: APP_PLATFORM=android-18 TARGET_ABI=x86 ./configure-android --use-ndk-cflags --disable-video

I’m not sure what I can do to debug this issue. Has nay body ran into this issues? Any suggestions on what I can do/try next?


_______________________________________________
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