Expressions/Scripts/Presets

Moderator: Paul Tuersley

 
HTN3D
Topic Author
Posts: 9
Joined: Tue Feb 28, 2017 4:02 pm
Location: Atlanta, GA
Contact:

AE is crashing

Sat Mar 11, 2017 4:02 am

I am writing a script with interface that creates a comps contain text and shape layers. I have been testing the script by creating one comp every time I testing it as I am writing the code  and everything was normal until I accidentally tried to create multiple comps then it crashed. I check everything but it keeps crashing whenever i create more than one comp.
I am using Git so I backed couple versions and I found that the problem started occur when I started splitting the code to multiple libraries to keep it maintainable because its fairly long and contains many functions and modules, so I am wandering if there are any limitations to the number of libraries or variables or loops that I can use in AE script. And also if there is a way to debug the crash and understand what's going on. I am using Atom on Mac and not showing anything.

I have been learning and writing script for few months now.. so I will be very grateful for any advice.
Haider Najeeb
Art Director and Motion Designer
www.htn3d.com
 
HTN3D
Topic Author
Posts: 9
Joined: Tue Feb 28, 2017 4:02 pm
Location: Atlanta, GA
Contact:

Re: AE is crashing

Sat Mar 11, 2017 4:16 am

Update..
I tried to test the script on Windows and it's same problem but the difference is showing legitimate message which says:
"After Effects: Memory allocation of 12.3 GB exceeds internal limits. Decrease the memory requirements for the rendering of this frame. (12802). For more information, see www.adobe.com/fo/lear_ae_mem"

It sounds a memory problem so maybe something wrong with variables scope or the loops i'm using? I have few global vars waiting util I finish to put them inside a main function but could they causing this problem?
Haider Najeeb
Art Director and Motion Designer
www.htn3d.com
 
runegan
Posts: 20
Joined: Fri Nov 04, 2016 3:18 pm
Contact:

Re: AE is crashing

Sat Mar 11, 2017 5:03 pm

Are you able to create some sample code that reproduces the problem?

How are you importing your libraries? Are you using @include/#include?

Using multiple files should not be a problem. I have been dealing with 30+ files without any trouble.

I'm thinking it may be a problem with the resolution or duration of the comps. If they are big and long, I'm guessing they may become a problem for AE.
 
HTN3D
Topic Author
Posts: 9
Joined: Tue Feb 28, 2017 4:02 pm
Location: Atlanta, GA
Contact:

Re: AE is crashing

Sat Mar 11, 2017 9:26 pm

Thanks Runegan for your response!
I am using #include and I don't think the comp resolution or duration is the problem. I ran many tests and I think the problem occur in the objects that I am passing by the function arguments. I am not sure but I think they're kind of not releasing the memory after the function is done and keep staking the data(not sure just personal thought). So I did some research about the memory management in JavaScript and I'm reading about memory leak and how to avoid it but still not sure if I need to clear this objects manually every time I use them?

briefly my script is a UI that generated by long "resourceString" and by onClick button it passes couple of objects as arguments to multiple functions to create the comp. these objects are a parameters that have been collected from the UI. the script creates first and second comp normally but crashes the AE on the third comp. sometimes ExtendScript showes the object is "undefined" before it crashes.
Haider Najeeb
Art Director and Motion Designer
www.htn3d.com
 
HTN3D
Topic Author
Posts: 9
Joined: Tue Feb 28, 2017 4:02 pm
Location: Atlanta, GA
Contact:

Re: AE is crashing

Mon Mar 13, 2017 8:55 am

the problem finally solved and I would like to share what it was. 
After I inspected every single function in the script I was suspicious about one function that creates the GUI. I used Mathias Möhl approach but it contains some statements I wasn't sure if they were necessary to have. I tried to search about it and I liked David Torno approach of how he build the GUI in AE. So I used it after a little tweaks and the problem solved.

so the old code I was using to building the GUI was like this:

function createUserInterface (thisObj,userInterfaceString,scriptName){
  var pal = (thisObj instanceof Panel) ? thisObj : new Window("palette", scriptName,  undefined,{resizeable: true});
  if (pal == null) return pal;

  var UI=pal.add(userInterfaceString);

  pal.layout.layout(true);
  pal.layout.resize();
  pal.onResizing = pal.onResize = function () {
    this.layout.resize();
  }
  if ((pal != null) && (pal instanceof Window)) {
    pal.show();
  }
  return UI;
};


And I replaced it with the following code and it solved the problem: 

function createUserInterface (thisObj,scriptName){
  var UI = (thisObj instanceof Panel) ? thisObj : new Window ("palette",scriptName,undefined, {resizeable:true});
  resourceString = "whatever string...";
  UI.mainPanel = UI.add(resourceString);
  if ((UI != null) && (UI instanceof Window)){
    UI.center();
    UI.show();
    return UI;
  }
}


I am glad that I ran through this problem because that pushed me to search a lot about the internal memory management in JS and learn how possible small mistake could lead to memory leak..
Haider Najeeb
Art Director and Motion Designer
www.htn3d.com

Who is online

Users browsing this forum: No registered users and 4 guests