From 5e85ef5f7c7f15987f810ae1a2aaea2bb35fa458 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Tue, 18 Sep 2018 15:53:39 +0300 Subject: [PATCH 1/2] Some cvat memory leaks have been fixed --- cvat/apps/engine/static/engine/js/player.js | 4 ++++ cvat/apps/engine/static/engine/js/shapes.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cvat/apps/engine/static/engine/js/player.js b/cvat/apps/engine/static/engine/js/player.js index dcfad56c4cac..3c859f548d1a 100644 --- a/cvat/apps/engine/static/engine/js/player.js +++ b/cvat/apps/engine/static/engine/js/player.js @@ -44,6 +44,8 @@ class FrameProvider extends Listener { this._loaded = frame; this._frameCollection[frame] = image; this._loadAllowed = true; + image.onload = null; + image.onerror = null; this.notify(); } @@ -109,6 +111,8 @@ class FrameProvider extends Listener { image.onload = this._onImageLoad.bind(this, image, frame); image.onerror = () => { this._loadAllowed = true; + image.onload = null; + image.onerror = null; }; image.src = `get/task/${this._tid}/frame/${frame}`; }.bind(this), 25); diff --git a/cvat/apps/engine/static/engine/js/shapes.js b/cvat/apps/engine/static/engine/js/shapes.js index e58d52f192c7..a38c1bb6e476 100644 --- a/cvat/apps/engine/static/engine/js/shapes.js +++ b/cvat/apps/engine/static/engine/js/shapes.js @@ -1646,8 +1646,8 @@ class ShapeView extends Listener { _removeShapeUI() { if (this._uis.shape) { - this._uis.shape.off('click'); this._uis.shape.remove(); + SVG.off(this._uis.shape.node); this._uis.shape = null; } } @@ -1656,6 +1656,7 @@ class ShapeView extends Listener { _removeShapeText() { if (this._uis.text) { this._uis.text.remove(); + SVG.off(this._uis.text.node); this._uis.text = null; } } From dcde9deeeba78ffb881b7514894c8903dd251cb4 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Tue, 18 Sep 2018 16:06:14 +0300 Subject: [PATCH 2/2] svg.selectize.js memory leaks have been fixed --- .../engine/static/engine/js/3rdparty.patch | 72 +++++++++++++------ 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/cvat/apps/engine/static/engine/js/3rdparty.patch b/cvat/apps/engine/static/engine/js/3rdparty.patch index f3a216368a77..38f26000b637 100644 --- a/cvat/apps/engine/static/engine/js/3rdparty.patch +++ b/cvat/apps/engine/static/engine/js/3rdparty.patch @@ -1,29 +1,29 @@ -From b89380c65ea8bc9231cc98a6ae0e812227c85b3d Mon Sep 17 00:00:00 2001 +From 5eeb1092c64865c555671ed585da18f974c9c10c Mon Sep 17 00:00:00 2001 From: Boris Sekachev -Date: Tue, 10 Jul 2018 14:31:13 +0300 +Date: Tue, 18 Sep 2018 15:58:20 +0300 Subject: [PATCH] tmp --- .../engine/static/engine/js/3rdparty/svg.draggable.js | 1 + cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js | 17 +++++++++++++++-- .../apps/engine/static/engine/js/3rdparty/svg.resize.js | 5 +++-- - .../apps/engine/static/engine/js/3rdparty/svg.select.js | 1 + - 4 files changed, 20 insertions(+), 4 deletions(-) + .../apps/engine/static/engine/js/3rdparty/svg.select.js | 5 ++++- + 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js -index d88abf5..06158f1 100644 +index d88abf5..aba474c 100644 --- a/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js +++ b/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js @@ -109,6 +109,7 @@ - + // while dragging DragHandler.prototype.drag = function(e){ + this.m = this.el.node.getScreenCTM().inverse(); - + var box = this.getBBox() , p = this.transformPoint(e) diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js -index 68dbf2a..9884b75 100644 +index 68dbf2a..20a6917 100644 --- a/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js +++ b/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js @@ -18,6 +18,7 @@ @@ -31,13 +31,13 @@ index 68dbf2a..9884b75 100644 this.lastUpdateCall = null; this.options = {}; + this.set = new SVG.Set(); - + // Merge options and defaults for (var i in this.el.draw.defaults) { @@ -139,6 +140,8 @@ // Call the calc-function which calculates the new position and size this.calc(event); - + + this.m = this.el.node.getScreenCTM().inverse(); + this.offset = { x: window.pageXOffset, y: window.pageYOffset }; // Fire the `drawupdate`-event @@ -46,7 +46,7 @@ index 68dbf2a..9884b75 100644 @@ -160,6 +163,16 @@ this.el.fire('drawcancel'); }; - + + // Undo last drawed point + PaintHandler.prototype.undo = function () { + if (this.set.length()) { @@ -59,24 +59,24 @@ index 68dbf2a..9884b75 100644 + // Calculate the corrected position when using `snapToGrid` PaintHandler.prototype.snapToGrid = function (draw) { - + @@ -371,14 +384,14 @@ - + this.set.clear(); - + - for (var i = 0; i < array.length; ++i) { + for (var i = 0; i < array.length - 1; ++i) { - + this.p.x = array[i][0] this.p.y = array[i][1] - + var p = this.p.matrixTransform(this.parent.node.getScreenCTM().inverse().multiply(this.el.node.getScreenCTM())); - + - this.set.add(this.parent.circle(5).stroke({width: 1}).fill('#ccc').center(p.x, p.y)); + this.set.add(this.parent.circle(5).stroke({width: 1}).fill('#ccc').center(p.x, p.y)).addClass("svg_draw_point"); } } - + diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.resize.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.resize.js index 0c3b63d..fb5dc26 100644 --- a/cvat/apps/engine/static/engine/js/3rdparty/svg.resize.js @@ -91,27 +91,53 @@ index 0c3b63d..fb5dc26 100644 + y: event.clientY != null ? event.clientY : event.touches[0].clientY }; }; - + @@ -343,6 +343,7 @@ } return; } + this.m = this.el.node.getScreenCTM().inverse(); - + // Calculate the difference between the mouseposition at start and now var txPt = this._extractPosition(event); diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js -index 47e07bd..f1d0c02 100644 +index 47e07bd..cee6d34 100644 --- a/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js +++ b/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js @@ -160,6 +160,7 @@ SelectHandler.prototype.drawPoints = function () { ev.preventDefault ? ev.preventDefault() : ev.returnValue = false; ev.stopPropagation(); - + + if (ev.which != 1) return false; var x = ev.pageX || ev.touches[0].pageX; var y = ev.pageY || ev.touches[0].pageY; _this.el.fire('point', {x: x, y: y, i: k, event: ev}); --- +@@ -361,6 +362,7 @@ SelectHandler.prototype.cleanup = function () { + // stop watching the element, remove the selection + this.rectSelection.set.each(function () { + this.remove(); ++ SVG.off(this.node); + }); + + this.rectSelection.set.clear(); +@@ -371,6 +373,7 @@ SelectHandler.prototype.cleanup = function () { + // Remove all points, clear the set, stop watching the element + this.pointSelection.set.each(function () { + this.remove(); ++ SVG.off(this.node); + }); + + this.pointSelection.set.clear(); +@@ -379,8 +382,8 @@ SelectHandler.prototype.cleanup = function () { + + if (!this.pointSelection.isSelected && !this.rectSelection.isSelected) { + this.nested.remove(); ++ SVG.off(this.node); + delete this.nested; +- + } + }; + +-- 2.7.4