Skip to main content
vmartin00
Participant
November 23, 2021
Question

AEGP_GetLayerNumEffects crash in AEGP IdleHook

  • November 23, 2021
  • 1 reply
  • 179 views

Hello,

 

I got an intermitent crash when invoking EffectSuite4()->AEGP_GetLayerNumEffects()


I got a setup where I have an effect and an AEGP.
Upon Effect creation, it will register itself on PF_Cmd_SEQUENCE_RESETUP to the AEGP with it's layer ID as key (we stricly enforce an one effect per layer). 
The AEGP will save the layer handle (PFInterfaceSuite1()->AEGP_GetEffectLayer()) and push it to a queue to process it in the idle update.


the crash happen when copy pasting / deleting a bunch of solid at once, triggering multiple updates,
I guess my handle get invalidated before it get processed by the AEGP, but is there a way to check the AEGP_LayerH validity ?
I tried to rely on  PF_Cmd_SEQUENCE_SETDOWN to unregister effect on the AEGP, but found it unreliable as it get triggered also when copy pasting layer and effects.

TL/DR: How do you manage correctly lifecycle of effect when there are dependant of each other.

thanks in advance

This topic has been closed for replies.

1 reply

Community Expert
November 23, 2021

my dear friend, you have stumbled upon a tough issue...

sequnece data calls are a bit of dark magic. you can't rely on layer handles aquired during these calls, and here's why:

1. sometimes during a sequence data call, the effect is not yet associated with any layer, so calling GetEffetLayer will result in an invalid or null layerH.

2. sometimes (especially when copying/duplicating multiple effect or layers), AE would call resetup on the original effect, but then use the resulting seq data handle on the new effect. so you would get the layerH of the old effect instead of the new.

 

if you can't work around these limitations, then you need a new strategy altogether. here's a suggestion:

1. on setup or resetup, keep a flag in sequence data saying it needs being handled.

2. inform your AEGP there's an instance in need of handling, without a layerH.

3. if an effect is waiting, then on idle hook have your AEGP scan the whole project, and look for instances.

4. query found instances for thier flag state using EffectCallGeneric().

vmartin00
vmartin00Author
Participant
November 23, 2021

Thanks for your answer,

I was hoping not to do that, but yeah... I guess I'll do a workaround of the style.
Thanks for the suggestion !

the lifecycle effect could be so much easier with a created / deleted callback, that's a shame we don't get thoses