Skip to main content
snakehill
Known Participant
January 30, 2024

Hanging Script when Removing Effect (long time issue, known cause)

  • January 30, 2024
  • 5 replies
  • 513 views

Someone asked me to troubleshoot a custom script I made for them a few years back. From my understanding, it last worked in AE 2020. They moved on to 2023 and now 2024, but each time they run the script, After Effect hangs showing an everlasting load icon. It sounds very much like what has been going on here: https://community.adobe.com/t5/after-effects-discussions/ae-2021-and-2022-freeze-when-using-script/td-p/12573468

 

After trying out the script line by line, I discovered that it happens when removing a layer effect, for example via: 

comp.selectedLayers[0].effect('Sharpen').remove();

 

The exact code really doesn't matter, whether it's straightforward or via Effects or property. Having .remove() on a layer effect anywhere in the running script or function will make it hang, without exception as far as I could tell. In other situations, like on layers themselves, .remove() doesn't cause the same issue.

 

Interestingly, upon pressing Escape, it does show to have processed all as intended, removing the effect successfully. I haven't been able to tell whether it does so upon and due to the Escape or whether it did so prior.

 

By the looks of it, AE just doesn't know when to stop the process or how to exit the script when there is a .remove() for a layer effect present. Trying to add an exit to the script, for example via a return (false), doesn't solve it.

 

Win 10 and 11, i7 9700k and Ryzen 7 5800x, 16 and 32 GB respectively, iGPU and RTX 3080, so the hardware doesn't seem to matter.

This topic has been closed for replies.

5 replies

JohnColombo17100380
Community Manager
Community Manager
February 1, 2024

Hi @snakehill,

Thank you for isolating and reporting this issue. We can reproduce it as well with the script you provided and we have opened a ticket to investigate potential fixes.

 

Thanks again,

- John, After Effects Engineering Team  

snakehill
snakehillAuthor
Known Participant
January 31, 2024

Glad it was reproduced. The strangest thing is that, as far as I'm aware, Esc cancels the script. That would mean it's already done and has removed the layer effect(s), somehow the expression making it think it's still doing something or that it didn't finish, for layer effects only.

 

I had tried $.wait/.sleep, or even removing the expression, but no such luck.

Dan Ebberts
Community Expert
Community Expert
January 31, 2024

That is interesting. There does appear to be some intereaction (maybe a timing issue) between the sampleImage expression and removing the layer. I could get it working some of the time (but not always) by adding a $.wait(500) before the remove(). Looks like a bug to me.

snakehill
snakehillAuthor
Known Participant
January 31, 2024

Oof, I was mistaken, it not just being the .remove() but a combination of things. Commenting out all removes opposed to anything else did fix the script in question, hence I thought that must have been it, but correlation does not equal causation.

 

This is one of the combinations that used to work that apparently makes it hang (yet still process correctly upon process Escape), a .remove() in combination with a sampleImage .expression. Commenting out either will make it process:

 

var layer = app.project.activeItem.selectedLayers[0];
layer.Effects.addProperty("Color Control");
layer.Effects.addProperty("ADBE Lumetri");
var color = layer.Effects.property("Color Control")("Color");
color.expression = "thisLayer.sampleImage(transform.position,[0.5,0.5]/2,true,time)";
layer.Effects.property("Lumetri Color").property("White Balance").setValue(color.value);
layer.Effects.property("Color Control").remove();

 

Dan Ebberts
Community Expert
Community Expert
January 30, 2024

I'm not seeing anything like that on AE 2024 (on Win 11 though). Using this code, I can remove the Sharpen effect if it's the only effect, or in a group of effects:

var comp = app.project.activeItem;
comp.selectedLayers[0].effect('Sharpen').remove();

Context may matter, so it might help to see more of the script.