Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

mdTabs: always recompiling template on tab switch (scope/watchers leak) #3692

Closed
andreialecu opened this issue Jul 12, 2015 · 4 comments
Closed
Labels
needs: demo A CodePen demo or GitHub repository is needed to demonstrate the reproduction of the issue needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community needs: unit tests This PR needs unit tests to cover the changes being proposed type: bug
Milestone

Comments

@andreialecu
Copy link

I'm seeing a huge scope leak when switching through tabs with watchers on them.

I was able to track it down to this:

if (ctrl.scope.noDisconnect) return;

Always being called on switching the tab, and the whole directive re-running from the beginning. The disconnect() function is never called. This seems to create a new scope and compile the template every single time.

I suspect it is related to the performance related change that was made recently, where tab content is ng-if'd out when not active, but I'm not sure.

Related: #3508

The repro there can also be used to reproduce this problem.

@andreialecu
Copy link
Author

I found a fix for this, at:

scope.$on('$destroy', reconnect);

Needs to be changed to:

      scope.$on('$destroy', function(){
        compileScope.$destroy();
      });

Can someone familiar (@robertmesserle) with that code explain why the $destroy watcher would reconnect the scope?

I see no unintended sideffects with the above code in my scenario, but I'm unsure what the intention was there.

@piyushchauhan2011
Copy link

👍

@ThomasBurleson
Copy link
Contributor

@anderson-arlen - Have you tried to using the mdNoDisconnect Tabs attribute:

<md-tabs md-no-disconnect>
  ...
</md-tabs>

And does this problem still exist with the latest code from master ?

Please provide a CodePen or Plunkr that demonstrates this issue. Here are some starter demo templates that you can use/fork:

May be related to #3617 and #3508

@ThomasBurleson ThomasBurleson added type: bug needs: demo A CodePen demo or GitHub repository is needed to demonstrate the reproduction of the issue needs: tests needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community labels Jul 30, 2015
@ThomasBurleson ThomasBurleson added this to the 0.11.0 milestone Jul 30, 2015
@ThomasBurleson ThomasBurleson self-assigned this Jul 30, 2015
@ThomasBurleson ThomasBurleson changed the title md-tabs always recompiling template on tab switch (scope/watchers leak) mdTabs: always recompiling template on tab switch (scope/watchers leak) Jul 30, 2015
@anderson-arlen
Copy link
Contributor

@andreialecu, I think @ThomasBurleson meant to tag you instead of me. Pesky autocomplete... :D

kennethcachia pushed a commit to kennethcachia/material that referenced this issue Sep 23, 2015
This is necessary due to various bugs with disconnecting scope.  The API
remains the same for now, but in 0.11 we will revise the API's to more
accurately describe what is going on under the hood.

Closes angular#3692
@Splaktar Splaktar added the needs: unit tests This PR needs unit tests to cover the changes being proposed label Mar 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: demo A CodePen demo or GitHub repository is needed to demonstrate the reproduction of the issue needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community needs: unit tests This PR needs unit tests to cover the changes being proposed type: bug
Projects
None yet
Development

No branches or pull requests

6 participants