Skip to main content
Participating Frequently
September 7, 2007
Question

Deadlock between CS3 Bridge and Photoshop

  • September 7, 2007
  • 8 replies
  • 1389 views
I've run into a deadlock problem with a script that exposes a modal dialog in Bridge and sends a msg to Photoshop. The PS code hangs at 'document.backgroundLayer.copy()', after executing many lines of code.
This code worked in CS2 and I've played around quite a bit to try to make it work in CS3.

A test snippet that exposes the problem is in http://jhollow.users.sonic.net/test.zip

Any help would be appreciated.

P.S. another bizarre behavior -- after the test code times out and I dismiss the error dialog, at the next key depress of CTRL or ALT I get an error dialog that says "an error occurred in a bridge extension, Javascript Error (xxxx:277): undefined is not an object". Any ideas on this?
This topic has been closed for replies.

8 replies

Participating Frequently
November 30, 2008
Thanks!

Good Luck.
______
My Si tes
Participating Frequently
September 19, 2007
Hi,
Thanks for your help, I managed to sort out my code so that it works now. See the excerpt in http://www.jhollow.members.sonic.net/task3.jsx

Thanks,
jack
Participating Frequently
September 10, 2007
Hi,

The problem is with the check for the result from the BT message, the section of code starting at line 90:

while(!result) ...

Don't check for a result from a BT message in this way. I'm not exactly sure why but I think it is because this is blocking the main thread and never gives the BT onResult callback the chance to run. Try something like this:

var psScript = "$.mylevel = 1;if ($.mylevel > 0) $.writeln(\"Entering Photoshop, JS Engine UID= \" + $.UID + \", displayDialogs=\" + app.displayDialogs); \
var f = new File(\"c:\\Temp\\test.psd\"); \
var doc = open(f); \
if ($.mylevel > 0) $.writeln(\"doc =\" + doc + \", about to copy layer...\"); \
doc.backgroundLayer.copy(); \
if ($.mylevel > 0) $.writeln(\"Photoshop: Copy done!\"); \
doc.close(SaveOptions.DONOTSAVECHANGES); \
\"Photoshop Done!\";";

var bt = new BridgeTalk();

bt.target = "photoshop";
bt.body = psScript;

bt.onResult = function(res)
{
MyTask.btFinished = res.body;
}

MyTask = {};
MyTask.BTFinishedCheck = function()
{
if(MyTask.btFinished)
{
$.writeln("BT Finished OK");
app.cancelTask(MyTask.checkBTID);
continueProcessing();
}else
{
$.writeln("BT not finished");
}
}

bt.send();
MyTask.checkBTID = app.scheduleTask("MyTask.BTFinishedCheck()", 500, true);

continueProcessing = function()
{
$.writeln("Starting...");
}

Cheers
Participating Frequently
September 10, 2007
More info:

If I manually launch PS first, then launch Bridge, the test works!

If I launch Bridge first, then either let my test code launch PS or manually launch PS, the test hangs...

The hang is on the copy() function in PS, which uses the Clipboard.

The most recent version of the code, with trace results is in http://jhollow.users.sonic.net/test2.jsx
Participating Frequently
September 9, 2007
After more investigation:

1) Please ignore the stuff about error dialogs, my code that did a "throw Error" was brain dead.

2) I still get a reproducible hang with the remote script at the statement "doc.backgroundLayer.copy()". Note that this involves the clipboard, which could be the shared resource that is blocking Photoshop. I've tried bringToFront and setting activeDocument to no avail. I suspect a Bridge/PS bug.

WinXP Pro, single and multicore, 32and 64-bit
Participating Frequently
September 7, 2007
Hi, some more data:

I installed another copy of CS3 on my Dell Latitude laptop running WinXP Pro (x32). The test failed once but then seemed to work. Then I ran Adobe Update and after that the failure is consistently identical to that on my first machine (which is a quad-core AMD Opteron BTW).

Both WinXP machines have current MS updates.

Sounds like a timing related problem...

BTW, more details on the maybe related "an error occurred in a bridge extension, Javascript Error (xxxx:277): undefined is not an object" error. This happens only the first time I run the test after launching Bridge. After dismissing the remoteEval timeout dialog (first time) AND then after the first UI event (key down, mouse click) I get a beep, then two error dialogs in sequence, then a second beep and a third error dialog. The text string in parens seems accidental (like "Test" or "Photoshop") and I'm guessing the number is a line number towards the end of test.jsx. This series of errors only happens the first time through after launching Bridge. Sounds like some garbage messages sitting around in some queue, perhaps timing related.
Participating Frequently
September 7, 2007
Hi, thanks for testing for this. I forgot to mention my configuration: PS CS3 10.0, Bridge 2.1.0.100, WinXP Pro x64.

I disabled all other scripts, still get the problem. The debug msgs from my execution are:
<<Test.jsx loading into estoolkit
>>Test.jsx loaded into estoolkit
<<Test.jsx loading into bridge
>>Test.jsx loaded into bridge
withProgress(Test Deadlock)
about to show()
about to scheduleTask
scheduleTask ID 1
Continuation task enter
Entering Worker Task
remoteEval photoshop
About to send var f = new File("c:\Temp\test.psd");
var doc = open(f);
if ($.mylevel > 0) $.writeln("doc =" + doc + ", about to copy layer...");
doc.backgroundLayer.copy();
if ($.mylevel > 0) $.writeln("Copy done!");
doc.close(SaveOptions.DONOTSAVECHANGES);
false;, to photoshop
Sent, waiting for result
<<Test.jsx loading into photoshop
>>Test.jsx loaded into photoshop
doc =[Document test.psd], about to copy layer...
remoteEval timed out
Copy done!

This problem still occurs when the d.show() is commented out, so it's not dependent on the palette being exposed. (I did notice that the docs say that palettes are not supported by CS3, say this isn't so.)

I'm not setup yet to test my script under other OS's, but I have to suspect a WinXP Pro x64 dependency. Any evidence of this?

jack
Participating Frequently
September 7, 2007
Hi,

I tried your test code and could not replicate the error. I was using PS CS3 10.0 and Bridge 2.1.0.100.

The script ran fine with no errors. So I would assume you have a script loaded in Bridge that is causing some interference. You could try temporarily disabling all of the scripts in Bridge and then try your code.

Hope that helps - even just a little bit.

Cheers