openvidu
openvidu copied to clipboard
Two attempts at videoElementDestroyed after unsusbcribe
Describe the bug This is just my guess. Possibly related to https://github.com/OpenVidu/openvidu/issues/129.
Occasionally, after unsubscribe, OpenVidu correctly removes its video element, emits videoElementDestroyed
and then attempts to do it again. The video element is no more there, so an error is produced.
Console:
OpenViduLogger.ts:31 Event 'videoElementDestroyed' triggered by 'Subscriber'
VideoElementEvent {hasBeenPrevented: false, cancelable: false, target: Subscriber, type: "videoElementDestroyed", element: video#remote-video-str_CAM_TuEE_con_NZFNg3QpWU}
VIDEO ELEMENT DESTROYED HANDLER CALLED
OpenViduLogger.ts:31 Unsubscribed correctly from con_NZFNg3QpWU
OpenViduLogger.ts:31 Inbound WebRTCPeer from 'Stream' with id [str_CAM_TuEE_con_NZFNg3QpWU] is now closed
OpenViduLogger.ts:31 Remote MediaStream from 'Stream' with id [str_CAM_TuEE_con_NZFNg3QpWU] is now disposed
OpenViduLogger.ts:31 Event 'streamDestroyed' triggered by 'Session'
StreamEvent {hasBeenPrevented: false, cancelable: true, target: Session, type: "streamDestroyed", stream: Stream, …}
STREAM DESTROYED HANDLER CALLED
OpenViduLogger.ts:31 Calling default behavior upon 'streamDestroyed' event dispatched by 'Session'
OpenViduLogger.ts:31 Inbound WebRTCPeer from 'Stream' with id [str_CAM_TuEE_con_NZFNg3QpWU] is now closed
OpenViduLogger.ts:31 Remote MediaStream from 'Stream' with id [str_CAM_TuEE_con_NZFNg3QpWU] is now disposed
OpenViduLogger.ts:42 TypeError: Cannot read property 'removeChild' of null
at StreamManager.ts:428
at Array.forEach (<anonymous>)
at Subscriber.StreamManager.removeAllVideos (StreamManager.ts:420)
at StreamEvent.callDefaultBehavior (StreamEvent.ts:97)
at Session.ts:734
The error happens in the first line of
streamManagerVideo.video.parentNode!.removeChild(streamManagerVideo.video);
this.ee.emitEvent('videoElementDestroyed', [new VideoElementEvent(streamManagerVideo.video, this, 'videoElementDestroyed')]);
Expected behavior
A single attempt at destroying the video element. Or, if do something wrong, reporting it instead of calling twice the same videoElementDestroyed
.
Wrong current behavior First attempt removes the component, the second one produces an error about a missing component.