P: SDK: LrTasks.pcall fails when called from an LrExportServiceProvider script or observer function

2 Votes
LEGEND ,
Dec 18, 2016 Dec 18, 2016

Copy link to clipboard

Copied

The following expression fails when called from an LrExportServiceProvider script:

LrTasks.pcall (LrFileUtils.exists, ".")

It generates the error "attempt to yield across metamethod/C-call boundary". This makes my Debugging Toolkit difficult, if not impossible, to use with an export service.  (The toolkit uses LrTasks.pcall() to catch errors, and it uses LrFileUtils.exists() to implement a more useful require().)

Tested in LR CC 2015.8 / OS X 10.11.5.

To reproduce the bug:

1. Start with a copy of  "ftp_upload.lrdevplugin" from the "Sample Plugins" folder of the Lightroom SDK 6.0.

2. Insert these lines at the top of "FTPUploadServiceProvider.lua":

local LrFileUtils = import 'LrFileUtils'local 
LrTasks = import 'LrTasks'
LrTasks.pcall (LrFileUtils.exists, ".")

3. Try to export a photo with FTP Upload. The post-processing action is never invoked.

4. Go to File > Plug-in Manager and observe that the plugin encountered an error:



5. Comment out the lines inserted in step 2 and reload the plugin in the Plug-in Manager.

6. Export a photo with FTP Upload again and observe that the post-processing action is invoked, prompting for a username and password.

Bug Acknowledged
TOPICS
macOS

Views

46

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

correct answers 1 Correct answer

Adobe Employee , Dec 19, 2016 Dec 19, 2016
Hi John, I have logged a bug for this. Could you confirm if this worked prior to 6.8? Thanks, Smit Keniya Adobe Lightroom Team

Votes

Translate

Translate
5 Comments
Adobe Employee ,
Dec 19, 2016 Dec 19, 2016

Copy link to clipboard

Copied

Hi John,

I have logged a bug for this. Could you confirm if this worked prior to 6.8?

Thanks,
Smit Keniya
Adobe Lightroom Team

Smit
Lightroom Classic Team

Votes

Translate

Translate

Report

Report
LEGEND ,
Dec 19, 2016 Dec 19, 2016

Copy link to clipboard

Copied

Smit - I've been working with John on this and I first saw it in 2015.7 but I can't say that's when it started. It's possible it's been around for a while before that too.

db

Votes

Translate

Translate

Report

Report
LEGEND ,
Dec 19, 2016 Dec 19, 2016

Copy link to clipboard

Copied

I neglected to add that this also occurs with CC 2015.5 (OS X 10.11.5), the only other Mac version I have installed.  

Votes

Translate

Translate

Report

Report
LEGEND ,
Dec 19, 2016 Dec 19, 2016

Copy link to clipboard

Copied

And I'm pretty sure I tested this with LR 3 (in 2010) and this problem didn't occur.  So it may have been introduced sometime in the last six years.

Votes

Translate

Translate

Report

Report
LEGEND ,
Dec 27, 2016 Dec 27, 2016

Copy link to clipboard

Copied

LATEST
LrTasks.pcall() also fails when called from a property table's observer function, producing the message with "attempt to yield across metamethod/C-call boundary" and sending LR into an infinite loop.

To reproduce, make a plugin with a single File menu command running this script:
local LrBinding = import 'LrBinding'
local LrFileUtils = import 'LrFileUtils'
local LrFunctionContext = import 'LrFunctionContext'
local LrTasks = import 'LrTasks'
LrFunctionContext.postAsyncTaskWithContext ("", function (context)
    local prop = LrBinding.makePropertyTable (context)
    prop:addObserver ("x", function ()
        LrTasks.pcall (LrFileUtils.exists, "/")
        end)
    prop.x = 1
    end)
When the command is executed, File > Plug-in Manager shows the following error:


The number of diagnostic messages continues to increase indefinitely.

In practice, it isn't easy to restructure the code to avoid calling LrFileUtils from within LrTasks.pcall(), since there a number of layers of abstraction between the LrTasks.pcall() and the call to LrFileUtils.  Something is obviously wrong with LrTasks.pcall().

Votes

Translate

Translate

Report

Report