bbc / VideoContext

An experimental HTML5 & WebGL video composition and rendering API.
http://bbc.github.io/VideoContext/
Apache License 2.0
1.33k stars 157 forks source link

VideoNode crashes if node._startTime === node._currentTime on first update #71

Closed PTaylour closed 6 years ago

PTaylour commented 6 years ago

I have a videocontext graph that sometimes produces this error on loading

Uncaught TypeError: Cannot set property 'playbackRate' of undefined

This error occurs in videonode.js if, on loading, this._startTime === this._currentTime, This prevents this._load() being called before this._state is set to playing in sourcenode.js

this._load is only called if this._startTime - this._currentTime < this._preloadTime (https://github.com/bbc/VideoContext/blob/master/src/SourceNodes/videonode.js#L172), so this can be fixed by changing this condition to "less than or equal to" this._startTime - this._currentTime <= this._preloadTime

Or, if the bug is that playing is set prematurely, you could update the condition that sets the playing state https://github.com/bbc/VideoContext/blob/master/src/SourceNodes/sourcenode.js#L354 to be less than (but not equal to)