From 90c9d9efeab53c5871f107736c1c13ee78ad0921 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Wed, 11 Dec 2013 13:26:44 -0700 Subject: [PATCH 1/3] move plot off scope object --- src/app/panels/histogram/module.js | 4 ++-- src/vendor/jquery/jquery.flot.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/panels/histogram/module.js b/src/app/panels/histogram/module.js index d476c95da85..7493933b573 100644 --- a/src/app/panels/histogram/module.js +++ b/src/app/panels/histogram/module.js @@ -527,7 +527,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { restrict: 'A', template: '
', link: function(scope, elem) { - var data; + var data, plot; scope.$on('refresh',function(){ scope.get_data(); @@ -699,7 +699,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { data[i].data = _d; } - scope.plot = $.plot(elem, data, options); + plot = $.plot(elem, data, options); } catch(e) { // Nothing to do here diff --git a/src/vendor/jquery/jquery.flot.js b/src/vendor/jquery/jquery.flot.js index fddbdc32ab7..5505c76d113 100644 --- a/src/vendor/jquery/jquery.flot.js +++ b/src/vendor/jquery/jquery.flot.js @@ -2438,9 +2438,9 @@ Licensed under the MIT license. radius = series.points.radius, symbol = series.points.symbol; - // If the user sets the line width to 0, we change it to a very + // If the user sets the line width to 0, we change it to a very // small value. A line width of 0 seems to force the default of 1. - // Doing the conditional here allows the shadow setting to still be + // Doing the conditional here allows the shadow setting to still be // optional even with a lineWidth of 0. if( lw == 0 ) From 1f1959d9b3c3c82e4c9e7f80fe36bcf81a1f01a7 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Thu, 12 Dec 2013 13:43:41 -0700 Subject: [PATCH 2/3] Angular tweaks to work around chrome GC bug --- src/app/directives/addPanel.js | 5 +++++ src/app/directives/kibanaPanel.js | 1 - src/vendor/angular/angular.js | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/app/directives/addPanel.js b/src/app/directives/addPanel.js index 2887a54a35e..4d7dee74901 100644 --- a/src/app/directives/addPanel.js +++ b/src/app/directives/addPanel.js @@ -12,6 +12,11 @@ function (angular, app, _) { return { restrict: 'A', link: function($scope, elem) { + + $scope.$on("$destroy",function() { + elem.remove(); + }); + $scope.$watch('panel.type', function() { var _type = $scope.panel.type; $scope.reset_panel(_type); diff --git a/src/app/directives/kibanaPanel.js b/src/app/directives/kibanaPanel.js index 009fb8f8e41..49283b8d00a 100644 --- a/src/app/directives/kibanaPanel.js +++ b/src/app/directives/kibanaPanel.js @@ -13,7 +13,6 @@ function (angular) { '
' + - '' + ''+ diff --git a/src/vendor/angular/angular.js b/src/vendor/angular/angular.js index d2115fe1d80..85d0cdca93a 100644 --- a/src/vendor/angular/angular.js +++ b/src/vendor/angular/angular.js @@ -8464,6 +8464,21 @@ function $RootScopeProvider(){ } else { this.$$childHead = this.$$childTail = child; } + + // RASHID: Fix for chrome GC bug + child.$on('$destroy', function() { + if(Child) + Child.prototype = null; + // Async so that the $broadcast('$destroy') can traverse the rest + setTimeout(function() { + child.__proto__ = {}; + for(var i in child) + child[i] = null; + child = null; + return null; + }); + }); + return child; }, @@ -8893,6 +8908,8 @@ function $RootScopeProvider(){ // see: https://github.com/angular/angular.js/issues/1313#issuecomment-10378451 this.$parent = this.$$nextSibling = this.$$prevSibling = this.$$childHead = this.$$childTail = null; + parent = this.$$nextSibling = this.$$prevSibling = this.$$childHead = + this.$$childTail = null; }, /** From 7580042b29160e10ec8eaed11abbbb71e012b238 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Thu, 12 Dec 2013 16:23:42 -0700 Subject: [PATCH 3/3] fixed initialization bugs --- src/app/app.js | 9 ++++++--- src/app/directives/kibanaPanel.js | 8 +++++++- src/app/services/dashboard.js | 3 +++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/app/app.js b/src/app/app.js index 41905a92955..973765c4f52 100644 --- a/src/app/app.js +++ b/src/app/app.js @@ -136,9 +136,12 @@ function (angular, $, _, appLevelRequire) { var $scope = this; $scope.requireContext(deps, function () { var deps = _.toArray(arguments); - $scope.$apply(function () { - fn.apply($scope, deps); - }); + // Check that this is a valid scope. + if($scope.$id) { + $scope.$apply(function () { + fn.apply($scope, deps); + }); + } }); }; }]); diff --git a/src/app/directives/kibanaPanel.js b/src/app/directives/kibanaPanel.js index 49283b8d00a..e37dc7862a2 100644 --- a/src/app/directives/kibanaPanel.js +++ b/src/app/directives/kibanaPanel.js @@ -61,16 +61,22 @@ function (angular) { link: function($scope, elem, attr) { // once we have the template, scan it for controllers and // load the module.js if we have any + var newScope = $scope.$new(); // compile the module and uncloack. We're done function loadModule($module) { $module.appendTo(elem); elem.wrap(container); /* jshint indent:false */ - $compile(elem.contents())($scope); + $compile(elem.contents())(newScope); elem.removeClass("ng-cloak"); } + newScope.$on('$destroy',function(){ + elem.unbind(); + elem.remove(); + }); + $scope.$watch(attr.type, function (name) { elem.addClass("ng-cloak"); // load the panels module file, then render it in the dom. diff --git a/src/app/services/dashboard.js b/src/app/services/dashboard.js index 768a3cbac62..4731d0bb928 100644 --- a/src/app/services/dashboard.js +++ b/src/app/services/dashboard.js @@ -134,6 +134,9 @@ function (angular, $, kbn, _, config, moment, Modernizr) { // here before telling the panels to refresh this.refresh = function() { if(self.current.index.interval !== 'none') { + if(_.isUndefined(filterSrv)) { + return; + } if(filterSrv.idsByType('time').length > 0) { var _range = filterSrv.timeRange('last'); kbnIndex.indices(_range.from,_range.to,