Skip to main content
Known Participant
May 8, 2023
Question

Time variable throwing unexpected time values

  • May 8, 2023
  • 4 replies
  • 360 views

I have a long expression but, isolating and trouble shooting one part of it for example's sake: 

z = time;
throw z;

Values are inconsistent, and innaccurate. 

For example, in a 2 second, 23.976 fps comp:

Frame 24 (1 second) throws z as 2.002 seconds. 

Frame 12 (0.5 seconds)... also 2.002 seconds.

 

Deleting the code, then re pasting it exactly the same as before:

Frame 24 (1 second) throws z as 0.95 seconds. 

Frame 12 (0.5 seconds)... back to 2.002 seconds.

Back to Frame 24 (1 second), we're back to 2.002 again. 

 

Seems like after a few clicks, the time variable is gets "caught" by the comp duration.

Any ideas? 

 

 

4 replies

JohnColombo17100380
Community Manager
Community Manager
January 7, 2025

Hi @videowizard.io & @Brian HTN,

What you're seeing is that the `time` keyword will return the time of the last rendered frame if the evaluation of the expression is interupted, which occurs when using `throw`. This is not a bug so much as it is undefined behavior since `throw` causes an Exception in the expresion itself. Depending on the cached state of the composition, the last rendered frame might be the current frame or some frame later on in time, maxing out at the composition duration, which is why you see it stabilize at the comp's duration, especially if you have Cache Frames When Idle enabled for the comp.

 

To debug a portion of an expression having to do with `time` directly, I'd recommend creating the same expression on a Text layer so that you can see the output of the expression without needing to interrupt it with `throw`. Using `throw` on other variables in the expression shouldn't show the same issue.

 

Cheers,

- John, After Effects Engineering Team 

Participant
January 3, 2025

I'm seeing this same issue. I was trying to write a longer expression that made some calculation with time, and I got unexpected values when debugging with throw. Sometimes it was correct, but most of the time it seemed arbitrary. To test, I eventually reduced it down to:

throw time;

...and that still gave me unexpected values. But on a positive note, the longer expression itself actually seems to work fine, just throw with time is messed up. The arbitrary values also happened with "key(index).time"

After Effects Version 24.5.0

M3 Max Macbook Pro

macOS Sonoma 14.5 (23F79)

Known Participant
May 8, 2023

I don't thnk so, as the rest of the expression only pertains to text styling. 

 

For what it's worth, I just made a new text layer and with ONLY "z = time; throw z" expression in the source text property, and same thing is happening. Curiously it always shows the correct text on screen, but as soon as I "throw" it, the results become unexpected. 

 

For example, 

Second 1, Frame 7 (in a 23.976 comp):

correctly reads as 1.293 on screen

incorrectly throws a hodgepodge of values. changing each time you "check" what it's throwing. until it stabilizes around ~2 seconds, which is the comp duraiton. 

Very strange. 

Dan Ebberts
Community Expert
Community Expert
May 8, 2023

I'm not seeing anything like that. The expression always seems to throw the appropraite time value. Maybe there's something going on in the rest of the expression?