Force UXP window to refresh?

Is there a way to force the UXP window view to refresh?

I am using innerHTML to updating the processing progress status. In some cases the UI is delayed to update the changes while the batchPlay functions are running. In some cases, adding in a sleep function for 250ms before processing the next batchPlay will allow it to refresh. In other cases, that doesn’t work. In the cases where this doesn’t work, even increasing the sleep time doesn’t help.

Just wondering if there is a command to force the UXP window to refresh after making the innerHTML changes.

When you’re using batchPlay, it’s going to be up to PS on when things get updated. Outside of batchPlay, you should see UI updates within the next video frame (so, within 16ms), but if PS is busy, it may take longer, since the UI runs on the main thread, and PS may not have had a chance to do anything beyond whatever image processing it’s working on.

It might help to see some code (how are you sleeping, for example), to see if there’s anything that could be interfering.

I’m updating with innerHTML between batchPlay commands. Here is how I’m using the sleep function to try to give it time to refresh.

Looking at it, the one place it consistently works, I also have a bunch of other calculations and variables being assigned between the sleep and the next batchPlay. It needs about 100-150ms for the sleep command in my testing so I gave it 250 have some buffer. In the other places places where there is a batchPlay directly after the sleep, it doesn’t refresh the innerHTML on the screen until after all of the batchPlay(s) after it are finished.

await batchPlay([descriptor1, desscriptor2, ect],{}); 
document.getElementById("elementID").innerHTML="Some text here.....";
await sleep(250);
await batchPlay([descriptor1, desscriptor2, ect],{});  

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

Have you tried to use .textContent instead of .innerHTML, especially if you’re dynamically updating a string?

Thanks for the suggestion. I just tried that and it behaves the exact same as innerHTML. There is no difference in the refreshing. I guess that textContent is probably the more proper way to change the text because I’m not replacing HTML tags. However, it still doesn’t solve the problem.

Are you developing on Mac OS or Win?

Windows right now. Eventually the plugin will be used on both but right now I’m just testing on Windows first.