Skip to main content
Inspiring
February 23, 2020
Question

JSX file is re-evaluated every frame for every property it is used (efficiency issue)

  • February 23, 2020
  • 1 reply
  • 270 views

JSX files are evaluated on import, this is correct. They are merely a JS expression. But they appear to be evaluated everytime they are used in an Expression. I tested this with this import file:

 

{
   "id": Math.random()
}

And in a Text object use this expression:

lib = footage("test_library.jsx").sourceData;
lib.id

The text string changes every frame of the animation, implying the JSX file is reevaluated.

 

I've tested this across multiple properties, and each one has it's own copy of the import. This actually makes sense, the properties should be isolated. But I'd expect the footage() result to be cached and reused from frame to frame. Otherwise I'll start having efficiency problems when I use the library too much, and/or it grows to more than a trivial set of functions.

This topic has been closed for replies.

1 reply

Mylenium
Brainiac
February 23, 2020

It works as it always has and as it is designed. Expressions are "dumb" and strictly evaluate based on time, i.e. whatever time value is fed into them eitehr by automatically progressing through the timeline or e.g. when you use valueAtTime() and such. It's a basic concept of AE and ultimately one of the reasons why you have to create loops in order to accumulate values because there is no storing or caching of values and variables. you have to live with it and refactor your own code to optimise the behavior as much as you can. In case of doubt writing a script and importing your data directly to source text keyframes may be much more efficient, if you really have that many data sets.

 

Mylenium

mortorayAuthor
Inspiring
February 23, 2020

I understand that, but it's not where my concer lies. I'm worried about efficiency. The library itself, not merely the expression, is reevaluated every-frame even though it's reasonable to assume it wouldn't change. This is a needless drain on runtime performance.

Mylenium
Brainiac
February 23, 2020

But the expressions don't know that and there is no pre-processor that would only feed them lines selectively. It's for all intents and purposes 100 percent logical and consistent within this framework. I'm not saying that it couldn't be different, but that would be the old gag of having to completely turn things on its head in AE not just in the expression system which isn't going to happen.

 

Mylenium