New Clarity and Grain adjustments layers are missing their layer.kind values

I just posted the following in the pre-release forum.

The new Clarity and Grain adjustment layers appear to be missing their layer.kind property values when attempting to access them using UXP.

HTML:

`<sp-button id="buttonGETLAYERKIND">Get Layer Kind</sp-button>`

JavaScript:

document.getElementById(“buttonGETLAYERKIND”).addEventListener(“click”, async() => {    
    const doc = await app.activeDocument;
    const layers = await doc.layers;
    
    layers.forEach((layer) => { 
        try { console.log(layer.kind) }
        catch(e) { console.log(e) } 
    });
});

When this code encounters a Clarity layer, it throws the following error:

Error: Invalid value of ‘clarity’ for the type ‘^1’.
at get kind [as kind] (uxp://uxp-internal/ps-app.js:1)
at VM28 index.js:315
at Array.forEach ()
at e.exports. (VM28 index.js:314)

When it encounters a Grain layer, it throws the following error:

Error: Invalid value of ‘grain’ for the type ‘^1’.
at get kind [as kind] (uxp://uxp-internal/ps-app.js:1)
at VM28 index.js:315
at Array.forEach ()
at e.exports. (VM28 index.js:314)

Below is a list of Photoshop’s LayerKind values:

LayerKind: Object
BLACKANDWHITE: “blackAndWhite”
BRIGHTNESSCONTRAST: “brightnessContrast”
CHANNELMIXER: “channelMixer”
COLORBALANCE: “colorBalance”
COLORLOOKUP: “colorLookup”
CURVES: “curves”
EXPOSURE: “exposure”
GRADIENTFILL: “gradientFill”
GRADIENTMAP: “gradientMap”
GROUP: “group”
HUESATURATION: “hueSaturation”
INVERSION: “inversion”
LAYER3D: “threeD”
LEVELS: “levels”
NORMAL: “pixel”
PATTERNFILL: “pattern”
PHOTOFILTER: “photoFilter”
POSTERIZE: “posterize”
SELECTIVECOLOR: “selectiveColor”
SMARTOBJECT: “smartObject”
SOLIDFILL: “solidColor”
TEXT: “text”
THRESHOLD: “threshold”
VIBRANCE: “vibrance”
VIDEO: “video”

As you can see, “clarity” and “grain” are not included.

This will present a significant problem for UXP developers. When coding using UXP, it is assumed that every layer will have a layer.kind property associated with it. With the absence of layer.kind values for Clarity and Grain layers, any UXP code that iterates over all document layers to determine their layerKind will error out now unless the code includes a try/catch to intercept the error.

The expected behavior would be that no error would be thrown when the code executes.

2 Likes

Testing using the code to determine other layer property values shows that, in addition to the “kind” value, the same error is thrown when looking for the following layer values:

adjustmentInfo
bounds
textItem

So, it’s not just the layer.kind value that throws the error. The same will happen with layer.adjustmentInfo, layer.bounds, and layer.textItem.

Other layer values listed below do not throw a similar error:
_docId
_id
allLocked
blendMode
boundsNoEffects
document
fillOpacity
filterMaskDensity
filterMaskFeather
id
isBackgroundLayer
isClippingMsk
layerMaskDensity
layerMaskFeather
layers
linkedLayers
locked
name
opacity
parent
pixelsLocked
positionLocked
selected
transparentPixelsLocked
typename
vectorMaskDensity
vectorMskFeather
visible

@samgannaway I think this needs an urgent update.

2 Likes

That error message is pretty broken.

The short answer is that the clairty and grain adjustment layers are new and not in the UXP DOM yet. I do advocate for keeping the DOM up-to-date. While support for this new layer is not likely soon, I think we can at least get the constant updated and sort out the error message.

Honestly, this sounds insane to me. I think I’ve mentioned this recently already, but I’ll repeat - after 5(?) years it seems UXP is still in beta. IMO any work done on Ps should already be done with UXP in mind. Adding new features or fixing bugs should never ever break existing plugins, and this case sounds like it was actually intentional - we add a feature and maybe a year later we’ll add it to the plugin ecosystem… Really?

2 Likes

Photoshop added support for bitmap masks in 1994 and 31 years later, ExtendScript DOM and UXP DOM do not have feature to create or delete bitmap mask. :smiley:

But I would imagine introducing breaking change would also break the DOM unit tests and in such a case PS should not go for public release.

3 Likes