-
Notifications
You must be signed in to change notification settings - Fork 35
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(FEC-11037): multiple decorator exist after destroy plugin with decorator #544
Conversation
Issue: when plugin has decorator and player destoryed the decorator reregister. Solution: filter out the previous decorator provider and keep the new one only
src/engines/engine-decorator.js
Outdated
EngineDecorator._decoratorProviders.push(decoratorProvider); | ||
} | ||
EngineDecorator._decoratorProviders = EngineDecorator._decoratorProviders.filter( | ||
currentDecoratorProvider => currentDecoratorProvider.constructor.name !== decoratorProvider.constructor.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why name and not id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're not maintaining id field
Hi @yuval, not sure I fully understand the issue description |
@OrenMe every setup register decorator provider, after destroy we setup again so if plugin has decorator it will add new decorator provider for each destroy and step and create decorator for each provider, this change will keep the newest plugin instance - decorator provider and remove the older one |
@OrenMe static hash? name? I think this check is much better |
I think the entire solution we have today is not ok - it was made when plugins were manager by the playkit lib and not relevant for kaltura player managed plugins. |
@OrenMe I agree, but in our case, we have to fix multiple decorators after destroy. |
The comment about being ok or not was referring to passing plugin instance from Kaltura player to Playkit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General note - most changes are around naming conventions or keeping existing names
src/player.js
Outdated
* @returns {void} | ||
* @param {EngineDecoratorGenerator} decoratorGenerator - function to create the decorator | ||
*/ | ||
addEngineDecorator(decoratorGenerator: EngineDecoratorGenerator): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addEngineDecorator(decoratorGenerator: EngineDecoratorGenerator): void { | |
registerEngineDecoratorProvider(engineDecoratorProvider: EngineDecoratorProvider): void { |
src/player.js
Outdated
* @param {EngineDecoratorGenerator} decoratorGenerator - function to create the decorator | ||
*/ | ||
addEngineDecorator(decoratorGenerator: EngineDecoratorGenerator): void { | ||
if (!this._decoratorManager) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!this._decoratorManager) { | |
if (!this._engineDecoratorManager) { |
class EngineDecoratorManager { | ||
_decoratorGenerators: Array<EngineDecoratorGenerator> = []; | ||
|
||
addDecorator(decoratorGenerator: EngineDecoratorGenerator): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addDecorator(decoratorGenerator: EngineDecoratorGenerator): void { | |
register(name: string, engineDecoratorProvider: EngineDecoratorProvider): void { |
_decoratorGenerators: Array<EngineDecoratorGenerator> = []; | ||
|
||
addDecorator(decoratorGenerator: EngineDecoratorGenerator): void { | ||
this._decoratorGenerators.push(decoratorGenerator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add check to see if it is already provided, and with above addition of name it is easier then ever
import type {IEngine} from './engine'; | ||
|
||
declare interface IEngineDecoratorProvider { | ||
getEngineDecorator(engine: IEngine, dispatchEventHandler: Function): IEngineDecorator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be part of the plugin interface, it is ok to remove it from here but need to make sure we define it for plugins in kaltura-player-js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure the change for kaltura player didn't upload yet
* @class EngineDecoratorManager | ||
*/ | ||
class EngineDecoratorManager { | ||
_decoratorProviders: MultiMap<string, IEngineDecoratorProvider> = new MultiMap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be a simple map, multi map is were the value is array but we only have one decorator per plugin
src/player.js
Outdated
@@ -390,6 +391,12 @@ export default class Player extends FakeEventTarget { | |||
* @private | |||
*/ | |||
_aspectRatio: ?string; | |||
/** | |||
* The engine manager. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The engine manager. | |
* The engine decorator manager. |
* @implements {IEngineDecorator} | ||
*/ | ||
class EngineDecoratorProvider implements IEngineDecoratorProvider { | ||
constructor(plugin: IEngineDecoratorProvider) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this means we are still passing the entire plugin to playkit. lets pass only the decorator provider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're passing it but not keeping it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provider will be getName and getEngineDecorator instead of the plugin itself
Description of the Changes
Issue: when the plugin has the decorator and the player destroyed the decorator reregister.
Solution: filter out the previous decorator provider and keep the new one only.
CheckLists