Bluesatin - 2024-01-14

Bug Report Summary

Photoshop freezing and becoming non-responsive when exporting an action containing a step where it saves a file using the 'NVIDIA Texture Tools Exporter' plugin (for .DDS files).

Issue

Photoshop kept freezing when trying to export several different Actions to XML when they contained a step that used the' NVIDIA Texture Tools Exporter' plugin to save a file. Photoshop would continue to whirr away with some CPU usage, so it appeared to be getting stuck doing something rather than actually crashing.

After a bunch of logging and debugging, it appears the issue is somewhere along the line of when the XTools script is extracting the 'PATH' entry for the saving action item (where it's supposed to save). It appears to extract an absurdly large number for how long the path string was expected to be (like 186335 characters long or something). And the loop for iterating through extracting each character would therefore get stuck, never able to exit the loop due to never being able to reach that number.

Hackjob Fix

My hackjob fix was to modify the xtools/xlib/ActionStream.js script on line 913, modifying the Stream.prototype.readUnicodeString = function(len, readPad) function by changing the &&/and logic to an or/|| one. Allowing the script to exit the loop if it either reaches the extracted length, or until it hits an empty character, rather than requiring both.

The function should change to looking like this:

Stream.prototype.readUnicodeString = function(len, readPad) {
  var self = this;
  var s = '';
  for (var i = 0; i < len; i++) {
    var uc = self.readInt16();
    // Switch the check below from '&&' to an '||' operator
    // ↓↓ CHANGE HERE ↓↓
    if (uc == 0 || (i + 1) == len) {
      return s; // should have been one char shorter
    }
    s += String.fromCharCode(uc);
  }
  if (readPad == true) {
    self.readInt16();     // null pad
  }
  return s;
};

Presumably a better fix would be to examine the length extraction and fix that, but since I didn't want to try and figure out how all that stuff worked, that hackjob didn't seem like it'd cause any major issues for anyone needing a quick fix.

Thanks for all the hard-work, these scripts have been a lifesaver.

 

Last edit: Bluesatin 2024-01-14