Skip to main content
johnrellis
Legend
June 8, 2026

P: SDK: Race condition with photo:applyDevelopPreset() and catalog:updateAISettings()

  • June 8, 2026
  • 2 replies
  • 19 views

If a plugin calls catalog:updateAISettings() immediately after photo:applyDevelopPreset(), the application of the preset is ignored. This bug was introduced in LR 15.3, likely with the background processing of AI commands.

 

To reproduce on LR 15.3 / Mac OS 26.4.1:

 

1. Import the attached preset “_Update Bug.xmp”.

 

2. Put the attached file “updateaisettings-bug.txt” into the LR Scripts folder.

 

3. Go to Develop with a test photo.

 

4. Do Scripts > updateaisettings-bug. Observe that Exposure is not changed (incorrect -- it should change to 4).

 

5. Apply the preset “_Update Bug”. Observe that Exposure changes to 4 (correct).

 

A workaround is to call LrTasks.sleep (0.1) before calling catalog:updateAISettings().

    2 replies

    C.Cella
    Legend
    June 8, 2026

    I can’t reply properly.
    I get a red “Something’s Gone wrong” message.


    There seems to be a character limit or something like thatt because I could NOT post in a single reply.

    johnrellis
    Legend
    June 8, 2026

    @C.Cella Might be of interest to you.

    C.Cella
    Legend
    June 8, 2026

    I’ve already encountered race conditions with all APIs that themselves provide a progress scope.

    For instance, if one tries to perform photo:applyDevelopPreset() followed by photo:setRawMetadata(), the latter might occur before even the preset was applied.

    In my experience, setting a LrTasks.sleep() is not reliable because, for my “heavily edited” photos, it can take seconds to apply a preset due to various reasons. I haven’t found a reliable “sleep” time for all situations.

    C.Cella
    Legend
    June 8, 2026

    One workaround I use to coordinate with the photo:applyDevelopPreset() is to create a Progress scope within which I summon photo:applyDevelopPreset(). When this parent scope is complete, I trigger the next action.
    In some codes, when I apply settings or presets, I directly read the catalog with SQLite to check for the appearance of history steps, which is the trigger I use to perform the extra action.

     

    I suggested to the team that we be able to observe scopes so that we could coordinate.

     

     

    P.S.

    If you still rely on photo:applyDevelopPreset() in your plug-ins (Any Menu, I guess), then now you can use catalog:applyDevelopPreset(), which presents ONE scope for all the array.

    So, there’s no longer a need to do photo:applyDevelopPreset() and catalog:updateAISettings() as we had to before.