I’ve just finished my first UXP plugin, and everything is running perfectly from the Developer Tool. I follow the basic steps to package, unload the dev version, install the .ccx, and the panel loads, but is entirely unfunctional. I notice that it doesn’t appear in the plugin manager either.
How can I debug this?
Are you using
eventNotifier by any chance? If so, it’s not available in a non-dev environment. If the error there isn’t caught, that could result in a non-functional panel.
Nope! I have a couple of vanilla JS event listeners for the UI, but no eventNotifier.
It’s a pretty straightforward panel: gets some user input from the UI, walks the DOM, does a couple of batchPlay get functions, and renames some layers.
Do you have a unique plugin ID?
I have one in the manifest.json (that I created).
I haven’t done so via the Adobe Developer Console though. The plugin only exists locally on my PC/UXP Dev Tool. Do I need to do that even if the panel is never going to be on the marketplace?
If I restart my computer it at least appears in the plugin manager. On first restart today the packaged panel worked. I tried to replicate this with no success.
If you don’t go to the marketplace it can be whatever ID you want to but should be unique locally.
That’s what I thought.
It has a unique ID locally, but it is a 2nd version rebuilt from scratch and shares the same ID as the 1st, but that’s long gone from my HDD.
I shall try changing the ID and see what happens.
I changed the id to “id.id”, repackaged it and the same. Panel loads in PS, but not plugin manager, and doesn’t function at all. After a complete restart it will appear in plugin manager.
If you DM me a .ccx, I can try it on my machine and see if anything jumps out at me.
Thank You Kerri, that’s very kind. I shall send it now!
Hi @Timothy_Bennett – I think I identified the issue – it’s more related to the panel lifecycle itself than anything else, but the way one loads things via devtools vs how one loads a plugin that’s installed is exacerbating the issue.
So, a few notes to set up the issue:
- Currently, the panel lifecycle is the same as the lifetime of Photoshop. An installed plugin is loaded when Photoshop starts, and persists until Photoshop is closed.
- Panels, once created, stay populated even after they are closed. Opening the panel again will show the previous state, unless you’ve actively changed it somehow.
- The Photoshop DOM API does not use anything like ExtendScript’s LiveObjects. That is, a reference to
app.activeDocumentwill always refer to the document that was active at the time the reference was assigned, not when the reference is used later.
The above all factors in to the real issue – that is, that the variable
doc you’re setting at the top of the plugin’s code may be very different from the document the user is ultimately trying to run the plugin on. When you’re loading the plugin through devtools, odds are good that you had already opened the document you wanted to work with. This means that
doc=app.activeDocument would point to the document you intended.
But when a plugin is installed, the main JS code runs much earlier than this. Likely
doc is going to be pointing at no document whatsoever. But you’d have a similar issue if the user had two documents open and switched between them –
doc would still refer to the first one (not the current one).
How that would manifest is in a couple of ways:
- Nothing happens visually because
docis pointing to a non-existent document (Ps is throwing an error under the hood:
index.js:115 Uncaught Error: This document does not exist.)
- The action happens, but in the wrong document – this would be because the user might have two documents open and has switched to the other one.
I took a look through your code, and noticed that
doc is only set once, at the top of the script. Instead, you want to set
doc = app.activeDocument at the top of each function where you need it. That way when the function is invoked,
doc is always pointing at the user’s current document – not what it was when Photoshop started your plugin.
I’ve pointed to the specific line in the DM, but hopefully this helps with provide some context
Kerri totally nailed it and I am ever thankful for her time and effort, what a great community this is!