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/t...
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.