material icon indicating copy to clipboard operation
material copied to clipboard

md-tabs: just switching tabs causes over 60 digests (was infinite in earlier versions)

Open gpothier opened this issue 11 years ago • 6 comments

When switching tabs in an md-tabs container, the digest process seems to be called many more times than necessary. I have an example where it is called around 60 times in Firefox (15 times in Chrome), although no data changes in the scope.

The html is like this:

<md-tabs flex md-border-bottom md-selected="selectedTab" >
    <md-tab label="A">
        <md-content class="md-padding">
            <div ng-if="isTeamAdmin(null)">stuff</div>
        </md-content>
    </md-tab>

    <md-tab label="B">
    </md-tab>
</md-tabs>

And the controller is like this:

angular.module("docflow").controller("BooksListCtrl", 
["$scope", "$rootScope", 
function($scope, $rootScope){
    $scope.isTeamAdmin = function() {
        console.log("isTeamAdmin");
        return false;
    };      
}]);

The isTeamAdmin function is called 60+ times when switching tabs.

Here is a Meteor app that reproduces the problem:

https://github.com/gpothier/mdTabIssues

Note: with previous versions of Angular and Material, the isTeamAdmin function was being called again and again forever, so it seems a kind of failsafe now kicks in, but still the method should be called only once.

gpothier avatar Jun 16 '15 21:06 gpothier

Just confirming that the version that caused infinite digests is 0.9.8. In 0.9.10 it is "only" 60.

gpothier avatar Jun 16 '15 22:06 gpothier

Can you confirm this issue still exists with the 0.10 release ?

ThomasBurleson avatar Jun 16 '15 22:06 ThomasBurleson

Oooh sorry, I did mean 0.10.0, not 0.9.10. So yes, I confirm that in 0.10.0 digest is executed around 60 times, and in 0.9.8 it was executed forever.

gpothier avatar Jun 16 '15 22:06 gpothier

Now that the infinite digest issue has been fixed, this is probably the next major perf issue with tabs.

I've updated a codepen that shows digest executions when tabs are interacted with to use the version which fixes #3101

http://codepen.io/stevenmiles/pen/RPxOgL

stevenmiles avatar Jun 30 '15 08:06 stevenmiles

Down to 10 in Firefox now.

robertmesserle avatar Jul 15 '15 17:07 robertmesserle

@robertmesserle - from infinite -> 10... #ftw

ThomasBurleson avatar Jul 15 '15 17:07 ThomasBurleson