Re: [android] destroy endpoint on call -crash GC

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

 



I try with GC and add Thread.Sleep after GC helps :) but I'm not sure that is good way to fix it. Perhaps there will be some situations where time in sleep will be to short.

but for now it works

Thanks
Andrzej

W dniu 2017-02-07 o 10:56, Michael Barthold pisze:
	// try to force GC to do its job before destroying the library, since it's
	// recommended to do that by PJSUA examples
            Runtime.getRuntime().gc();
	Thread.sleep(100);

mit freundlichen Grüßen | kind regards

Michael Barthold
Senior Software Architect


-----Ursprüngliche Nachricht-----
Von: pjsip [mailto:pjsip-bounces@xxxxxxxxxxxxxxx] Im Auftrag von frogersik
Gesendet: Dienstag, 7. Februar 2017 10:49
An: pjsip list <pjsip@xxxxxxxxxxxxxxx>
Betreff:  [android] destroy endpoint on call -crash GC

Hi,
Sorry for long post, but it cannot be shorter.
I have huge problem with deinit endpoint during call. I'm using latest version of pjsip (2.6) build stack with ndk 11. When I call
Endpoint.delete() or Endpoint.libDestroy() I get crash from lib.

My problem is connected with gc
(http://www.pjsip.org/docs/book-latest/html/intro_pjsua2.html#problems-with-garbage-collection)\

Do you know what kind of objects I need to delete before I want to deinitialize lib?

I want to do that when I lost connection, when I go out from WiFi or other user interaction with WiFi.

In these case I get two kinds of error:
1. "conf && port < conf->max_ports" failed (log in attachment) 2. "Calling pjlib from unknown/external thread." (log in attachment)

I also attach full log when I disconnect WiFi during call. As you can see. I try disconnect audio ports but it doesn't help.

BR, Andrzej

Here is my deinit procedure:
     void deInitialize(final SipService sipService)
     {
         Log.d(this, "deInitialize deleteAudioMedia();");
         deleteAudioMedia();
         Log.d(this, "deInitialize deleteCall();");
         deleteCall(sipService);
         Log.d(this, "deInitialize deleteAccount();");
         deleteAccount();
         try
         {
             IntVector transportVector = ep.transportEnum();
             for (int i = 0; i < transportVector.size(); i++)
             {
                 Log.d(this, "deInitialize transportClose();");
                 ep.transportClose(i);
             }
         }
         catch (Exception e)
         {
             Log.e(this, e);
         }
         Log.d(this, "deInitialize sipTpConfig.delete();");
         sipTpConfig.delete();
         sipTpConfig = null;
         try
         {
             Thread.sleep(3000);
             Log.d(this, "deInitialize ep.libDestroy();");
             ep.libDestroy();
         }
         catch (Exception e)
         {
             Log.e(this, e);
         }
         Log.d(this, "deInitialize ep.delete();");
         ep.delete();
         ep = null;
         sipService.notifyStackState(pjsua_state.PJSUA_STATE_NULL);
     }
	
	
	void deleteCall(final SipService sipService)
     {
         try
         {
             ep.hangupAllCalls();
             if (mSipAccount != null)
             {
                 Stream.of(mSipAccount.getCallIDs()).filter(callId -> callId != -1).forEach(callId -> {
                     SipCall call = mSipAccount.getCall(callId);
                     if (call != null)
                     {
                         call.delete();
                         call = null;
                     }
                     sipService.notifyCallDisconnected(callId);
                 });
             }
         }
         catch (Exception e)
         {
             Log.d(this, "deleteCall", e);
         }
     }

     void deleteAudioMedia()
     {
         try
         {
             AudioMediaVector audioMediaVector = ep.mediaEnumPorts();
             for (int i = 0; i < audioMediaVector.size(); i++)
             {
                 Log.d(this, "audioMedia deleted");
                 AudioMedia audioMedia = audioMediaVector.get(i);
                 ep.mediaRemove(audioMedia);
                 audioMedia.delete();
             }
             Log.d(this, "audDevManager deleted");
             ep.audDevManager().delete();
         }
         catch (Exception e)
         {
             Log.e(this, "deleteAudioMedia", e);
         }
     }
	
	void deleteAccount()
     {
         if (mSipAccount != null)
         {
             try
             {
                 mSipAccount.delete();
             }
             catch (final Exception e)
             {
                 Log.e(this, e);
             }
         }
         mSipAccount = null;
     }
	
	where
	
	ep - Endpoint
	mSipAccount - public class SipAccount extends Account


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

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



_______________________________________________
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