• Editor
  • [Photoshop] Empty error dialog box before crash

Hello !

Since yesterday, for no apparent reasons, the PhotoshopToSpine.jsx script available on GitHub stopped working.
We tried numerous versions of Photoshop and the script, without any luck.
This is currently happening on (at least) two machines at our workplace.

On a very simple PSD, I get an empty error box from Photoshop when the script is initializing :

Afterwards, Photoshop hangs on and/or eventually crashes.

It sounds like a very nasty issue, and I'm very unsure where to start to look at :scared:

Is it a known issue ? Does anyone have a hint of where to look at ?

Thanks in advance for any help 🙂

Sorry about that! We've fixed the alert. It shouldn't have made Photoshop crash though. After the alert the script tries to open the errors text file it created. You should find the errors.txt file next to the JSON output file.

Hello 🙂

I just tried the 7.20 version of the script, and it hasn't changed anything in the behaviour :\

To note :

  • an "images" folder is successfully created
  • there is no json output file created
  • there is no "errors.txt" file created

The pending error seems to be triggered very soon in the script, even before the "Collecting layers" phase.

In the meantime, we might try to roll up our sleeves and debug the ExtendScript


After debugging, the "empty" error is triggered on the following line :

return executeActionGet(ref).getBoolean(sID("hasBackgroundLayer"));

After clicking "cancel" on the dialog, the code executes on the following line... :

... before I'm unable to debug anything and Photoshop hangs until it crashes :\

I have found the following post from someone who apparently had the same issue :
Photoshop to spine script error: p74631

I'll get back here after I tried the workarounds you proposed on the other post, Nate 🙂

7.20 should fix the empty alert. If you still see the alert, I'd question if you're really running 7.20? The 7.20 script doesn't have any empty alerts.

Thanks for debugging and tracking it down to hasBackgroundLayer. It's really terrible for Photoshop to ever hang because of something a script does, especially something that seems to work for most people. 🙁

Can you share your PSD? Maybe something in your PSD is causing hasBackgroundLayer to fail. If we can see it fail, then maybe we can come up with a workaround.

Just double-checked, I'm 100% sure I'm now using the 7.20 :grinteeth:

Back with more findings :

  • Removing the call to "hasBackgroundLayer" prevents Photoshop from triggering this strange empty dialog error, hanging, then crashing
  • I tried to replace the following line :
    first: hasBackgroundLayer() ? 0 : 1,
    ... with :
    first: 0,

On my PSD with no background layer, it triggered a verbose (but standard, not crash-inducing) error telling me the script was trying to do bad things with Photoshop. However, when I wrote the following line on the same PSD :

first: 1,

[/b]

... the script eventually worked ! :scared:

We haven't identified yet the differences between our workstations to understand what is actually happening (it works on some workstations but not on others, with or without the same Photoshop versions... it's a mystery.).

I'm sending you just in case the Test.psd I used to debug, but this is just a very very basic psd file :\

If we ever find what was causing the issue in the first place, we'll come back here with our new findings !


I've found this community thread about the issue(s) with finding if a PSD has a background layer or not, via JSX plugin :
https://webcache.googleusercontent.com/search?q=cache:on1mEG1EyhYJ:https://feedback-readonly.photoshop.com/conversations/photoshop/photoshop-how-to-check-if-document-has-background-layer-with-jsx-javascript-script/5f5f45f44b561a3d426aa1e9%3FcommentId%3D5f5f48b84b561a3d42353215+&cd=12&hl=fr&ct=clnk&gl=fr

Photoshop doesn't look friendly at all about plugins and the use of old JSX... you are heroes for maintaining this export script 😃

Thanks for the file. Unfortunately the script runs on the PSD for me. I wonder what difference there is on the computers it doesn't work. 🙁

midiphony-panda escribió

Photoshop doesn't look friendly at all about plugins and the use of old JSX... you are heroes for maintaining this export script 😃

Thanks. Photoshop scripting is absolutely horrible. Poor documentation, poor APIs, and it's very slow. We wrote the script using the lowest level APIs available because higher level APIs are much slower. Sadly the script is still pretty slow.

That's a pretty good thread. It's hard to tell if the last solution there is different from ours. Maybe you could try it:

function hasBackgroundLayer () {
   try {
      var ref = new ActionReference(); 
      ref.putProperty(cID("Prpr"), sID("hasBackgroundLayer")); 
      ref.putEnumerated(cID("Dcmn"), cID("Ordn"), cID("Trgt"));
      return executeActionGet(ref).getBoolean(sID("hasBackgroundLayer"));
   } catch (e) { // CS2.
      try {
         return activeDocument.backgroundLayer;
      } catch (ignored) {
      }
      return false;
   }
}

If that doesn't help, there are other ways to check, but they are slower. We can try that next. Sorry for all the trouble!

Just to let you know that the script runs without issue when replacing the "hasBackgroundLayer" function by the one you provided in your last post 🙂

That's good news! We'll update to 7.21 with that change. Hopefully it still accurately detects if a background layer exists.

11 días más tarde

Hello,
Thank you for the fixed is version 7.21 first of all.
I'm coming back to you because I noticed a regression with the 7.20 modification.
Indeed, some error stops the script but does not log the alerts and therefore impossible to know what is not working.
I tried to put back "alert(first);" (the modification of the 7.20) while keeping the fix of the 7.21 and everything works well, and I recover the alerts as it should.

Is it possible to correct this on your side? Thanks in advance.

4 días más tarde

@Nate : backing up @edesmet reply

It would be nice to get back the alert that was removed in 7.20, as it wasn't the cause of the issue.
(and the alert was informative :p)

It is back in 7.22. Sorry about that!