I am building a player with videocontext that allows clips to be added and removed.
When a clip is in view and the user deletes the clip, we destroy the video node, however the canvas is not cleared and the last frame that was rendered remains on screen.
I've found the reason to be that the Khan's algorithm used here is faulty because it does not consider the case where there are no connections and only one node (the DestinationNode)
(In this case sortedNodes is just an empty array instead of [this._destinationNode] which is the correct result)
The problem is resolved if I manually call _render and _update on the DestinationNode when there aren't any connections via an override of the VideoContext class. I can actually make a PR for a simple hotfix by checking if connections.length===0 then setting sortedNodes to [this._destinationNode] if you'd like.
I am building a player with videocontext that allows clips to be added and removed. When a clip is in view and the user deletes the clip, we destroy the video node, however the canvas is not cleared and the last frame that was rendered remains on screen.
I've found the reason to be that the Khan's algorithm used here is faulty because it does not consider the case where there are no connections and only one node (the DestinationNode) (In this case sortedNodes is just an empty array instead of [this._destinationNode] which is the correct result)
https://github.com/bbc/VideoContext/blob/5f82048cc36a87e64d5b855befc4ff08ec1a169a/src/videocontext.js#L941-L962
The problem is resolved if I manually call _render and _update on the DestinationNode when there aren't any connections via an override of the VideoContext class. I can actually make a PR for a simple hotfix by checking if connections.length===0 then setting sortedNodes to [this._destinationNode] if you'd like.