Modal "OK" and "Cancel" buttons stopped working

This is going to sound odd but the “OK” and “Cancel” buttons in my UXP generated modals stopped working. No code was changed. No new version of Ps was installed. I eventually loaded an archived development version through the UXP Developer Tool in place of the current version and then the buttons start started working again. Then I reloaded the current version, and it worked too. I was rebooting the computer and restarting Ps though all this, but none of this helped. I just started working again.

And then these buttons stopped working again. And then they started working again.

So it’s totally unpredictable. And when they stop working, it affects all modals generated by the plugin. So it seems to be something more than just some bad coding on one modal.

I’m still exploring if there’s something in the way persistent storage is loading that may affect this, but again, that’s never been an issue before, so it seems unlikely.

Just wondering if anyone else is seeing weird stuff with modal “OK” and “Cancel” buttons. I know it sounds weird, but something strange is going on that’s affecting all these buttons and I’m having a hard time tracking it down. Or does any one have any suggestions of things to try?

Was Ps also in a modal state? There are cases where you can essentially “deadlock” Ps & UXP because both are modal, and Ps has stopped the UXP JS thread. Because the UI is in a separate thread, the buttons remain clickable, but the JS events aren’t handled.

It might be worth seeing a video of this (feel free to DM it, if you don’t want to share here) to get a better feel of what’s going on.

I just reset my Photoshop preferences and now the “OK” and “Cancel” button in the modals are working again. Don’t know if this will be a permanent solution or not. The problem has gone away and then returned several times already. Will keep testing and report back if the buttons stop working.

OK, I think I figured it out. You comments were very helpful @kerrishotts and got me thinking in the right direction. Based on this thread, I had rewritten a getter with the batchPlay options:

{"synchronousExecution": true, "modalBehavior": "wait" }

However, this getter runs every 250 ms, and was apparently putting Ps in a modal state when it executed at this rate thereby causing the dialog modal’s “OK” and “Cancel” buttons to fail.

Once I reverted the getter code to

await require('photoshop').action.batchPlay([...

and the default batch play options:

{"synchronousExecution": false, "modalBehavior": "wait" }

and then used .then() to consume the getter’s output, everything works fine again.

Which makes me advise against using

{"synchronousExecution": true, "modalBehavior": "wait" }

in getters. Obviously it’s not a good combination and should probably be avoided.

I also tried the following batchPlay options:

{"synchronousExecution": true, "modalBehavior": "fail" }
{"synchronousExecution": true, "modalBehavior": "execute" }

in the getter

let getter = require('photoshop').action.batchPlay([...

and neither of these options options interfered with the “OK” and “Cancel” buttons in the dialog modal.

So I’m still unclear as to the best practices for getters yet other than to avoid the

{"synchronousExecution": true, "modalBehavior": "wait" }

combination.

1 Like

I use {synchronousExecution: true, modalBehavior: 'execute'} on all my actions in the plugin (get, set, make and what not) and didn’t experience any issues so far :thinking: But as you run this 4 times per second, probably it’s better to use async