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

fix: Prevent exceptions from being thrown by the MediaSource #389

Merged
merged 2 commits into from
Feb 7, 2019

Conversation

brandonocasey
Copy link
Contributor

See code comments

try {
this.mediaSource.duration = newDuration;
} catch (e) {
videojs.log.warn('Failed to set media source duration', e);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried for a long time to determine the cause of this, it almost seems like a bug in firefox. Originally I thought it was due to updating sourceBuffers or the media source not being open but that is not the case.

@brandonocasey brandonocasey force-pushed the fix/media-source-exceptions branch from 76bc2da to 7f4c552 Compare January 28, 2019 19:55
return;
}

// on chrome calling endOfStream can sometimes cause an exception,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chrome can sometimes throw a DOM exception here when endOfStream is called. It seems like it almost always happens when:

  1. sourceBuffers are still updating
  2. The mediaSource is no longer open

It does seem to happen at other times though. So I think we just need to wrap this in a try catch here.

Copy link
Member

@misteroneill misteroneill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me.

@forbesjo forbesjo merged commit 8c06366 into master Feb 7, 2019
@forbesjo forbesjo deleted the fix/media-source-exceptions branch February 7, 2019 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants