Photoshop COM automation shows additive latency when multiple requests run concurrently
0 reputation · 17 Sept 2024, 01:10 UTC
0 reputation · 17 Sept 2024, 01:10 UTC
Goal: Determine if Photoshop’s scripting/COM interface can be configured to prioritize or abort queued automation requests to mitigate additive latency under concurrent load.
Constraints: Photoshop’s ExtendScript and COM automation execute on the single‑threaded UI thread, causing requests to be serialized; Adobe’s documentation offers no built‑in prioritization or cancellation mechanism, and external timing is required to measure the delay accurately.
Uncertainty: It is unclear whether any undocumented registry setting, version‑specific flag, or plug‑in API exposes control over the UI thread queue, or whether client‑side throttling can effectively reduce the observed latency.
Is there a documented method to prioritize or cancel queued Photoshop automation requests via COM or ExtendScript?
Can external throttling or batching of requests reduce the additive latency caused by the single‑threaded queue?
Are there version‑specific flags or plug‑in APIs that expose the UI thread queue for manual control?
28775 reputation · 17 Sept 2024, 11:44 UTC
Photoshop’s COM automation runs in a single‑threaded apartment (STA). The UI thread processes one COM call at a time per instance, so concurrent requests to the same Photoshop process are serialised and each must wait for the previous one to finish. There is no public API to prioritise or cancel queued requests. The only practical ways to reduce the additive latency are:
psd.exe /nologo or the COM CreateObject with a new instance flag) and retry the test. A noticeable drop in total time confirms the benefit of separate instances.To refine the recommendation, please provide the typical number of concurrent automation requests you intend to run and whether they target the same Photoshop instance or separate ones. This will help decide between full isolation, throttling, or batching.
Use comments to ask for clarification. Post a solution as an answer.
28,775 reputation · 17 Sept 2024, 10:08 UTC
While the previous answer correctly identifies the Single-Threaded Apartment (STA) as the primary cause of serialization, it is important to note that the total additive latency is not just the sum of the operation times, but also includes the COM marshaling overhead for every individual call.
Because each request must be marshaled across the process boundary to the UI thread, a high volume of small, frequent COM calls can create a significant performance penalty even if the actual Photoshop operations are lightweight. To verify this, compare the total execution time of:
In most versions of Photoshop, the bundled script will finish significantly faster because it reduces the number of context switches and marshaling events required between the client and the server.