Skip to content
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

Some memory leaks have been fixed #61

Merged
merged 2 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 49 additions & 23 deletions cvat/apps/engine/static/engine/js/3rdparty.patch
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
From b89380c65ea8bc9231cc98a6ae0e812227c85b3d Mon Sep 17 00:00:00 2001
From 5eeb1092c64865c555671ed585da18f974c9c10c Mon Sep 17 00:00:00 2001
From: Boris Sekachev <boris.sekachev@intel.com>
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 @@
this.startPoint = null;
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
Expand All @@ -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()) {
Expand All @@ -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
Expand All @@ -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

4 changes: 4 additions & 0 deletions cvat/apps/engine/static/engine/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion cvat/apps/engine/static/engine/js/shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down