-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Exceptions while destroy() #151
Comments
var reload = function(newMpdUrl) {
return player.unload().then(function() {
return player.load(newMpdUrl, null, sameEstimator, null);
});
}; |
would it be possible to implement fix in the shaka player so it would not throw these exceptions? |
@jozefchutka Do you still get these exceptions when you follow advice from @tdrews about the unload promise? |
hi joeyparrish, the async solution is not ideal in my case as I need to destroy old instance / change source synchronously. Is it preffered the Player instance to be reused or new one to be recreated for every new source? |
For what it's worth, the Player is designed to be reusable. You are welcome to create new Player instances if you like, but if there are still async processes happening with your video tag, attaching a new Player to the same tag before that completes may cause problems for you. If you intend to create new Players, you should either wait for the old one to be destroyed or add remove the old video tag from the DOM and create a new one for the new Player. However, given that we designed Player to be reusable, I really can't see any reason to do it. Plus, this process would still be async. The asynchronicity of unload() cannot be avoided due to the asynchronicity of EME APIs that must be used during unload(). My recommendation is to call load() with a first source, then when you want to change sources, just call load() again. load(), which is async, will call unload() internally if need be and wait for the result. If you need to destroy the player, just call destroy() instead of unload() and destroy(). The destroy() method, like load(), will call unload() internally if needed. Does this work for you? If not, can you explain your use case? I don't understand why a real application would do the things you are doing in your sample above. |
@joeyparrish you can see I try to create a new video instance for each Player insntance so that should not be an issue. I have also tried to remove In my realworld application I need to navigate around a singe page app and there is |
@jozefchutka, I see. Well, we did not consider rapid creation and destruction as a use case, but it seems reasonable to expect destruction to interrupt async processes and cause their failure. Any Promises returned to you would be rejected, and your application would then have to avoid calling methods on that instance from any handlers you attach to that Promise. For what it's worth, I would still recommend against calling unload() and then destroy() synchronously. Just destroy() should suffice, and will trigger the same logic as unload() during the destruction process. I notice you say that these exceptions could "easily be avoided". Does that mean you have already looked into it and worked out the fix? Do you have a patch ready? Or is this something you would still like us to work on? Thanks, |
@joeyparrish, I can not recall why I needed to call unload() before destroy(), but I can confirm that even without unload() being called it does work the same in my test. So I can see the same exception while new video being created correctly and old one is gone. If I recall the reason, I will report it as a separate issue. By saying easily avoided I referred to the fact that apart from the exception in the console the player works as expected, and as that one seems to be a null pointer it can be avoided by having a null check in place. I do not have a patch or fix on my side. |
I have a fix for this in review, including new Player tests to cover your use case. Thanks for the report! |
Found one more case we missed. |
great job. thanks @joeyparrish |
Using shaka-player.compiled.js v1.4.0 I can observe two exceptions when destroying player instance. Here is my test player - clicking in the document a current instance of player is disposed and a new one created:
First exception seems to be related to
<style>video {display: block;}</style>
:Second one seems to be related to quickly destroying and recreating player. It is easily replicated by creating and destroying the player twice in a row (see dispose/create/dispose/create sequence)
Its also worth mentioning that unload() seems to be required before destroy(). I would suggest to have that call inside destroy() so memory can be released easily by calling just one master method.
The text was updated successfully, but these errors were encountered: