Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix MultiThread debug element memory leak
I saw a memory leak which may (still under tests) be the source of my recent failing tests on LG TVs (the application restarted after one or two hours of playback). It only appears in a combination of experimental features, so not dramatic either: - multithread is enabled - the RxPlayer's debug element is shown on screen I noticed that the create Promise's `reject` callback was correctly linked to the `Init`'s CancellationSignal but was never unbound from it. As such, that `CancellationSignal`, which is alive as long as the content is playing, would keep a reference to that reject's function, and this seems to extend to other objects linked to that Promise. I was for example under the impression that even that Promise's resolved value was retained by looking at Chrome's inspector. The solution is simply to unbound `reject` from the CancellationSignal when either "rejecting" or "resolving" the Promise. --- I also profited from this fix to transform the `resolvers` object from a simple JS Object to a `Map` as it seems much more appropriate: we very frequently insert and remove values from it, and we never need to serialize that object. Also that Object's keys were number and to my understanding JS Object keys are always stringified (or at least you cannot have e.g. `[1]` and `["1"]` point to different values) so that didn't seem natural to me, plus the fact that I initially feared that it was an array.
- Loading branch information