Potential script closure issue

Upload Photoshop Scripts, download Photoshop Scripts, Discussion and Support of Photoshop Scripts

Moderators: Tom, Kukurykus

hillrg

Potential script closure issue

Post by hillrg »

Try running the attached script in photoshop. A small dialog with a run button will appear. Click run and a complex template editor dialog will open. Cancel the template editor dialog. Repeat this process 5-6 times. It takes longer each time for the dialog to open. There is some timing code in the script that reports to the ESTK.

I think this is a closure issue, caused by the inner functions used, but I am not sure. Any feedback on how to prevent this would be greatly appreciated.

Also, any idea what $.debugDialog does? I found it at the start of ImportCamera_BR.jsx.

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

Potential script closure issue

Post by Mike Hale »

Is this the full code? I can't get it to run at all. I get an error on line 33 'Ditto is undefined'.

I commented out that line and got the same error at line 44
hillrg

Potential script closure issue

Post by hillrg »

Mike Hale wrote:Is this the full code? I can't get it to run at all. I get an error on line 33 'Ditto is undefined'.

I commented out that line and got the same error at line 44

Hi Mike

It runs on my two PC's by itself in photoshop CS2.

You could try adding the line

Ditto = {};

before line 33. It works both ways for me.
Mike Hale

Potential script closure issue

Post by Mike Hale »

That helped, I now get the first dialog. But if I click on run it gets stuck in a loop. I get an error 'Ditto.ddhelp is not a function'. I have to cancel the run dialog to exit.

I am running this using ESTK and CS2, but it does the same if I run it from the CS2 script menu.
hillrg

Potential script closure issue

Post by hillrg »

Mike Hale wrote:That helped, I now get the first dialog. But if I click on run it gets stuck in a loop. I get an error 'Ditto.ddhelp is not a function'. I have to cancel the run dialog to exit.

I am running this using ESTK and CS2, but it does the same if I run it from the CS2 script menu.

I thought I had gotten rid of the ddHelp stuff. For some reason it is still working on my machine.

I have commented out the helptips and reattached the file.

Thanks very much for the feedback to help with this.
Mike Hale

Potential script closure issue

Post by Mike Hale »

Rory,

I'm afraid that I will not be able to help you much with this. Other than to comfrim that it does take longer on my machine as well. Each loop seems to take about 45 seconds longer on my machine. Although it does vary and sometimes there is little increase.

I did several runs, some as long as 20 loops. I ploted the timing results in excel. It is just a guess, but it might be JS garbage collection because different parts take more time in each loop.

For example, in one run Dropdown lists timing was 0 twice, 16 9 times, 32 3 times and 64 once. The other sections where much the same, generally taking longer each loop but some times faster than the previous loop.

I can follow your code, but my skill set in not strong enough to see why it takes longer. I did move the fontlist code to the top so it is only run once and that seems to help level out the 'General tab' section.

Hope this helps and hope you find the problem

Mike
Mike Hale

Potential script closure issue

Post by Mike Hale »

One other thought

On my system there is a very large gap between show() and when the dialog appears on the screen. That may be due to your using autolayout. Here the first loop is generally done in less than a second but the dialog does not display for almost 20.

It could be that even though Adobe recommends using autolayout it, like other JS parts new to Photoshop, is not ready for printe time.

You might try building the dialog without autolayout. It could be that if the dialog showed in 1 second the first loop, you wouldn't mind that it taking 3 seconds by the 5 or 6 loop. But with it already taking too long in the first loop, any increase is very noticeable.
hillrg

Potential script closure issue

Post by hillrg »

Mike

Thanks very much for taking the time to try this out and confirm the performance degradation. I'll keep plugging away and xbytor said he would take a look.

Have a very Merry Christmas.
hillrg

Potential script closure issue

Post by hillrg »

Update - Adobe has confirmed this is an issue.
xbytor

Potential script closure issue

Post by xbytor »

I've also sent them code for what is probably the same underlying problem with closures. At least I've been able to work around it in my code.