In my script, I start by running this code lifted straight from the PPro Github:
> Any idea why?
I think the key will be in figuring out the 'sometimes', in 'sometimes it'll work'...
Can you provide any necessary project(s), as well as step-by-step instructions that, if followed, reliably reproduce the problem?
Ahh, therein lies the issue! It seems completely at random. It's not necessarily one project that produces the error. Somtimes I'll get the error when I'm trying to run the script on a particualr project, then close a few other projects I have open and then, boom, works again. Almost always it'll work on a fresh restart if i'm running the script on the only project I have open. But, I"ll try to do some sleuthing and report back, thanks!
Speculative: Perhaps having multiple views into one project open (e.g., one open project panel, and another panel showing the contents of a bin from within that project) helps confuse PPro?
Great idea, I'd been toying around with something of that nature. I'm still working on isolating, and it seems running it while having multiples views of one project causes the issue. BUT I've also found that after having , say a bin of one project open in addition to the project panel and then closing the bin view, app.getProjectViewIDs() still returns a viewID associated with that view (presumably, I just know that it returns too many viewIDs for the amount of views open) even though it's no longer open. Switching between workspaces seems to fix that issue and get PPro to retun the proper amount of viewIDs.
Good info! Yes, we're tracking that issue as DVAPR-4237895; work has not yet been scheduled.