Filmulator crashes after lensfun database update (MacOS Big Sur)

Okay nice! I see that the libraries are all in there, but the linker isn’t looking for them in the right palce. The furthest I got on the subject last time was that the rpath of the executable needs to be set correctly, but I didn’t figure out how to do that. Here is the error I get on my machine, which shows that it’s trying to find lensfun in /usr/local/lib, /usr/lib, or Filmulator.app/Contents/Macos. It’s also trying to find it under a slightly different name.

Termination Reason:    Namespace DYLD, Code 1 Library missing
Library not loaded: liblensfun.2.dylib
Referenced from: /private/var/folders/*/Filmulator.app/Contents/MacOS/filmulator
Reason: tried: 'liblensfun.2.dylib' (no such file), '/usr/local/lib/liblensfun.2.dylib' (no such file), '/usr/lib/liblensfun.2.dylib' (no such file), '/private/var/folders/rn/zh3k3k353vbbn9qwnhl2vhc00000gn/T/AppTranslocation/229D447E-534E-4AF1-A6EB-F8E260589076/d/Filmulator.app/Contents/MacOS/liblensfun.2.dylib' (no such file), '/usr/local/lib/liblensfun.2.dylib' (no such file), '/usr/lib/liblensfun.2.dylib' (no such file)

Yeah that’s a very interesting problem. It always should look for a Version 2 database, and the database format hasn’t changed since version 2 was made available.

I‘m not sure, if it really was a database compatibility issue or if the lensfun installation from Macports was simply broken or in another way different from what I built. The newly built lensfun is around 1,5 MB dylib, the pre-installed on was 285 kB and did not work …

I moved two major stack consumers in kMeansNLMApprox() to global static memory

std::array<float, expandedBlockSize * expandedBlockSize * numChannels> IBlockCopy;
std::array<float, expandedBlockSize * expandedBlockSize * numChannels * patchSize> expandedDimensions;

Not the best programming practice, I know, but the crashes are gone. Wondering if I should expect any unwanted side effects? kMeansNLMApprox() is not supposed to be called from multiple threads, right?

It wouldn’t be called by multiple threads right now, but there’s a chance it could in the future.

Interesting find, though.