IMPORTANT UPDATE! May 12 13, 2026



Tomorrow Today Last Wednesday, on the 13th of May, the manual Patrons group (the one that gives you your green username AND access to dedicated Patrons spaces on WSL) will be has been DELETED.

This means that your access to those spaces will be has been revoked until you connect your Patreon account to WSL using the link below, which will give you access to the NEW, future-proof Patrons+++ group.

With the imminent release of ZEPPO BETA 2 - tentatively planned for released Friday today yesterday (!!) - I wouldn't dawdle... with Beta 2 (i.e. all my late nights in the past month), Zeppo has become something truly special, battle-tested and multi-user hardened in an actual production.

Yes, there will be a Reactor release eventually, and no, it won't have all the bells and whistles - those are for Patrons, because they are the ones keeping WSL afloat, which is still only barely these days...

I'd better get back to prepping that done did release then!

Thank you,

Pieter


Significant overhead for the GetSource() call

User avatar
ErickSkrauch
Posts: 6
Joined: 3 weeks ago
Reactions score: 0
Been thanked: 1 time

Significant overhead for the GetSource() call

#1

Unread post by ErickSkrauch »

Hello. I'm developing a plugin for Fusion that will simulate spring behavior to create smoother animations. The problem with the spring is that its velocity must be calculated from the very beginning and remain continuous. So I have to recalculate the values from scratch for every frame. I can’t cache the values because I haven’t found any mechanisms to invalidate the cache afterward. The longer the composition and the higher the FPS, the more frames need to be recalculated.

My problem is that I have to call GetSource on all input parameters for every frame. Each call takes quite a long time, and in total, the render time for a single frame easily exceeds 18ms, which is unacceptable.

Fusion has quite a lot of undocumented API that I can only find through LLM results. But it seems I’ve reached a point where this is much more hallucination than what is actually available in modern Fusion.

Ideally, I’d like to cache the values so I don’t have to recalculate everything every time. But NotifyChanged behaves strangely for animated parameters and doesn’t make sense.

So I’m trying to optimize the process of retrieving the values itself. Is it possible to call GetSource() once for all Inputs at once? Or is there some other way to get all the values for a single Input, but as a table of values over time?

I’d appreciate any tips.


User avatar
danell
Fusionista
Posts: 589
Joined: 9 years ago
Reactions score: 18
Location: Norrköping
Real name: Jacob Danell
Has thanked: 7 times
Been thanked: 48 times

Re: Significant overhead for the GetSource() call

#2

Unread post by danell »

Where do you call GetSource()? If it's under Process() the image will be processed before. If you call it under PreProcess() instead no image will be generated while you're fetching your values.
If you store your variables outside of any functions they will be int he global space and you can access those in between frames.
It's a bit hard to know exactly what's going on in your plugin but if you can share the code so far it's easier to see what might be going on.


User avatar
ErickSkrauch
Posts: 6
Joined: 3 weeks ago
Reactions score: 0
Been thanked: 1 time

Re: Significant overhead for the GetSource() call

#3

Unread post by ErickSkrauch »

I have tried the PreRender(), but it still takes too long for all GetSource() calls.

Here is the plugin at current state.

You do not have the required permissions to view the files attached to this post.

User avatar
Tangenten
Posts: 32
Joined: 3 years ago
Reactions score: 76
Has thanked: 30 times
Been thanked: 66 times

Re: Significant overhead for the GetSource() call

#4

Unread post by Tangenten »

Adding these 'REQF_SecondaryTime' constants to my GetSource calls helped with performance issues for me:

  1. local frame = 5
  2. local inpVal = inp:GetSource(frame, REQF_SecondaryTime, REQF_SecondaryTime).Value

I think they avoid revalidating controls / viewers or something like that.


User avatar
ErickSkrauch
Posts: 6
Joined: 3 weeks ago
Reactions score: 0
Been thanked: 1 time

Re: Significant overhead for the GetSource() call

#5

Unread post by ErickSkrauch »

Never saw that parameter before. Will try. Thank you for the info!


User avatar
pizza
Posts: 19
Joined: 1 year ago
Reactions score: 11
Has thanked: 5 times
Been thanked: 3 times

Re: Significant overhead for the GetSource() call

#6

Unread post by pizza »

Yeah, my understanding is that REQF_SecondaryTime is important when you are getting a value from a different frame than the one you are actually rendering. It's also good for avoiding weird UI issues where controls don't know what frame they should be on (which I expect is also the source of any performance improvements). You can find example usage of this in the built in duplicate.fuse file iirc.


User avatar
ErickSkrauch
Posts: 6
Joined: 3 weeks ago
Reactions score: 0
Been thanked: 1 time

Re: Significant overhead for the GetSource() call

#7

Unread post by ErickSkrauch »

pizza wrote: 3 days ago

It's also good for avoiding weird UI issues where controls don't know what frame they should be on

Oh, that's the thing I really wanted to fix!

But unfortunately, this doesn't fix the performance issue. Adding a modifier to a long clip still makes playback non-realtime. I think adding this option makes things a little better, but the operation still takes longer the further into the clip we go.

For now, I’ve implemented a local solution with a cache and a button to clear it. With this approach, everything works smoothly, but I get annoyed having to press that button all the time. I haven’t given up hope of finding a working solution.

One of my hopes was that I could add another Output for the Velocity parameter. When attempting to render frame X, I’ll query the position and velocity parameters from the Output X-1. If they’re there, Fusion will return them from the cache. If they’re not, it’ll call Process for the previous frame and cache the result.

Unfortunately, in reality, I haven’t found any way to retrieve a value from an Output. If you have any ideas on this, I’d love to hear them. I really hope to finish my plugin and publish it on Rector. Animations should look natural!


User avatar
pizza
Posts: 19
Joined: 1 year ago
Reactions score: 11
Has thanked: 5 times
Been thanked: 3 times

Re: Significant overhead for the GetSource() call

#8

Unread post by pizza »

ErickSkrauch wrote: 3 days ago

For now, I’ve implemented a local solution with a cache and a button to clear it. With this approach, everything works smoothly, but I get annoyed having to press that button all the time. I haven’t given up hope of finding a working solution.

Depending on what you are doing perhaps you could also consider something like storing a value from last frame as a point to continue from? For example:

  1. LastValue, LastFrame;
  2. function Process(req)
  3.   if (req.Time == LastFrame+1) then
  4.     LastValue = LastValue + InNumber:GetValue(req).Value;
  5.   else
  6.     // loop over preceding frames
  7.   end
  8.   LastFrame = req.Time;
  9. end

When values are changed the current frame should re-render and LastFrame + 1 will not equal the current frame, invalidating your cache. In practice I'm not sure if this will come with any gotchas so you might still need the clear cache button, but hopefully it helps make things easier to use.


User avatar
ErickSkrauch
Posts: 6
Joined: 3 weeks ago
Reactions score: 0
Been thanked: 1 time

Re: Significant overhead for the GetSource() call

#9

Unread post by ErickSkrauch »

pizza wrote: 3 days ago

When values are changed the current frame should re-render and LastFrame + 1 will not equal the current frame, invalidating your cache. In practice I'm not sure if this will come with any gotchas so you might still need the clear cache button, but hopefully it helps make things easier to use.

Hmm. You've given me an interesting idea. I can cache the input values. If they differ from the calculated value for the current frame, that will be a clear signal that the cache needs to be invalidated. It’s still not a perfect solution, but at least it’s something. It’s a shame that NotifyChanged works so poorly and doesn’t allow for a proper implementation without workarounds.


User avatar
ErickSkrauch
Posts: 6
Joined: 3 weeks ago
Reactions score: 0
Been thanked: 1 time

Re: Significant overhead for the GetSource() call

#10

Unread post by ErickSkrauch »

Oh yeah, that worked. The Recalculate button is history!

As a final touch, I’d like to set the animation for all inputs to use the Step In spline mode by default. This setting is available when manually editing an input, but I can’t find any documentation for this option in Fusion scripts. Do you happen to know how to do this?

step_in.webp
You do not have the required permissions to view the files attached to this post.