Hello everyone.
I have a script which renames multiple files on disk. It's fairly simple, just clicking 'OK' until the rename window goes away (with a few extra steps).
The issue I have, is that on our particular macOS version/SMB storage server Pro Tools takes a really long time to rename files on disk, especially with long multi-channel files. This causes Pro Tools to hang (spinning wheel) for up to a minute between rename operations.
Irritatingly, when Pro Tools stops responding none of my waitFor methods work properly.
For example to take just some of the code:
const renameWindow = sf.ui.proTools.window.whoseTitle.is("Name").first;
const textField = renameWindow.groups.whoseTitle.is("Name".first.textFields.first;
const okButton = renameWindow.buttons.whoseTitle.is("OK").first;
const currentFile = textField.value.invalidate().value;
okButton.elementClick();
sf.waitFor({
callback: () => (!textField.exists) || (textField.invalidate().value.value !== currentFile),
timeout: 30000,
onError: "ThrowError",
})
This works perfectly as long as Pro Tools doesn't go unresponsive, but breaks completely if it does.
Is there an 'official' way to wait until Pro Tools starts responding again?
Thanks.
Fergus
Chris Shaw @Chris_Shaw2025-02-25 16:54:58.591ZI would try setting the timeout to -1 which will cause
waitForto wait indefinitely.sf.waitFor({ callback: () => (!textField.exists) || (textField.invalidate().value.value !== currentFile), timeout: -1, onError: "ThrowError", })But I'm sure @Kitch might have a better solution.
Pinewood Studios @Pinewood_StudiosHey Chris,
I think the issue here is that the callback actually exits early, rather than erroring out. Possibly the non-responsive Pro Tools makes the textField.exists come back false?
So this bit wouldn't be solved by an infinite timeout.
Thanks!
Fergus
Kitch Membery @Kitch2025-02-25 18:03:44.023ZHi @Pinewood_Studios (AKA Fergus)
The first step to troubleshooting this would be to find a foolproof way to make Pro Tools unresponsive.
This may have been covered in the forum quite some time ago, but I might be wrong.
Let me know if you can find a way, and we can investigate if there is a robust way to wait before proceeding. :-)
Pinewood Studios @Pinewood_StudiosHi Kitch,
I have a foolproof way to recreate this on our server, but it won't be recreateable on your end. I have combed the forum but struggling to find anything...
I can keep trying to look for ways, or we could jump on a call at some point and I can demo?
Fergus
Kitch Membery @Kitch2025-02-26 18:01:07.012ZHi @Pinewood_Studios (AKA Fergus)
I'll take a look and see if I can find info on this, failing that we can jump on a call sometime next week to see if we can work out a way. :-)
Pinewood Studios @Pinewood_StudiosHey Kitch.
You can force Pro Tools to stop responding by finding it's process ID (ps aux | grep "Pro Tools") and then running kill -STOP [process ID].
Following finding this, I think I've worked out a great way to do what I'm looking for. Posting it below.
sf.waitFor({ callback: () => { try{ sf.ui.proTools.appActivateMainWindow(); return true; } catch(err) { return false; } }, timeout: 30000, onError: "ThrowError" });If you try to activate the main window when Pro Tools is not responding it throws an error. By catching this error we can wait for Pro Tools to start responding again.
Would love to know your thoughts on this?
Fergus
Kitch Membery @Kitch2025-02-27 19:22:52.336ZHi @Pinewood_Studios (Fergus)
Great sleuthing!
Using
sf.ui.proTools.appActivateMainWindow();, in this instance, would not be my preferred method here as it performs more than one task under the hood.-
To get the process ID, I instead used
pgrep -x "Pro Tools". This will return the process number only. -
To pause the process ID, I used
kill -STOP [process ID] -
To resume the process ID, I used
kill -CONT [process ID] -
For the
waitFormethod, I usedhasLiveValidUIproperty.
When pausing and resuming the process ID in the terminal, the following code seems to work for me.
sf.waitFor({ callback: () => sf.ui.proTools.children.first.invalidate().hasLiveValidUI, pollingInterval: 500, timeout: -1, // Add a timeout here or "-1" for infinite wait. });Let me know if it works for you. :-)
Pinewood Studios @Pinewood_StudiosDefinitely a neater way of doing it - I like the polling interval change too, I didn't realise that was a thing.
Cheers!
-