client-sdk-unity-web icon indicating copy to clipboard operation
client-sdk-unity-web copied to clipboard

hardware camera not releasing when disconnect and reconnect in another room

Open leandro-zanardi opened this issue 1 year ago • 4 comments

If you connect a room room.Connect(url, token) then you disconnect from room room.Disconect(true)

and so connect again in a different room with other token and roomName, the video track stack, and camera hardware never turn off.

publishing track {localTrack: LocalVideoTrack} publishing track {localTrack: LocalVideoTrack} publishing track {localTrack: LocalVideoTrack}

and no way to unpublish and release de camera. even doing a disconnection again, the track keep stacking

leandro-zanardi avatar Mar 07 '23 02:03 leandro-zanardi

how to fully destroy a local Track? from c# before disconnect room, to prevent it keep stacking?

Client.CreateLocalVideoTrack(opts);

has no way to be destroyed

leandro-zanardi avatar Mar 07 '23 19:03 leandro-zanardi

Hey, you should be able to unpublish a track using LocalParticipant.UnpublishTrack.

theomonnom avatar Mar 19 '23 21:03 theomonnom

It remove from unity, not from JS. In my case, the user can change many times of Room, when user change a room, even the room destroyed, the JS object still having listeners and alive in the DOM. From the C# side, has no way to clear the JS object complete. If you use only one room is fine, use the LocalParticipant.UnpublishTrack, but in the next room you enter, it will be stacked in the HTML DOM.

leandro-zanardi avatar Mar 22 '23 19:03 leandro-zanardi

Hey, sorry for the late answer. The DOM objects will not be directly deleted because of the C# GC. You can try to call Room.Dispose when you're done with it. You should still be able to turn off the hardware camera even if the DOM is still present. Removing the listeners from the Room object on destroy is tricky (can lead to Null references when an event is called in a certain timing). I will experiment with another way of dealing with listeners after releasing the native SDK :)

theomonnom avatar Apr 10 '23 06:04 theomonnom