Copy link to clipboard
Copied
Hi,
I'm experiencing an issue since the LR version 11.0 update where the SDK commands concerning collections are not taking effect on the application view. For example, if I'm trying to run the following code:
Copy link to clipboard
Copied
How many photos are being added to the collections? When I run that script on a 1000-photo catalog, it completes nearly instantaneously, and the created collections appear fully populated. But when I run it ona catalog with 36K photos, it takes many minutes to complete, and the collections didn't appear in the Collections panel until a couple minutes after starting the script.
collection:addPhotos() has long had an n-squared performance bug that's causing this misbehavior:
So try re-running your test, and use Activity Monitor to observe the CPU time of the Lightroom Classic process while running the script. After the CPU utilization drops to a few percent, do the collections now appear in the Collections panel fully populated?
Copy link to clipboard
Copied
Thanks for replying.
I've managed to resolve the issue (although indirectly).
I believe the issue is not related to run time but rather to the LR GUI refresh "cycle".
LR did not refresh to GUI after adding the photos.
In order to "trigger" the refresh I've splitted the creation of the collection and the insertion of the photos into 2 separate write access commands. The following code works:
Copy link to clipboard
Copied
Glad you found a workaround. Reviewing the code in some of my plugins, I see that I've done the same thing, but I had written comments saying that trying to add photos to a newly created collection inside a singlewithWriteAccessDo() would fail with an error (the collection wouldn't appear to be created until the withWriteAccessDo() exited). But not all my plugins split up creation and adding. So this, and the n-squared performance bug, is clearly something fragile in LR internals that interacts badly with refreshing the UI.