Encountering a bug with Ae 22.5 where I am getting an expression error of
"RangeError: Maximum call stack size exceeded"
then After Effects crashes. Neither the error nor the crashing happens with Ae 22.4 or older, and seems to only happen on Windows.
Confirmed that it happens on a wide range of hardware. Intel Core i9 12900K, AMD Ryzen 5950X, Threadripper Pro 5975WX/5995WX, etc., but all are on Windows 11 (haven't tested Windows 10 yet). Does not seem to be an issue on MacOS. Tried all the usual troubleshooting of clearing cache/preferences, doing a complete clean install, and a couple of these systems were actually complete OS reinstalls. Only fix I have found so far is to roll back to 22.4.
Screenshot is below, video showing the issue, and a small test project to replicate the bug is attached to this post.
I don't know much about that specific error, but I think cascading expressions like you're doing can put a lot of stress on the expression engine. You've got a lot of layers where expressions reference the same property on the next layer down in the layer stack, so to get the result for Bar 34, for example, the expression engine first has to calculate the result for Bar 33, which depends on the result for Bar 32, etc. Sometimes you have to set things up like that, but usually, as in your case I think, it would be much more efficient to use the layer's index to calculate the result based on the layer's relative position (index-wise) to the base layer. So you would replace your position expression with something like this:
M = thisComp.layer("Bar Master");
n = M.index - index;
new_pos = M.position + (thisComp.layer("Control").effect("Bar Spacing")("Slider") * 4)*n;
It is intended to be a stress on the expressions engine actually. So, in many ways, being unoptimized is part of the goal. We use it as a part of our After Effects benchmark plugin and we've never had problems with Ae crashing with it since we started using it back in Ae 16.something.
We could of change the composition to make it lighter in order to get around the issue, but that would really just be a bandaid to hide the underlying issue.