Skip to content

Commit

Permalink
fix(FEC-10512): handle memory leaks in smart TV (#487)
Browse files Browse the repository at this point in the history
issue: HTML5 event handler is too complex and took too long and the babel config causes memory issue on a smart TV.
Solution: simplify the handler and fix the babel plugin config which causes the memory issue.
  • Loading branch information
Yuvalke authored and yairans committed Oct 18, 2020
1 parent d23f428 commit f1c29fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
7 changes: 6 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
"@babel/plugin-transform-property-mutators",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-classes"
[
"@babel/plugin-transform-classes",
{
"loose": true
}
]
],
"presets": ["@babel/preset-env", "@babel/preset-flow"]
}
15 changes: 8 additions & 7 deletions src/engines/html5/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,14 @@ export default class Html5 extends FakeEventTarget implements IEngine {
*/
attach(): void {
Object.keys(Html5EventType).forEach(html5Event => {
this._eventManager.listen(this._el, Html5EventType[html5Event], () => {
if (Html5EventType[html5Event] === Html5EventType.ERROR) {
this._handleVideoError();
} else {
this.dispatchEvent(new FakeEvent(Html5EventType[html5Event]));
}
});
if (Html5EventType[html5Event] !== Html5EventType.ERROR) {
this._eventManager.listen(this._el, Html5EventType[html5Event], () => {
return this.dispatchEvent(new FakeEvent(Html5EventType[html5Event]));
});
}
});
this._eventManager.listen(this._el, Html5EventType.ERROR, () => {
this._handleVideoError();
});
this._handleMetadataTrackEvents();
let mediaSourceAdapter = this._mediaSourceAdapter;
Expand Down

0 comments on commit f1c29fc

Please sign in to comment.