Laerdal / Xamarin.AzureCommunicationCalling

Xamarin iOS and Android binding libraries for Microsofts Azure Communication Services
MIT License
36 stars 11 forks source link

can't render local camera on android more than once #23

Closed MhAllan closed 2 years ago

MhAllan commented 2 years ago

I tried the android library, I am using Join Group and it works fine for the first time, but after that it doesn't render local camera, no matter, there are no errors, and the renderer is creating native view, but it just doesn't show anything. I tried to dispose the call, the camera, the agent, the device manager, some of them, all of them, still no luck.

Edit 1, After experimenting, the second call will succeed if I chose another camera next time. so the problem is the camera disposing not happening: VideoDeviceInfo.Dispose() not doing anything

Edit2, disposing local renderer make it work

Edit3,

using wrapper method to dispose objects like this Dispose(IDisposable obj) will not work, while Dispose(dynamice obj) will work

tompi commented 2 years ago

Hey @MhAllan , not sure Im reading your edits correctly, but did you make it work by disposing the local renderer?

Not sure I understand what you mean by edit nr 3...

The example app should work fine with multiple repeated calls to a group conv?

MhAllan commented 2 years ago

Yes it works if we dispose the renderer, I was using helper method to dispose the objects

void Dispose(IDisposable obj)
{
    if(obj == null) return;
    try
    { 
         obj.Dispose();
    }
    catch(Exception ex)
    {
        _logger.LogError(ex);
    }
}

Surprisingly, that doesn't dispose the objects. But if you dispose the objects directly without this helper method _camera.Dispose() or changed the signature of that helper method to void Dispose(dynamice obj) then it will work. It is very weird

tompi commented 2 years ago

@MhAllan Since you can explicitly implement interfaces(like IDisposable) calling ((IDisposable)obj)Dispose() and obj.Dispose() doesnt have to be calling the same method... Im assuming this is an effect of the binding, will try to have a look when I get around to upgrading android lib to latest ACS version.

tompi commented 2 years ago

should be fixed in the latest releases