# Bug of the UXP progress bar? Why is the progress bar window never displayed?

**URL:** <https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829>\
**Category:** UXP Plugin API\
**Created:** [February 10, 2023, 8:38am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829 "2023-02-10T08:38:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaibei](https://avatars.discourse-cdn.com/v4/letter/k/f1d935/32.png) [@kaibei](https://forums.creativeclouddeveloper.com/u/kaibei)\
**Post date:** [February 10, 2023, 8:38am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/1 "2023-02-10T08:38:37Z")

</div>

```auto
require("photoshop").core.executeAsModal(async(executionContext) => {
    let suspensionID = await executionContext.hostControl.suspendHistory({
        "documentID": app.activeDocument.id,
        "name": 'Test Progress'
    });
    await require("photoshop").action.batchPlay([{
        "_obj": "copyToLayer"
    }, {
        _obj: "surfaceBlur",
        radius: {
            _unit: "pixelsUnit",
            _value: 100
        },
        threshold: 15
    }], {});
    await app.activeDocument.layers.forEach((layer) => {
        layer.visible = false;
    });
    await executionContext.hostControl.resumeHistory(suspensionID);
}, {
    commandName: "Test Progress Bar"
});

```

When running this era, the running time is obviously more than 2 seconds, but why doesn’t the progress bar window appear halfway?  
Not only the “surfaceBlur” function, but also other C++ plug-ins will not appear when the progress bar window, is this a Bug of UXP? @kerrishotts

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [February 10, 2023, 9:32pm UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/2 "2023-02-10T21:32:57Z")

</div>

Not sure if this is related but on my machine surface blur uses all CPU cores at once. So there might not be resources left to show a dialog. Can you try filters that can use only a single CPU core?

---

<div class="post-metadata">

**Author:** ![dotproduct](https://avatars.discourse-cdn.com/v4/letter/d/258eb7/32.png) [@dotproduct](https://forums.creativeclouddeveloper.com/u/dotproduct)\
**Post date:** [February 11, 2023, 12:53am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/3 "2023-02-11T00:53:15Z")

</div>

I wonder if the problem isn’t so much resources but the filter thread(s) not yielding to the gui thread 🤔 If it’s a deal breaker maybe a temporary work around might be to show your own message dialog, call batchPlay and close the dialog once done?

---

<div class="post-metadata">

**Author:** ![kaibei](https://avatars.discourse-cdn.com/v4/letter/k/f1d935/32.png) [@kaibei](https://forums.creativeclouddeveloper.com/u/kaibei)\
**Post date:** [February 11, 2023, 3:13am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/4 "2023-02-11T03:13:47Z")

</div>

It’s safe to say that things are definitely not that simple. Maybe the pixels of the photos you test are too small. With photos with more than 20 million pixels, the average computer processing time will be more than 2 seconds, but you still can’t see the progress bar window.  
However, I changed the code to the following so that I could see the progress bar window:

```auto
require("photoshop").core.executeAsModal(async(executionContext) => {
    // let suspensionID = await executionContext.hostControl.suspendHistory({
    // "documentID": app.activeDocument.id,
    // "name": 'Test Progress'
    // });
    // await require("photoshop").action.batchPlay([{
    require("photoshop").action.batchPlay([{
        "_obj": "copyToLayer"
    }, {
        _obj: "surfaceBlur",
        radius: {
            _unit: "pixelsUnit",
            _value: 100
        },
        threshold: 15
    }], {});
    // await app.activeDocument.layers.forEach((layer) => {
    // layer.visible = false;
    // });
    // await executionContext.hostControl.resumeHistory(suspensionID);
}, {
    commandName: "Test Progress Bar"
});

```

In this code, the history merge operation and the await before the batchPlay are canceled, and the steps performed after the batchPlay are cancelled. if you don’t, you won’t see the progress bar window no matter how long you run. Why?

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [February 11, 2023, 11:35am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/5 "2023-02-11T11:35:01Z")

</div>

What happens if you `await executeAsModal()`? 🤔 Just guessing here

---

<div class="post-metadata">

**Author:** ![kaibei](https://avatars.discourse-cdn.com/v4/letter/k/f1d935/32.png) [@kaibei](https://forums.creativeclouddeveloper.com/u/kaibei)\
**Post date:** [February 14, 2023, 6:46am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/6 "2023-02-14T06:46:55Z")

</div>

> [@kaibei](#):
>
> @kerrishotts

This question is not important enough?

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [February 14, 2023, 7:12am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/7 "2023-02-14T07:12:29Z")

</div>

@kaibei that’s a bit rude

---

<div class="post-metadata">

**Author:** ![kaibei](https://avatars.discourse-cdn.com/v4/letter/k/f1d935/32.png) [@kaibei](https://forums.creativeclouddeveloper.com/u/kaibei)\
**Post date:** [February 14, 2023, 7:18am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/8 "2023-02-14T07:18:07Z")

</div>

You’re right. We should continue to wait patiently and be more patient.

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [February 14, 2023, 7:29am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/9 "2023-02-14T07:29:34Z")

</div>

Or let someone know if their suggestion made any difference or not

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [February 14, 2023, 7:31am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/10 "2023-02-14T07:31:11Z")

</div>

Is the help of three people not good enough for you? Three people who have given their time freely to do so I might add.

---

<div class="post-metadata">

**Author:** ![kaibei](https://avatars.discourse-cdn.com/v4/letter/k/f1d935/32.png) [@kaibei](https://forums.creativeclouddeveloper.com/u/kaibei)\
**Post date:** [February 14, 2023, 7:57am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/11 "2023-02-14T07:57:38Z")

</div>

Are we here to chat? There is no progress bar during a long run, which can cause the user to crash.  
1: I think this is the place to solve the problem. Does the problem exist?  
2: if the problem exists, is there a way to solve it? Don’t chat.

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [February 14, 2023, 8:03am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/12 "2023-02-14T08:03:20Z")

</div>

Sure, but don’t be a dick about it

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [February 14, 2023, 8:17am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/13 "2023-02-14T08:17:51Z")

</div>

LOL. I just tested your code and I get a progress bar.

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [February 14, 2023, 8:26am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/14 "2023-02-14T08:26:47Z")

</div>

I got a progress bar with a 24 core i9. That said, CPU didn’t dip below 90% for whole process.

---

<div class="post-metadata">

**Author:** ![kaibei](https://avatars.discourse-cdn.com/v4/letter/k/f1d935/32.png) [@kaibei](https://forums.creativeclouddeveloper.com/u/kaibei)\
**Post date:** [February 14, 2023, 2:12pm UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/15 "2023-02-14T14:12:08Z")

</div>

I can see the progress bar with the code sent for the second time, and I can never see the progress bar with the code sent for the first time. Did you test it with the code sent for the first time? Thank you.

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [February 14, 2023, 5:42pm UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/16 "2023-02-14T17:42:20Z")

</div>

I’ve been experimenting and I’m starting to lean towards a bug.  
In a nutshell, if I re-run the surface blur a second time within the same executeAsModal the progress bar appears for the second run and with the custom `commandName`, but it doesn’t move. Otherwise no progress bar is displayed (apart from a millisecond flash of it at the end).  
The batchplay descriptors execute and the history suspension works fine.  
If I hit escape during the first surface blur, the second one starts and the progress bar appears (but still doesn’t move).  
This is my test code and the console output - note the time logging. If the surface blur only runs once the total time is correct and matches “Run A”, if run twice it seems to ignore “Run B”.

```auto
async function test() {
  try {
    // Helper functions
    const getTime = (start, end) => {
      const diff = end - start;
      const seconds = Math.floor((diff / 1000) % 60);
      return seconds === 0 ? "<1" : seconds;
    };

    const surfaceBlur = async () => {
      await batchPlay(
        [
          {
            _obj: "copyToLayer",
          },
          {
            _obj: "surfaceBlur",
            radius: {
              _unit: "pixelsUnit",
              _value: 100,
            },
            threshold: 15,
          },
        ],
        {}
      );
    };

    const invertLayerVisibilty = async () => {
      app.activeDocument.layers.forEach((h) => (h.visible = !h.visible));
    };

    // Main function
    const modalStart = new Date();

    await core.executeAsModal(
      async (executionContext) => {
        let hostControl = executionContext.hostControl;
        let documentID = app.activeDocument.id;
        let suspensionID = await hostControl.suspendHistory({
          documentID: documentID,
          name: "Custom Command",
        });

        const startA = new Date();
        // No progress bar for following 3 function calls
        await surfaceBlur();
        await invertLayerVisibilty();
        // Flip layers back to visible so next surface blur has pixel data to use
        await invertLayerVisibilty();

        const endA = new Date();
        console.log(`Run A took ${getTime(startA, endA)} seconds`);

        const startB = new Date();

        // this will display progress bar with custom command name but progress bar does not move

        await surfaceBlur();
        const endB = new Date();
        console.log(`Run B took ${getTime(startB, endB)} seconds`);

        await hostControl.resumeHistory(suspensionID);
      },
      { commandName: "executeAsModal" }
    );

    const modalEnd = new Date();

    console.log(`Process took ${getTime(modalStart, modalEnd)} seconds`);
  } catch (error) {
    console.error(error);
  }
}

```

 ![Screenshot 2023-02-14 172424](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/2/2a47f1efc3662407d7c0cbb3dbcea89d5385ea6c.png)

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [February 14, 2023, 11:48pm UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/17 "2023-02-14T23:48:42Z")

</div>

Also keep in mind that you can update progress bar explicitly and control percentage and message by yourself. [https://developer.adobe.com/photoshop/uxp/2022/ps\_reference/media/executeasmodal/#progress-bar](https://developer.adobe.com/photoshop/uxp/2022/ps_reference/media/executeasmodal/#progress-bar)

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [February 15, 2023, 12:30am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/18 "2023-02-15T00:30:28Z")

</div>

I tried adding arbitrary progress updates within the main function with no success.  
I also tried nesting each function call wrapped within a secondary `executeAsModal` and nada - no progress bar.

Based on the logged 45 second process time of running a single surface blur batchPlay command there should be a progress bar no?  
I’m also confused why a second call to the same function renders a broken progress bar when the first didn’t.

I’m going to test it tomorrow with a known working example that takes \>2 seconds but is bunch of resize/save functions rather than a single CPU intensive descriptor.

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [February 15, 2023, 12:32am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/19 "2023-02-15T00:32:43Z")

</div>

It’s less a case of “why isn’t the progress UI updating?” and more _“I’m not getting a progress bar at all!”_

---

<div class="post-metadata">

**Author:** ![kaibei](https://avatars.discourse-cdn.com/v4/letter/k/f1d935/32.png) [@kaibei](https://forums.creativeclouddeveloper.com/u/kaibei)\
**Post date:** [February 15, 2023, 8:14am UTC](https://forums.creativeclouddeveloper.com/t/bug-of-the-uxp-progress-bar-why-is-the-progress-bar-window-never-displayed/5829/20 "2023-02-15T08:14:56Z")

</div>

Yes, there is no progress bar is displayed (apart from a millisecond flash of it at the end).

I’m not getting a progress bar at all! Why?
