Getting error message when playing all actions recorded from UXP button clicks in Ps Beta v25.9.0

I’m getting the following error message whenever I play an action that has steps that include recorded button clicks from UXP plugins

image

This is only happening in Ps Beta v25.9.0. It does NOT happen with the current product version of Ps (v25.7.0). I have replicated the errors on Windows 10 and an older MacBook Air computer running the Monterey OS (Intel chip).

I thought it might be another plugin causing this problem, so I removed all installed plugins.

image

The “Test BUtton” plugin is being run from UDT and I have removed all batchPlay from it except for the one button I’m using to try and understand where this error is coming from.

The HTML for the button I’m using is:

<sp-button id="buttonACTIONFROMUXP">Acton from UXP</sp-button>

The JS is as follows:

document.getElementById("buttonACTIONFROMUXP").addEventListener("click", async() => {
    
    try {
        // record function as an action and pass required variables.
        action.recordAction(
            {"name": "New Layer", "methodName": "myNewLayer"}, {"MyLayerName": "New Layer from action", "historyStateName": "Run My Action"}
        );
    } catch (e) {}
    
    //Run the action associated with the button when the button is clicked and pass the necessary variables
    //First variable is an empty object but could potentially be: {"mode":"action","uiMode":"never","hostControl":{}}
    await myNewLayer({"uiMode":"test"}, {"MyLayerName": "New Layer from click",  "historyStateName": "New Layer From Click"});
        
});

//adding function in global scope.
window.myNewLayer = myNewLayer;

async function myNewLayer(executionContext, info) { 
    
    try {await exeModal(targetFunction, {"commandName": "Progress...", "interactive": true});}
    catch(e) {
      if (e.number == 9) {showAlert("Some other plugin is using Photoshop!");}
      else {
          //THIS IS WHERE THE ERROR MESSAGE IS BEING GENERATED!
          showAlert(e)
      }
    }

    async function targetFunction(executionControl, string) {

        let hostControl = executionControl.hostControl;
        let documentID = await app.activeDocument._id;
        let suspensionID = await hostControl.suspendHistory({ "historyStateInfo": { "name": info.historyStateName, "target": [{ _ref: "document", _id: documentID }] } });

        ///////////////////// Start modal execution /////////////////////        
                
        await batchPlay([
            //Make new layer
            { "_obj": "make", "_target": [ { "_ref": "layer" } ]},
        ], {}).then(result => {console.log(result)}, error => {console.log(error)});        
        
        ///////////////////// Stop modal execution /////////////////////

        await hostControl.resumeHistory(suspensionID);
        } // end targetFunction()  
};

I have one beta tester using a Mac Apple Silicon computer and he cannot replicate this issue.

I’m completely mystified. I’ve been experimenting extensively with creating and playing actions from UXP button clicks, and everything was working fine with all my plugins until this started.

I’ve reset my Ps Beta preferences, but that did not help either.

Has anyone else had a similar experience? Does anyone have any idea what might be causing this?

Investigating…

Edited js to get it working in UDT Playground

document.getElementById(“buttonACTIONFROMUXP”).addEventListener(“click”, async() => {

try {
    // record function as an action and pass required variables.
    require('photoshop').action.recordAction(
        {"name": "New Layer", "methodName": "myNewLayer"}, {"MyLayerName": "New Layer from action", "historyStateName": "Run My Action"}
    );
} catch (e) {}

//Run the action associated with the button when the button is clicked and pass the necessary variables
//First variable is an empty object but could potentially be: {"mode":"action","uiMode":"never","hostControl":{}}
await myNewLayer({"uiMode":"test"}, {"MyLayerName": "New Layer from click",  "historyStateName": "New Layer From Click"});

});

//adding function in global scope.
window.myNewLayer = myNewLayer;

async function myNewLayer(executionContext, info) {
const app = require(‘photoshop’).app;
try {await require(‘photoshop’).core.executeAsModal(targetFunction, {“commandName”: “Progress…”, “interactive”: true});}
catch(e) {
if (e.number == 9) {require(‘photoshop’).core.showAlert(“Some other plugin is using Photoshop!”);}
else {
//THIS IS WHERE THE ERROR MESSAGE IS BEING GENERATED!
require(‘photoshop’).core.showAlert(e)
}
}

async function targetFunction(executionControl, string) {

    let hostControl = executionControl.hostControl;
    let documentID = await app.activeDocument._id;
    let suspensionID = await hostControl.suspendHistory({ "name": info.historyStateName, documentID  });

    ///////////////////// Start modal execution /////////////////////        
            
    await require('photoshop').action.batchPlay([
        //Make new layer
        { "_obj": "make", "_target": [ { "_ref": "layer" } ]},
    ], {}).then(result => {console.log(result)}, error => {console.log(error)});        
    
    ///////////////////// Stop modal execution /////////////////////

    await hostControl.resumeHistory(suspensionID);
    } // end targetFunction()  

};

I uninstalled Ps Beta on my Windows computer this morning and then reinstalled it NOT carrying anything over from the previous installation, and the problem went away. Not looking forward to reconfiguring Ps Beta the way I like it, but at least it appears to have solved this odd-ball problem. Will try the same thing on the Mac a little later when I have time.

Edit: The error message returned on restarting Ps Beta second time after installation. More info further down.

Maybe if you would listen to “garbage” events in Alchemist it would show you when/how modal state was elevated.

I could do this on my Mac yet, @Jarda. Do I have to turn on listening for “garbage” events or does Alchemist do this by default?

Check the settings and remove any events in ignore. And set filter to show all. So you would see actions + events together. That should be enough.

Oh, this is bizarre! I restarted Ps Beta and the problem returned. Same error message. I have uninstalled/reinstalled Ps Beta multiple times, and as soon as I restart Ps for a second session, the error message is back anytime I play an action that has steps recorded from a UXP plugin. If I load a plugin and some actions that were recorded from the plugin and then play the action the FIRST time Ps Beta opens, there is NO error message. However, when I close and restart Ps and then play the same action, the error message returns. It looks like the trigger for this error is restarting Ps the second time after Ps Beta is installed.

@Jarda – I’m not seeing anything in Alchemist that the modal state was invoked.

image

I’m starting to wonder if this might only be an issue with the “pre-release” version of Ps Beta. Three people that have the standard Ps Beta (not pre-release version) cannot reproduce this. Yet I’m able to reproduce it on two computers, Mac and Windows, running the “pre-release” version of Ps Beta. Trying to find some explanation for this, and this is the best idea so far.

OK, just downgraded Ps Beta from v25.9.0 to v25.8.0 (both are pre-release versions) and the problem goes away. No more error message even after closing and restarting Photoshop for a second session (and a third session) and using different images and different Photoshop actions recorded from different UXP plugins.

So, this appears to be a bug in Ps Beta v25.9.0, pre-release version only. Hope it doesn’t find it’s way to the non-pre-release version or the product version.

If you are in pre-release program (not a beta)… then you should take care of it and add ticket to system or the other forum. You should check what they are working on these days.

…what do you see recorded when you e.g. add layer using its dialog?

I filed a bug report, @Jarda.