ladendirekt / pjsip4net

A wrapper library exposing the pjsip library to the .NET world in a OO-friendly way.
71 stars 42 forks source link

Lock up of implemented UI. #107

Open rndthoughts opened 5 years ago

rndthoughts commented 5 years ago

Describe the bug

I have implemented pjsip4net in a WinForms (4.7.1) application and use the .Build.Start() function to start pjsip from Program.cs. Everything works correctly except I keep getting regular but intermittent UI lockups. I initially thought it would be because there are locks around procedures like "GetCallById" and multiple calls might be deadlocking the UI but i've removed all these and it still happens. I've also run a profiler on the code and I can't see any deadlocks occurring.

It doesn't appear to be a call state change, as it usually happens mid-call. The call is not dropped and the user's can still hear each other. I have no errors logged and nothing in the trace logs. The whole UI just freezes. I think pjsip is being hosted in the main UI thread but I'm not sure why this would lock the UI. Is there a way i can move it to another thread?

To Reproduce Steps to reproduce the behavior:

  1. Answer/Make a Call
  2. UI locks up mid-call

Expected behavior UI should stay responsive

Screenshots N/A Environment (please complete the following information):

App configuration (please complete the following information):

Additional context Add any other context about the problem here.

siniypin commented 5 years ago

Hi Steve,

as a rule of thumb you should run your SIP UserAgent in a background thread and update your UI through a SynchronizationContext making no downstream calls to pjsip4net in callbacks you'd dispatch.

Cheers

siniypin commented 5 years ago

I've concluded that it is a decision app developers supposed to make on their own, whether to dispatch events to any SyncCtx present.

siniypin commented 5 years ago

Here, found some old samples: https://gist.github.com/siniypin/5f403be8dc6e5b2f802e926c1b7855d3

rndthoughts commented 5 years ago

Thanks, I'll take a look!

siniypin commented 5 years ago

Hi Steve,

did it work for you? Care to share your findings?