"doScript" scripts fail in AI 2022

LEGEND ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

I have an Illustrator Action Library I've been using since AI 2015.
Since upgrading from AI 2020 to 2022 I find any script calling these actions with "doScript" fail if run from VSCode. If I run the action directly in AI 2022 they work fine.

Does anyone know how I can alter the scripts to allow them to work in AI 2022?

Edit:
I've determined it is not the scripts themselves. The failure occurs when they are run from VSCode directly. Running them via Keyboard Maestro works fine.


Version info:
Version: 1.69.1
Commit: b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a
Date: 2022-07-12T08:21:51.333Z
Electron: 18.3.5
Chromium: 100.0.4896.160
Node.js: 16.13.2
V8: 10.0.139.17-electron.0
OS: Darwin x64 21.5.0

Will see about downgrading.

 

TOPICS
Bug , Scripting

Views

306

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 20, 2022 Jul 20, 2022

@sberic@erinferinferinf@m1b@Anubhav Majumder,
By rolling back to ExtendScript Debugger v1.1.2 I am now able to debug "doScript" scripts without issue.
@sberic, I did post this issue on the "ExtendScript Debugger" comments page. Since it may ultimately be a "Ai 2022" bug I feel the ExtendScript Debugger team my have more access to the Ai Development team than I do. I will at least attempt to file a Bug report in the appropriate place (where ever that is).

 

Setup:
Mac Studio M1 Max

VSCode 1.69.2

...

Likes

Translate

Translate
Adobe Employee ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Hello @rcraighead,

 

Sorry to hear about this experience. I would request you to try the suggestions shared in this community post (https://community.adobe.com/t5/illustrator-discussions/app-doscript-probem/td-p/11200321) and check if it helps.

 

Looking forward to your response.

 

Thanks,

Anubhav

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

@Anubhav Majumder , these are scripts I've been using for years. They still run fine directly in AI or from Keyboard Maestro. They just fail (and cause Ai to hang) if run from VSCode.

FYI: I am running VSCode 1.69.1 and ExtendScript Debugger 2.0.3. I notice Debugger was updated 7/14. I wonder if that's the issue?

ExtendScript Debugger 2.0.3 - 2022-07-14

 

Edit:
Confirmed: Downgraded ES Debugger to 2.02 and "doScript" method now works from VSCode!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

You can ask @sberic, the developer. The version we just released has some new notes on Illustrator peculiarities...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

@rcraighead Do you have an example of a script that fails that we can test? Something short and sweet would be great!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

So I just ran the following script with v2.0.3:

app.doScript("Opacity 60 (selection)", "Default Actions");

and it appears to work... if there have been no errors in the ExtendScript engine (e.g. `main`) prior to running the script.

 

If there have been errors, Illustrator itself appears to go into an infinite loop (on macOS, at least) and must be Force Quit. Is this what you're referring to when you say that `doScript` doesn't work?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

I reverted back to v2.0.2 and I'm seeing the exact same functionality.

 

More testing, however, shows that sometimes the "Illustrator goes unresponsive" problem may happen without an error occurring in the target engine first? Regardless, attempting to use the script I posted above after running a script – even from the Debug Console, like `$.writeln(;` or similar – seems to get the problem to reproduce consistently.

 

There doesn't appear to be anything that the debugger extension is doing (or seeing along the underlying protocol from the host application) that could be causing this. If you do have an example script that you can share that works flawlessly in v2.0.2 and fails consistently in v2.0.3, please do so as it may help provide more insight as to what is going on!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

This simple script runs the Action "Unite" (Pathfinder:Add) from Action folder "TestAction". It works fine in 2.0.2 but causing Ai 2022 to go in infinite loop (beachball).

 

 

 

app.doScript("Unite", "TestAction");

 

Here is the script in .jsx format:
https://www.icloud.com/iclouddrive/062CSlMj1dw5YDM5zdo0L4IXA#test_doScript

 

I am not sure how to attach an aia file. Please try this link:
https://www.icloud.com/iclouddrive/09eLzO6nE0o1TRXn3Z20eWmkQ#TestAction

 

And here is a simple file for testing. Select all before running script:
https://www.icloud.com/iclouddrive/094Bu2Q6uOP4_2v3T36yrMJLA#TestFile

I did find I had to revert to ES Debugger 2.0.1 to run the script this evening. I have also adjusted settings so the extension does not auto-update. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

Hi @rcraighead, I wasn't able to reproduce your issue. Your sample file, action, and script worked as expected for me. Here's my test set up:

Mac OS 12.4.

VSCode v1.69.1 (Universal) Running in Rosetta on M1 Macbook Pro.

ExtendScript Debugger v2.0.3.

launch.json:

 

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "extendscript-debug",
            "request": "attach",
            "name": "Start debugger—AI",
            "hostAppSpecifier": "illustrator",
        }
    ]
}

 

 - Mark

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

@m1b, thanks for testing and for all the info. I switched to "Universal running in Rosetta". It works the same as the Intel version for me. I also tried using your launch.json configuration but was not able to get it work for some reason. I need to read more about the "attach" request option.

I will hit this again on Monday. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 17, 2022 Jul 17, 2022

Copy link to clipboard

Copied

quote

I need to read more about the "attach" request option.

By @rcraighead

 

The `attach` request will create a debug session that is open ended - it isn't tied to a specific run (evaluation) of your script the way a `launch` request is. As such, you can attach to a host once and then run your evaluation commands (or use the _Eval in Adobe..._ button) to run the scripts. If a breakpoint/error is encountered while the scripts are evaluating then the `attach` mode debug session will respond. The Debug Console will also be active the entire time the debug session is live.

 

The idea with an `attach` mode debug session is:

 

1. Start your `attach` mode debug session when you want to use debug features.

2. Run your script in the attached engine zero-or-more times.

3. Stop your `attach` mode debug session when you're done using debug features.

 

Make sense?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

quote

I did find I had to revert to ES Debugger 2.0.1 to run the script this evening. I have also adjusted settings so the extension does not auto-update. 


By @rcraighead

 

There is zero functional difference between v2.0.1 and v2.0.2. The two versions were uploaded to work around issues with how v2.0.0 was uploaded to the Marketplace (there is, in fact, no difference between v2.0.0, v2.0.1, and v2.0.2). See the CHANGELOG for details.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

@sberic, To correct myself, I am not able to run a "doScript" to AI 2022 from VSCode using ES Debugger 2.0.3, 2.0.2 or 2.0.1. I have not tried others yet. It successfully ran ONCE using 2.0.2 and I though I had found the problem. I was wrong.
I only noticed the issue in the last couple days so when I realized ES Debugger had just updated I started suspecting it. As stated, I am still able to debugger scripts using "doScript" to AI 2020 on my iMac. I cannot test this on the M1 since AI 2020 cannot be loaded on it.
I will continue testing on Monday. Thank you for spending your valuable time to study this issue.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

quote

This simple script runs the Action "Unite" (Pathfinder:Add) from Action folder "TestAction". It works fine in 2.0.2 but causing Ai 2022 to go in infinite loop (beachball).


By @rcraighead

 

Thank you for providing the test files! It appears that the situation is very similar to what I described seeing with the `doScript` call that uses a built-in Action:

 

 

app.doScript("Opacity 60 (selection)", "Default Actions");

 

 

In my testing, I found that I was generally able to run your script with your custom Action and it worked fine, even with the latest v2.0.3. I said generally above because it would occasionally still trigger the "Illustrator locks up" issue.

 

That "occasionally" is due to the fact that I'm not 100% certain about how this reproduces. From my testing, I can get it to reproduce 100% of the time by running a script in a specific engine (either `main` or `transient`) that causes an Error in the engine. Once that occurs, attempting to run `doScript` in the same engine appears to cause the problem to occur every single time.

 

However, I have also seen the issue appear without first running a script that causes an error. This does not mean that the root cause isn't the same - some other built-in script running in the engine you're using may result in an error first and you simply wouldn't see it. Even if you have an attached debug session, you wouldn't see the error report because that requires that the script being evaluated also have the `$.level` debugging level manually set to either `1` or `2` (this is a quirk of Illustrator's). No Adobe-written script would do that (at least not shipped) so it is highly unlikely that you would know if any Adobe-written (or other third party) scripts caused an error in the engine you're using. It is also possible that there are more things that cause this issue - we simply cannot rule out third-party scripts causing errors in the target engine as a culprit here.

 

To be clear, when you have a debug session attached, the script evaluation features of the extension do properly set `$.level = 1`. This can be overridden if you manually set the `debugLevel` property when specifying Custom Key Bindings.

 

In summation, this appears to be a bug in Illustrator 2022 (at least). I'm not sure how to officially report a bug like this, but one should definitely be filed.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

@m1b Can you run a test where you evaluate a script in Illustrator that produces an error and then try to run the `doScript()` call in a subsequent evaluation? Does the issue reproduce for you in that scenario?

 

(For the record, I have an effectively identical environment to the one you describe.)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

@sberic, yes I tried that and no I couldn't reproduce the problem. I tried with target engine unspecified and with a random target engine specified. Nothing unexpected.

- Mark

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

quote

So I just ran the following script with v2.0.3:

 

 

app.doScript("Opacity 60 (selection)", "Default Actions");

 

 

and it appears to work... if there have been no errors in the ExtendScript engine (e.g. `main`) prior to running the script.

 

If there have been errors, Illustrator itself appears to go into an infinite loop (on macOS, at least) and must be Force Quit. Is this what you're referring to when you say that `doScript` doesn't work?


By @sberic


Yes. This is very repeatable for me in AI 2022.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

@sberic@erinferinferinf@m1b@Anubhav Majumder,
By rolling back to ExtendScript Debugger v1.1.2 I am now able to debug "doScript" scripts without issue.
@sberic, I did post this issue on the "ExtendScript Debugger" comments page. Since it may ultimately be a "Ai 2022" bug I feel the ExtendScript Debugger team my have more access to the Ai Development team than I do. I will at least attempt to file a Bug report in the appropriate place (where ever that is).

 

Setup:
Mac Studio M1 Max

VSCode 1.69.2 (Universal running in Rosetta)

Illustrator CC 2022

 

Thanks,

Ray

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

quote

By rolling back to ExtendScript Debugger v1.1.2 I am now able to debug "doScript" scripts without issue.


By @rcraighead

 

This is mistifying to me.

 

The old version communicates to host applications using the same protocol as the new version - the new version just does so in a massively more efficient manner. The only other difference is how the debugger identifies itself (the name it uses in the protocol) which I guess could be a factor... but I can't dream up a reason that anyone would do that.

 

Hopefully someone on the ExtendScript Debugger team who is also internal to Adobe will be able to bring this to the attention of an Illustrator dev and get them to test in a debug build of Illustrator to identify precisely what is going on. It should be pretty straightforward to identify the issue. If you sample the "Not Responding" process in Activity Monitor on macOS it's pretty clear that there's an infinite loop happening (besides the fact that it's doing nothing at 100% CPU usage). I recognize the "ScScript::DebugAPI::executeXML(ScCore::XML const&, ScCore::Error&) (in AdobeExtendScript)" line in the callstack as the line that handles the debug protocol's evaluate request. So the request to `doScript` is clearly triggering something nefarious. Beyond that, the callstack loses much helpful information other than that it calls into ScriptingSupport->Adobe Illustrator and then bounces around a bunch invoking code in libraries like AdobeBIB and AdobeAGM. I have zero insight into any of that but I assume that someone on the Illustrator team would be able to very quickly identify the source of the issue.

 

Hopefully someone will be able to take a look at this soon and can even provide some insight as to what either we-on-the-debugger-team can do or what you as the script author can do to sidestep the hang. 🤞

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

LATEST

Thanks for the followup. I posted an Illustrator "JavaScripting" bug report (the closest category in the list).

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Hi @rcraighead, what happens when you run the script from Illustrator?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

It runs fine directly from Illustrator. Thanks @m1b 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

I'd be happy to test from my VSCode if you post a sample action and script.

- Mark

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines