John_R_Ellis's profile
Champion

Champion

 • 

6K Messages

 • 

103.7K Points

Mon, Dec 19, 2016 5:28 AM

Closed

In progress

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

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.

Official Solution

Employee

 • 

295 Messages

 • 

7.8K Points

5 y ago

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

9 Messages

 • 

358 Points

5 y ago

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

Champion

 • 

6K Messages

 • 

103.7K Points

5 y ago

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.  

Champion

 • 

6K Messages

 • 

103.7K Points

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.

Champion

 • 

6K Messages

 • 

103.7K Points

5 y ago

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().