Critical Bug at "make Shape from path"

A little heads-up for everyone using paths in their plugins: In one of the recent updates of Photoshop, a new bug crept in that made my whole plugin malfunction and gave me quite a bit of headaches to find and work around.

If you want to create a new shape using the work path, you’d usually use the following descriptor:

const desc = {
  _obj: 'make',
  _target:{
      _ref: 'contentLayer',
  },
  using: {
    _obj: 'contentLayer',
    type: {
      _obj: 'solidColorLayer',
      color: {
        _obj: 'RGBColor',
        red: 0,
        grain: 0,
        blue: 0,
      }
    },
    shape: {
      _obj: 'pathClass',
      targetPath: {
        _enum: 'pathKind',
        _value: 'targetPath',
      },
    },
  },
}

This does not work correctly anymore. Instead of using the target path (workpath), it just creates a new shape layer with an empty vector mask. When I built the plugin a few weeks ago, this bug didn’t exist.
(I’m now on version 22.1.0 20201125.r.94 where the bug exists)

Also, this bug is not just related to UXP/scripting. Recording the mentioned event in a Photoshop Action and playing that one back gives the same incorrect result.

For now, I’ve come up with the following workaround:

require(photoshop).action.batchPlay(workPathToShape, {})

function workPathToShape(color: Color): ActionDescriptor[] {
  return [
    __makeShapeFromPath(color), // usually this would be enough
    __deleteActiveVectorMask(),
    __selectWorkPath(),
    __makeVectorMaskFromActivePath(),
  ];
}

function __makeShapeFromPath(color: Color): ActionDescriptor {
  return {
    _obj: "make",
    _target: {
      _ref: "contentLayer",
    },
    using: {
      _obj: "contentLayer",
      type: {
        _obj: "solidColorLayer",
        color,
      },
      shape: {
        _obj: "pathClass",
        targetPath: {
          _enum: "pathKind",
          _value: "targetPath",
        },
      },
    },
  };
}

function __selectWorkPath(): ActionDescriptor {
  return {
    _obj: "select",
    _target: { _ref: "path", _property: "workPath" },
  };
}

function __deleteActiveVectorMask(): ActionDescriptor {
  return {
    _obj: "delete",
    _target: { _ref: "path", _enum: "path", _value: "vectorMask" },
  };
}

function __makeVectorMaskFromActivePath(): ActionDescriptor {
  return {
    _obj: "make",
    _target: { _ref: "path" },
    at: { _ref: "path", _enum: "path", _value: "vectorMask" },
    using: { _ref: "path", _enum: "ordinal", _value: "targetEnum" },
  };
}

I think this bug is quite critical as it can cause various plugins, actions and scripts from the past to crash in the latest version of Photoshop…

Are you sure? If you want to use work path you should reference work path and not selected path :slight_smile: At least if it can be used as a reference.

Yes I’m 99% sure. I think I even tried to reference the work path in that code.
And the code has worked before, the Photoshop update definitely broke it.

To validate this behavior you could do the following:

  1. Draw a path
  2. Record action
  3. Click the “Shape” button (at the top in the tool bar, when a path tool is selected)
    -> Shape get’s created from the path
  4. Stop recording
  5. Undo a step
  6. Play the recorded action

The results should be the same, but aren’t.

Ok thanks for the clarification. In this case, someone should fix it.

What if you record the action panel in old Photoshop and play in new Photoshop. Is that also broken?

Yes, that’s also broken.
This definitely has to be seen by some Adobe devs, I might look for a better place to post this bug tomorrow as it’s not only related to plugin development.

1 Like

I guess this forum would be the place

1 Like

Thanks, I’ve posted it there.