Is there a way to know when a frame preview starts or ends, or even check if it's rendering?
Here's my problem, I have a custom UI for my plugin, and when changing values interactively, AE doesn't have time to render (preview) a complete frame before the next one is requested. This means that the frame being rendered is cancelled and a new one requested. I never get a fully rendered frame until I stop changing values.
I want to skip frame requests if the last one is still rendering. Either by detecting if one frame is still rendering, or telling the preview renderer to not cancel my previous frame.
I home this makes sense.
do you abort the renderin mid process, or does AE throw away your complete result?
if you're aborting, you can set a flag in your global data telling an interaction is going on, and then avoid aborting during interaction.
AE throws it away mid process. What I'm actually doing is changing a data parameter using AEGP_SetStreamValue. This triggers a preview frame render. In my test case a frame takes about 60ms to process, but I'm setting the parameter faster that that. The problem is even worse if the frame takes more time that that.
ae throws what? an abort message when checking PF_ABORT()?
I meant AE thows the current frame away, meaning no change to the preview unless I stop changing the data parameter. Once I stop and there are no more interruptions, the preview renderer is able to finish a full frame and the result is shown in the preview.
Just to clarify a bit more:
This is how I create my hidden parameter that holds the data I'm changing:
PF_ParamDef def; memset(&def, 0, sizeof(PF_ParamDef)); def.param_type = PF_Param_ARBITRARY_DATA; aeData->inData->utils->ansi.strcpy(def.name, "MyData"); def.ui_flags = PF_PUI_NO_ECW_UI; def.flags = PF_ParamFlag_CANNOT_TIME_VARY; def.u.arb_d.refconPV = (void*)0x1; def.u.arb_d.id = 10000; def.u.arb_d.dephault = data; def.uu.id = pid; PF_ADD_PARAM(aeData->inData, -1, &def);
Now my custom UI is not an AE panel, it's a small window on the side where I have a bunch o windows controls. I use those controls to change my custom parameters that are then saved into the data structure I created with the code above.
I then use AEGP_SetStreamValue to save my changes to the data structure. Just as I do this, AE triggers a preview refresh (BTW I'm talking about preview render, not actual rendering). I have a slider for this, and moving the slider creates a bunch of saves like this one, and AE seems to immediatly abort the current frame render preview as soon as I save this data once again. Since I'm saving a lot of timer per second, AE never finishes a frame and I don't get any preview refresh until I stop the mouse movement.
So... I want to check the progress of the preview, or maybe when it stops, or if it's possible to force AE to finish a preview frame instead of throwing it away mid process.
good question... i'm not sure there's something you could do about it. i think that's just how AE behaves with long processing times while interacting...
i'm trying to think of some workaround.
Is it possible to at least know how long the last preview frame took? I see the elapsed time shows at the bottom left of AE's window (Frame Render Time).
I could use that to calculate an average and use it as frameskip.
shouldn't getting the system time at the beginning and the end of a render call do the trick?
I only need to know when the preview is done. The time interval would be a workaround. I cannot use the render call for this because it only represents my plug-in, not the whole render.
ah, now i see what you mean by render.
well, there is SOME (very partial) way of deducing whether a preview is currently rendering.
during a preview render, custom comp UIs are deactivated. so if your plug-in is the only one selected, yet it's comp ui is off, then it's likely that a preview is being rendered. (this is soooo NOT deterministic)
How can I check if the custom UI is locked? I can do that just as I'm about to save my data.
Also, I'm wondering how custom parameters in an AE panel can be changed and update the preview at the same time without getting into this issue. I guess they are "more native" than my own.
you need to implement a custom comp ui. when it deactivates the plugin gets an event call of type "deactivate".
(take a look at the "CCU" sample project)
the effect also geta s "deactivate" call when the effect is either deselected or is selectd along with other effects. (it's active only when it's selected alone)
Alright, thanks Shachar.