-
Notifications
You must be signed in to change notification settings - Fork 27.4k
stripCustomNsAttrs performance #14928
Comments
Thanks for raising this issue. |
Hello. IE throws exception: The test below should trip it reliably (it does on both of my test system, but feel free to increase the number of elements added in the loop);
For reference, Edge seems to manage just fine even with 8x the amount: I am not sure if they allocate bigger stack, or Chakra implements tail-recursion optimization |
Fwiw, it seems to indeed crash on IE11, but only with DevTools open. If I close the DevTools, it works fine. |
When you say "works fine", does it actually render the list (long column of "name" lines)? Because the exception is normally silent, but aborts the bind operation |
It does. |
I used the script mentioned here along with something similar to the fix mentioned here and increased IE 11 from breaking on ~3k records to breaking on ~200k records. A grand improvement to be sure! I am worried a bit about over-optimizing though, since the script and fix are heavily biased towards sibling nodes. I am wondering if that is something I should be concerned about. I have an idea bouncing around that could potentially address both child and sibling nodes, but if we are much more concerned with one than the other, the solution is significantly simpler to optimize for only one. Chrome doesn't seem much affected either way by this script, managing ~1M records without too much issue. |
The whole code could be changed to walk the tree up/down the same way as the digest loop does; but I am not really sure it's worth the effort - the stack depth should now correspond to the depth of the DOM tree, and I wouldn't really expect that to be an issue. |
Update Internet Explorer-only helper function stripCustomNsAttrs to be less recursive Reduce stack height of function causing out of space error Closes angular#14928
Update Internet Explorer-only helper function stripCustomNsAttrs to be less recursive. Reduce stack height of function causing out of stack space error. Closes angular#14928
Update Internet Explorer-only helper function stripCustomNsAttrs to be less recursive. Reduce stack height of function causing out of stack space error. Closes angular#14928
Update Internet Explorer-only helper function stripCustomNsAttrs to be less recursive. Reduce stack height of function causing out of stack space error. Closes angular#14928
Update Internet Explorer-only helper function stripCustomNsAttrs to be less recursive. Reduce stack height of function causing out of stack space error. Closes angular#14928 Closes angular#15030
Update Internet Explorer-only helper function stripCustomNsAttrs to be less recursive. Reduce stack height of function causing out of stack space error. Closes angular#14928 Closes angular#15030
Update Internet Explorer-only helper function stripCustomNsAttrs to be less recursive. Reduce stack height of function causing out of stack space error. Closes angular#14928 Closes angular#15030
Update Internet Explorer-only helper function stripCustomNsAttrs to be less recursive. Reduce stack height of function causing out of stack space error. Closes angular#14928 Closes angular#15030
Update Internet Explorer-only helper function stripCustomNsAttrs to be less recursive. Reduce stack height of function causing out of stack space error. Closes angular#14928 Closes angular#15030
Performance suggestion
stripCustomNsAttrs is currently using recursive to walk the siblings in the DOM tree, which can easily cause it to run out of stack space in Internet Explorer. That happens to us when sanitizing a string containing cca 3000 DOM elements (which we do as performance optimization over ng-repeat, normally we of course bind much smaller strings).
It seems rewriting the code to use iteration should be safe, and resolves the problem entirely:
We experience the issue in Angular 1.5.7, Internet Explorer 11. The string bound is something like
<div class="entry"><div class="icon icontype"></div><span>Name</span></div>
repeated 3000xThe text was updated successfully, but these errors were encountered: