• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

SDK Issue with applyDevelopPreset for plugin created with plug-in

Explorer ,
Dec 12, 2023 Dec 12, 2023

Copy link to clipboard

Copied

I am building a plugin that allows me to "Save" settings from one image and then "Apply" those settings to another image. I am saving the settings from the reference image to a develop preset using LrApplication.addDevelopPresetForPlugin() (this is one lua file) and then applying the settings using photo:applyDevelopPreset() (this is a different lua file). Everything is working as it should except when I attempt to apply the settings multiple times in a row. I receive an error that says "An internal error has occurred. assertion failed!"

 

Here is a video of the error: https://vimeo.com/893943484/947d84620e?share=copy

 

Here is my script for the Save Settings lua file:

 

local LrApplication = import "LrApplication"
local LrDialogs = import 'LrDialogs'
local LrTasks = import 'LrTasks'
local catalog = LrApplication.activeCatalog ()
local photo = catalog:getTargetPhoto ()
local targetPhoto = catalog:getTargetPhoto ()

LrTasks.startAsyncTask( function()
catalog:withWriteAccessDo ("Save Settings One", function ()

local settings = targetPhoto:getDevelopSettings ()
savesettingsone = LrApplication.addDevelopPresetForPlugin(_PLUGIN, "Paste Settings", settings)
end)
end)

 

Here is my script for the Apply Settings lua file:

 

local LrApplication = import "LrApplication"
local LrDialogs = import 'LrDialogs'
local LrTasks = import 'LrTasks'
local catalog = LrApplication.activeCatalog ()
local photo = catalog:getTargetPhoto ()
local photos = catalog:getTargetPhotos()


LrTasks.startAsyncTask( function()
catalog:withWriteAccessDo ("Paste", function ()

photo:applyDevelopPreset(savesettingsone, _PLUGIN)

end)
end)

 

Any thoughts on what is happening here?

TOPICS
SDK

Views

257

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 12, 2023 Dec 12, 2023

Copy link to clipboard

Copied

You can often get an idea of where an error is coming from by starting LR from the Terminal command line with the -tracebacks option:

/Applications/Adobe\ Lightroom\ Classic/Adobe\ Lightroom\ Classic.app/Contents/MacOS/Adobe\ Lightroom\ Classic -tracebacks

 

Trigger the error, and then copy/paste the last couple hundred lines or so here.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 13, 2023 Dec 13, 2023

Copy link to clipboard

Copied

@cwurzbach 

 

I have to ask: in what way is your plug-in different compared to LrC internal Copy and Paste?

 

Seems to me you are copying settings as they are, so you are keeping all the bugs and issue connected to it.

 

What's the advantage?

Why not use LrC directly?

 

Is this the beginning of a bigger more complete plug-in?

 

 

 

.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 13, 2023 Dec 13, 2023

Copy link to clipboard

Copied

@C.Cella I have a very specific use case for this functionality that is different than the native copy and paste functionality in Lightroom Classic.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 13, 2023 Dec 13, 2023

Copy link to clipboard

Copied

@johnrellis thanks so much for this tip!

 

Here are the results:

 

2023-12-13 09:45:19.417 Adobe Lightroom Classic[98185:5924484] [string "unarchived table localPointColors"]:1: unexpected symbol near '0'

    0: global   loadstring                     - C

    1:          [unnamed]                      - 214868927:1005+14

    2:          [unnamed]                      - tail

    3:          [unnamed]                      - tail

    4: method   getLocalPointColors            - 1440245828:9827+11

    5: method   getPointColors                 - 1952468259:8123+9

    6: upvalue  ?                              - 412168478:1184+6

    7:          [unnamed]                      - 412168478:1314+5

    8: upvalue  ?                              - C

    9: upvalue  ?                              - 174292919:1121+85

   10: field    notifyObservers                - 174292919:1356+61

   11: upvalue  ?                              - 862131963:379+16

   12: upvalue  ?                              - 862131963:362+8

   13: field    set                            - 862131963:455+5

   14: upvalue  ?                              - 1334683539:1451+107

   15: method   next                           - 1334683539:2558+12

   16: upvalue  ?                              - 1438065897:158+21

   17: upvalue  ?                              - 1438065897:487+11

   18: upvalue  ?                              - 1478146055:232+7

   19:          [unnamed]                      - 1131627717:301+11

   20: global   pcall                          - C

   21:          [unnamed]                      - 1131627717:313+21

   22: method   handleResponse                 - 1131627717:526+84

   23: method   handleResponse                 - 435542093:492+14

   24:          [unnamed]                      - 435542093:436+45

   25: global   pcall                          - C

   26: method   processPendingResponses        - 435542093:543+31

   27:          [unnamed]                      - 435542093:330+6

<end>

2023-12-13 09:45:20.910 Adobe Lightroom Classic[98185:5924484] [string "unarchived table localPointColors"]:1: unexpected symbol near '0'

    0: global   loadstring                     - C

    1:          [unnamed]                      - 214868927:1005+14

    2:          [unnamed]                      - tail

    3:          [unnamed]                      - tail

    4: method   getLocalPointColors            - 1440245828:9827+11

    5: method   getPointColors                 - 1952468259:8123+9

    6: upvalue  ?                              - 412168478:1184+6

    7:          [unnamed]                      - 412168478:1314+5

    8: upvalue  ?                              - C

    9: upvalue  ?                              - 174292919:1121+85

   10: field    notifyObservers                - 174292919:1356+61

   11: upvalue  ?                              - 862131963:379+16

   12: upvalue  ?                              - 862131963:362+8

   13: field    set                            - 862131963:455+5

   14: upvalue  ?                              - 1334683539:1451+107

   15: method   next                           - 1334683539:2558+12

   16: upvalue  ?                              - 1438065897:158+21

   17: upvalue  ?                              - 1438065897:487+11

   18: upvalue  ?                              - 1478146055:232+7

   19:          [unnamed]                      - 1131627717:301+11

   20: global   pcall                          - C

   21:          [unnamed]                      - 1131627717:313+21

   22: method   handleResponse                 - 1131627717:526+84

   23: method   handleResponse                 - 435542093:492+14

   24:          [unnamed]                      - 435542093:436+45

   25: global   pcall                          - C

   26: method   processPendingResponses        - 435542093:543+31

   27:          [unnamed]                      - 435542093:330+6

<end>

2023-12-13 09:45:21.690 Adobe Lightroom Classic[98185:5924484] assertion failed!

    0: global   assert                         - C

    1: method   unwrap                         - 1095389259:59+4

    2: method   applyDevelopPreset             - 1097790262:1873+8

    3: upvalue  ?                              - Copy and Paste/Paste One.lua:15

    4:          [unnamed]                      - 1666282269:1230+52

    5:          [unnamed]                      - 179812414:2266+12

<end>

2023-12-13 09:45:21.690 Adobe Lightroom Classic[98185:5924484] assertion failed!

    0: global   pcall2call                     - C

    1:          [unnamed]                      - 1289965755:154+21

    2:          [unnamed]                      - tail

    3: upvalue  ?                              - 1666282269:1118+111

    4:          [unnamed]                      - 1666282269:1418+89

    5:          [unnamed]                      - tail

    6: upvalue  ?                              - Copy and Paste/Paste One.lua:10

    7:          [unnamed]                      - 2144215698:63+9

    8:          [unnamed]                      - 179812414:2266+12

<end>

2023-12-13 09:45:21.691 Adobe Lightroom Classic[98185:5924484] Oops! An untagged string (assertion failed!) got thrown far enough that we display it to the user. This shouldn't happen.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 13, 2023 Dec 13, 2023

Copy link to clipboard

Copied

That trace-back gives some hints: It confirms the assertion failure is occurring inside the photo:applyDevelopPreset()  method, and it suggests it has something to do with the Point Colors settings.

 

A couple of bugs have been reported with Point Colors, which was added in LR 13: The setting doesn't always copy/sync correctly, and you can't always make a preset with it.  The bugs are probably related to the fact that settings.PointColors = nil should be treated the same as settings.PointColors = {}.

 

To work around problems in my Copy Settings plugin, the plugin always explicitly changes nil to {} before trying to copy develop settings:

 

settings.PointColors = settings.PointColors or {}

 

That's the first thing I suggest you try: Do it before creating the preset.

 

The second thing is to avoid the use of photo:applyDevelopPreset() and use photo:applyDevelopSettings() instead. Plugin-specific presets aren't often used, so the likelihood of a bug in that code path is higher.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 13, 2023 Dec 13, 2023

Copy link to clipboard

Copied

@johnrellis I just tried it in version 12.4. I created the develop preset by triggering the "copy" script and then applied the preset via the "paste" lua script and I was able to get the same error. The point color issue shouldn't be present in 12.4. See the log below.

 

If I were to use photo:applyDevelopSettings() how would I be able to reference the "saved" settings from the "copy" script? This is why I am using LrApplication.addDevelopPresetForPlugin() and photo:applyDevelopPreset(). Basically, I need to be able to save the settings from an image and then apply them later to other images (it could be hours or days later). 

 

2023-12-13 11:04:29.787 Adobe Lightroom Classic[489:6022846] WFOzUserModel ERROR Failed to log in to Oz: "database is locked"

sessionReadyCallback: 3

sessionReadyCallback: 0

<6022815> <GPUFoundation> <5> Done loading modules, sec: 0.000196292, device: Metal(0)

sessionReadyCallback: 5

2023-12-13 11:05:20.531 Adobe Lightroom Classic[489:6022467] assertion failed!

    0: global   assert                         - C

    1: method   unwrap                         - 1095389259:59+4

    2: method   applyDevelopPreset             - 1097790262:1873+8

    3: upvalue  ?                              - Copy and Paste/Paste One.lua:15

    4:          [unnamed]                      - 1666282269:1222+52

    5:          [unnamed]                      - 179812414:2266+12

<end>

2023-12-13 11:05:20.531 Adobe Lightroom Classic[489:6022467] assertion failed!

    0: global   pcall2call                     - C

    1:          [unnamed]                      - 1289965755:154+21

    2:          [unnamed]                      - tail

    3: upvalue  ?                              - 1666282269:1110+111

    4:          [unnamed]                      - 1666282269:1410+89

    5:          [unnamed]                      - tail

    6: upvalue  ?                              - Copy and Paste/Paste One.lua:10

    7:          [unnamed]                      - 2144215698:63+9

    8:          [unnamed]                      - 179812414:2266+12

<end>

2023-12-13 11:05:20.531 Adobe Lightroom Classic[489:6022467] Oops! An untagged string (assertion failed!) got thrown far enough that we display it to the user. This shouldn't happen.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 13, 2023 Dec 13, 2023

Copy link to clipboard

Copied

Some possible next steps for troubleshooting:

 

1. You could first identify whether it is indeed a problem in applyDevelopPreset() by writing a test script that uses getDevelopSettings() to get the current settings of the most-selected photo and then uses applyDevelopSettings() to copy them to the other selected photos. If that avoids the problem, it points to applyDevelopPreset(). You could then avoid the issue by writing the contents of the develop settings to a file and then reading in that file later.

 

2. Use the script from step 1 to narrow down the conditions under which the problem occurs. Is it always the same photo? If so, what is different about the settings of that photo from those of the others?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 13, 2023 Dec 13, 2023

Copy link to clipboard

Copied

@johnrellis thanks for the troubleshooting tips. Is there any chance I could get some clarification on how to use photo:applyDevelopPreset()? I think I may be using it incorrectly and that is causing the issue.

 

If I have a develop preset that I've created via LrApplication.addDevelopPresetForPlugin() that is stored in the Plugin Develop Presets folder, what is the proper way to use it with photo:applyDevelopPreset()?

 

As an example, I have a develop preset in the Plugin Develop Presets folder named test.lrtemplate when I try to use photo:applyDevelopPreset(test, _PLUGIN) to apply the preset I get the assertion failed error. 

 

Here is the entirety of the script:

 

local LrApplication = import "LrApplication"
local LrDialogs = import 'LrDialogs'
local LrTasks = import 'LrTasks'
local catalog = LrApplication.activeCatalog ()
local photo = catalog:getTargetPhoto ()
 
LrTasks.startAsyncTask( function()
catalog:withWriteAccessDo ("Paste", function ()  
photo:applyDevelopPreset(test, _PLUGIN)
end)
end)
 
Please note, I get the error when I change the script that creates the develop preset from test = LrApplication.addDevelopPresetForPlugin(_PLUGIN, "test", settings ) to simply LrApplication.addDevelopPresetForPlugin(_PLUGIN, "test", settings )
 
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 13, 2023 Dec 13, 2023

Copy link to clipboard

Copied

"I need to be able to save the settings from an image and then apply them later to other images (it could be hours or days later)."

 

You can simply navigate back to that image copy settings > then paste.

LrC alredy keeps the settings in memory for long time (until quitting I believe)

 

If you aim to do it via your Plug-in so keep the settings saved for long time then I suggest to present a dialog window after you paste an mention the source image used for those settings.

 

E.g.

 

Settings pasted from (name of file).

 

You could as well simply create a Develop Preset and delete it after it's no loger useful.

 

.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 13, 2023 Dec 13, 2023

Copy link to clipboard

Copied

@C.Cella I am aware of the solutions mentioned. I am trying to do something very specific for a very specific use case.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 18, 2023 Dec 18, 2023

Copy link to clipboard

Copied

[This post contains formatting and embedded images that don't appear in email. View the post in your Web browser.]

 

Sorry for the late reply on this:

 

Looking more closely at your scripts, the first one sets a global variable "test" and the second one reads "test".  The values of global variables for a plugin persist through the entire LR session or until you reload the plugin in File > Plug-in Manager.

 

So normally, if you run the first script and then immediately run the second one, "test" should always be non-nil. I don't know what exactly is happening in your plugin or the exact sequences of steps you took, but I think it's most likely that the variable "test" got set to nil somehow.   When you invoke the applyDevelopPreset() method with nil, you get the "assertion failed!" error:

 

johnrellis_0-1702953512894.png

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

LATEST

@johnrellis thanks for the follow-up message, as always, it's much appreciated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines