Skip to main content
Participant
July 8, 2021
Question

Crash on adding camera to composition

  • July 8, 2021
  • 2 replies
  • 545 views

After adding a camera to a comp via script, AFX crashes on opening the comp.

 

After running this, open the comp and AFX crashes.

var myItemCollection = app.project.items;
var myComp = app.project.items.addComp('Composition Name', 1920.0, 1080.0, 1, 5.6, 25);
var newCamera = myComp.layers.addCamera('020_030_', [0, 5.6]);

 

When manually creating a comp and then adding camera via script, it works.

var newCamera = app.project.items.activeItem.layers.addCamera('020_030_', [0, 5.6]);

 

AFX Version is 18.2.0

 

Am I doing something wrong or is this a bug?

This topic has been closed for replies.

2 replies

asdffgh8
Participant
July 23, 2021

posting here as i had similar problem and solved. my camera wasnt created via script but ae was instantly crashing when i opened the comp with the cam in it (the only camera in the whole project). Thanks to your advice on resetting the preffs i investigated and found out that my crashes were because of the "Display Markings in Layer Bars" variable for the cache markings which i had set to 01 earlier. Now i set it back to 00 and no more crashes. Its in the "Adobe After Effects 18.2 Prefs.txt" file

Mylenium
Legend
July 8, 2021

You pretty much answered your own question: Order of execution matters and your code does neither branch nor does it have any checks for whether collections exist and are valid and if stuff already has been created. You will of course need a bit more work rather than just blindly firing three lines of code. Add an if...else... or try...catch... or refer to the scripting guide on how to check and manipulate the various internal collections to create safe code.

 

Mylenium

Participant
July 8, 2021

nor does it have any checks for whether collections exist 

quote

You pretty much answered your own question: Order of execution matters and your code does neither branch nor does it have any checks for whether collections exist and are valid and if stuff already has been created. You will of course need a bit more work rather than just blindly firing three lines of code. Add an if...else... or try...catch... or refer to the scripting guide on how to check and manipulate the various internal collections to create safe code.

 

Mylenium


By @Mylenium


These lines are of course a simplified excerpt of a larger script to illustrate the problem.

The Problem is not with the script, i am merely trying to illustrate the Problem.

 

Run this line:

var newCamera = myComp.layers.addCamera('020_030_', [0, 5.6]);

on any comp you want, then open the comp. AE will crash in the current version.

It's as simple as that.

 

If the script would error, i would understand, but that's not the case. This line makes the comp unopenable.

 

I just checked on AE 17.7.0 and the Problem does not exist.

 

This makes a big part of your production pipeline simply unusable.

Dan Ebberts
Community Expert
Community Expert
July 8, 2021

I just tried your code on 18.2.1 (Windows) and it works fine for me (no crash).