Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better timeout handling #1541

Closed
mmcc opened this issue Sep 29, 2014 · 9 comments
Closed

Better timeout handling #1541

mmcc opened this issue Sep 29, 2014 · 9 comments

Comments

@mmcc
Copy link
Member

mmcc commented Sep 29, 2014

I've left this comment on a few issues, so it's probably time to create a new catch-all for this one.

@heff and I talked this over, and we think it makes sense to have a setTimeout utility method that is identical to window.setTimeout, but adds the timeout to an array on the player instance so we can dispose all of them at once when the player is disposed.

This would clean up all the instances of having to create a dispose listener each time a timeout is created, and help us avoid accidentally missing one (which seems to happen pretty often) and allows plugins to utilize the same functionality.

Other (potential) references: #1521, #1484, #1505, #1431

@deweydb
Copy link

deweydb commented Nov 9, 2014

Is there any work around for these issues in the interim? I'm having a pretty big problem with this in my application as users switch between states after i .dispose() the player and try to re-create one later.

@ntodd
Copy link

ntodd commented Nov 9, 2014

Same here. I'm trying to use video.js in an Ember app and running into this as I dynamically create and remove players.

@deweydb
Copy link

deweydb commented Nov 9, 2014

I realized that the problem is mostly caused by timers that don't get cleaned up, so a simple fix is just to pause the video first before dispose.

player.pause();
setTimeout(function() {
player.dispose();
}, 0);

Found here: http://stackoverflow.com/questions/25493887/videojs-return-vdata-error-when-dispose-is-call

@ntodd
Copy link

ntodd commented Nov 9, 2014

@deweydb Interesting. I tried pause(), but didn't think to defer dispose(). I'll give it a shot. Thanks.

@mmcc mmcc closed this as completed Jan 9, 2015
@ppaul
Copy link

ppaul commented Nov 10, 2015

In a context worked for me. Now again I had the issues. I could fix it by forcing in vjs lib to exit, like this:

vjs.trigger = function(elem, event) {
//there is a bug after disposing video
if (!elem) {
return false;
}
....

and also:

vjs.trigger = function(elem, event) {
// Fetches element data and a reference to the parent (for bubbling).
// Don't want to add a data object to cache for every parent,
// so checking hasData first.
var elemData = (elem && vjs.hasData(elem)) ? vjs.getData(elem) : {};
...

@mmcc
Copy link
Member Author

mmcc commented Oct 24, 2016

@toru-sean The original context of this issue was resolved with #1642. If you're seeing this issue again, it could be a regression or an entirely different problem altogether, but we need some context here. Please use the issue template so folks can take a look. Thanks!

@willpiam
Copy link

willpiam commented Sep 1, 2021

Hey I'm here 5 years after the last activity, with at the very least a very similar issue. I'll try deferring dispose but a) that's disgusting and b) my error is coming from the line where I call videojs().

@willpiam
Copy link

willpiam commented Sep 1, 2021

yeah it didn't help

@mmcc
Copy link
Member Author

mmcc commented Sep 2, 2021

It's really difficult to determine whether this is the same, new, or implementation issue without seeing a reduced test case that shows the problem. Think you could put something together there and we can take a look?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants