RawTherapee-dev Apple M1 đ›œ-test

Thanks. A noob question: which binary shold be signed? the .dmg bundle, or the .app?

@HIRAM one question about the code signing. I’ve successfully generated a personal certificate for code signing. I saw on Rawpedia that there is a -DCODESIGNID option for cmake, but what should I put in this field? I don’t have an Aple dev ID. Should I juste put the name of the certificate ?

Edit:

Adding the name of personal certificate to -DCODESIGNID doesn’t add the certificate to the app.
I tried to sign the app with sudo codesign -fs "Personal Code Signing Certificate" RawTherapee.app, and when I verify the signature with codesign -dv --verbose=4, it looks like the app is signed:

Executable=/Users/sguyader/PhotoApps/rtrepo/build/RawTherapee.app/Contents/MacOS/rawtherapee
Identifier=com.rawtherapee.RawTherapee
Format=app bundle with Mach-O thin (arm64)
CodeDirectory v=20400 size=109460 flags=0x0(none) hashes=3414+3 location=embedded
VersionPlatform=1
VersionMin=722176
VersionSDK=721664
Hash type=sha256 size=32
CandidateCDHash sha256=ff87dc320c80c310fe548a60f997d37830b13dd6
CandidateCDHashFull sha256=ff87dc320c80c310fe548a60f997d37830b13dd62540e37529ea69f9d85e9bd3
Hash choices=sha256
CMSDigest=ff87dc320c80c310fe548a60f997d37830b13dd62540e37529ea69f9d85e9bd3
CMSDigestType=2
Executable Segment base=0
Executable Segment limit=10452992
Executable Segment flags=0x1
Page size=4096
CDHash=ff87dc320c80c310fe548a60f997d37830b13dd6
Signature size=1932
Authority=Personal Code Signing Certificate
Signed Time=28 Aug 2021 at 11:14:22
Info.plist entries=20
TeamIdentifier=not set
Sealed Resources version=2 rules=13 files=3330
Internal requirements count=1 size=104

But running the app still crashes with:

Crashed Thread:        0

Exception Type:        EXC_BAD_ACCESS (Code Signature Invalid)
Exception Codes:       0x0000000000000032, 0x0000000102e30000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace CODESIGNING, Code 0x2

kernel messages:

VM Regions Near 0x102e30000:
    __LINKEDIT                  102bbc000-102e30000    [ 2512K] r--/r-- SM=COW  /Users/*/RawTherapee.app/Contents/MacOS/rawtherapee
--> mapped file                 102e30000-102e34000    [   16K] r--/r-x SM=PRV  Object_id=dfdbf52d
    __TEXT                      102ec0000-102f40000    [  512K] r-x/r-x SM=COW  /usr/lib/dyld

Application Specific Information:
dyld: launch, loading dependent libraries
/Applications/RawTherapee.app/Contents/Frameworks/libgtkmacintegration-gtk3.4.dylib

Thread 0 Crashed:
0   dyld                          	0x0000000102f1e1e0 memcmp + 16
1   dyld                          	0x0000000102ede7fc ImageLoaderMachO::validateFirstPages(linkedit_data_command const*, int, unsigned char const*, unsigned long, long long, ImageLoader::LinkContext const&) + 136
2   dyld                          	0x0000000102ee578c ImageLoaderMachOCompressed::instantiateFromFile(char const*, int, unsigned char const*, unsigned long, unsigned long long, unsigned long long, stat const&, unsigned int, unsigned int, linkedit_data_command const*, encryption_info_command const*, ImageLoader::LinkContext const&) + 268
3   dyld                          	0x0000000102edd3ec ImageLoaderMachO::instantiateFromFile(char const*, int, unsigned char const*, unsigned long, unsigned long long, unsigned long long, stat const&, ImageLoader::LinkContext const&) + 172
4   dyld                          	0x0000000102ec4588 dyld::loadPhase6(int, stat const&, char const*, dyld::LoadContext const&) + 668
5   dyld                          	0x0000000102ecdbd0 dyld::loadPhase5(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 1368
6   dyld                          	0x0000000102ecd5f4 dyld::loadPhase4(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 208
7   dyld                          	0x0000000102ecd300 dyld::loadPhase3(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 1100
8   dyld                          	0x0000000102eccac4 dyld::loadPhase1(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 252
9   dyld                          	0x0000000102ec4104 dyld::loadPhase0(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 468
10  dyld                          	0x0000000102ec3ca8 dyld::load(char const*, dyld::LoadContext const&, unsigned int&) + 196
11  dyld                          	0x0000000102ece574 dyld::libraryLocator(char const*, bool, char const*, ImageLoader::RPathChain const*, unsigned int&) + 56
12  dyld                          	0x0000000102ed8970 ImageLoader::recursiveLoadLibraries(ImageLoader::LinkContext const&, bool, ImageLoader::RPathChain const&, char const*) + 344
13  dyld                          	0x0000000102ed7128 ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, bool, ImageLoader::RPathChain const&, char const*) + 160
14  dyld                          	0x0000000102ec6a08 dyld::link(ImageLoader*, bool, bool, ImageLoader::RPathChain const&, unsigned int) + 328
15  dyld                          	0x0000000102ec9208 dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 7964
16  dyld                          	0x0000000102ec1258 dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) + 476
17  dyld                          	0x0000000102ec1038 _dyld_start + 56

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000102e30000   x1: 0x000000016dd455d0   x2: 0x0000000000001288   x3: 0x0000000000040001
    x4: 0x0000000000000003   x5: 0x0000000000000000   x6: 0x0000000102f48280   x7: 0x0000000000000000
    x8: 0x0000000000000000   x9: 0x000000016dd45fb0  x10: 0x0000000000000001  x11: 0x0001803000000000
   x12: 0x0000000000000032  x13: 0x0004000000000000  x14: 0x000000000001ce48  x15: 0x000000016dd45f30
   x16: 0x00000000000000c5  x17: 0x000000016dd45f48  x18: 0x0000000000000000  x19: 0x0000000102f4d930
   x20: 0x0000000000001298  x21: 0x000000016dd455d0  x22: 0x0000000102e30000  x23: 0x0000000000000003
   x24: 0x000000016dd46818  x25: 0x000000016dd4d6e8  x26: 0x00000001020b0800  x27: 0x000000016dd455d0
   x28: 0x0000000000000016   fp: 0x000000016dd44fd0   lr: 0x0000000102ede7fc
    sp: 0x000000016dd44f90   pc: 0x0000000102f1e1e0 cpsr: 0x20000000
   far: 0x0000000102e30000  esr: 0x92000007


Binary Images:
       0x1020b0000 -        0x102aa7fff +com.rawtherapee.RawTherapee (5.8.2954 - 5.8.2954) <4C70CA9D-C987-3915-A8A2-A241682BD000> /Users/USER/*/RawTherapee.app/Contents/MacOS/rawtherapee
       0x102ec0000 -        0x102f3ffff  dyld (852.2) <17D14D9B-B6B2-35DC-B157-4FD60213BE99> /usr/lib/dyld
       0x1974a2000 -        0x19782efff  com.apple.Foundation (6.9 - 1777.103) <B64AAE92-8C63-3FF9-8C0C-F9C10FCE7782> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
       0x1a0cd8000 -        0x1a0cf1fff  libexpat.1.dylib (26) <D6660721-945B-3EB1-81A9-9A1C806D78F1> /usr/lib/libexpat.1.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=506.7M resident=0K(0%) swapped_out_or_unallocated=506.7M(100%)
Writable regions: Total=8416K written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=8416K(100%)
 
                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
STACK GUARD                       56.0M        1 
Stack                             8176K        1 
VM_ALLOCATE                        1.0G        1 
__AUTH                              45K        1 
__AUTH_CONST                       243K        2 
__DATA                             372K        5 
__DATA_CONST                      1235K        4 
__DATA_DIRTY                        29K        1 
__LINKEDIT                       492.6M        4 
__OBJC_CONST                       112K        1 
__TEXT                            14.1M        4 
mapped file                         16K        1 
===========                     =======  ======= 
TOTAL                              1.6G       26 

Model: Macmini9,1, BootROM 6723.140.2, proc 8:4:4 processors, 8 GB, SMC 
Graphics: kHW_AppleM1Item, Apple M1, spdisplays_builtin
Memory Module: LPDDR4
AirPort: spairport_wireless_card_type_airport_extreme, wl0: Jul  7 2021 00:48:27 version 18.50.40.10.7.8.121 FWID 01-f5ad2691
Bluetooth: Version 8.0.5d7, 3 services, 27 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en1
USB Device: USB 3.1 Bus
USB Device: BillBoard Device
USB Device: USB 3.1 Bus
USB Device: USB 3.0 Bus
USB Device: USB3.1 Hub
USB Device: UMC204HD 192k
USB Device: USB2.1 Hub
USB Device: CHERRY Wired Keyboard
Thunderbolt Bus: Mac mini, Apple Inc.
Thunderbolt Bus: Mac mini, Apple Inc.

@sguyader You probably need to codesign the app with --deep to recurse bundle dirs.

Here is the codesign command in macosx_bundle.sh:

The following spctl command outputs the signature’s gatekeeper registration.

For the self-signed app, the dmg is not really neccessary.

I used (adapted) the codesign command:
sudo codesign --force --deep --timestamp --strict -v -s "Personal Code Signing Certificate" -i com.rawtherapee.RawTherapee -o runtime --entitlements rt.entitlements RawTherapee.app

But the OS doesn’t seem to like my certificate:

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    DYLD, [0x5] Code Signature

Application Specific Information:
dyld: launch, loading dependent libraries

Dyld Error Message:
  Library not loaded: /Applications/RawTherapee.app/Contents/Frameworks/libgtkmacintegration-gtk3.4.dylib
  Referenced from: /Users/USER/*/RawTherapee.app/Contents/MacOS/rawtherapee
  Reason: no suitable image found.  Did find:
	/Applications/RawTherapee.app/Contents/Frameworks/libgtkmacintegration-gtk3.4.dylib: code signature in (/Applications/RawTherapee.app/Contents/Frameworks/libgtkmacintegration-gtk3.4.dylib) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)
	/Applications/RawTherapee.app/Contents/Frameworks/libgtkmacintegration-gtk3.4.dylib: code signature in (/Applications/RawTherapee.app/Contents/Frameworks/libgtkmacintegration-gtk3.4.dylib) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)

Referenced from: /Users/USER/*/RawTherapee.app/Contents/MacOS/rawtherapee

Run the app from /Applications - it is finding applicable libraries in the copy in /Applications but maybe not matching the signature in the copy you launched elsewhere.

From the Applications folder:

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    DYLD, [0x5] Code Signature

Application Specific Information:
dyld: launch, loading dependent libraries

Dyld Error Message:
  Library not loaded: /Applications/RawTherapee.app/Contents/Frameworks/libgtkmacintegration-gtk3.4.dylib
  Referenced from: /Applications/RawTherapee.app/Contents/MacOS/rawtherapee
  Reason: no suitable image found.  Did find:
	/Applications/RawTherapee.app/Contents/Frameworks/libgtkmacintegration-gtk3.4.dylib: code signature in (/Applications/RawTherapee.app/Contents/Frameworks/libgtkmacintegration-gtk3.4.dylib) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)
	/Applications/RawTherapee.app/Contents/Frameworks/libgtkmacintegration-gtk3.4.dylib: code signature in (/Applications/RawTherapee.app/Contents/Frameworks/libgtkmacintegration-gtk3.4.dylib) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)

Binary Images:
       0x102090000 -        0x102a87fff +com.rawtherapee.RawTherapee (5.8.2954 - 5.8.2954) <A98017FD-C7C6-39E6-8001-A2A49F4A7383> /Applications/RawTherapee.app/Contents/MacOS/rawtherapee
       0x102f34000 -        0x102fb3fff  dyld (852.2) <17D14D9B-B6B2-35DC-B157-4FD60213BE99> /usr/lib/dyld
       0x1974a2000 -        0x19782efff  com.apple.Foundation (6.9 - 1777.103) <B64AAE92-8C63-3FF9-8C0C-F9C10FCE7782> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
       0x1a0cd8000 -        0x1a0cf1fff  libexpat.1.dylib (26) <D6660721-945B-3EB1-81A9-9A1C806D78F1> /usr/lib/libexpat.1.dylib

Model: Macmini9,1, BootROM 6723.140.2, proc 8:4:4 processors, 8 GB, SMC 
Graphics: kHW_AppleM1Item, Apple M1, spdisplays_builtin
Memory Module: LPDDR4
AirPort: spairport_wireless_card_type_airport_extreme, wl0: Jul  7 2021 00:48:27 version 18.50.40.10.7.8.121 FWID 01-f5ad2691
Bluetooth: Version 8.0.5d7, 3 services, 27 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en1
USB Device: USB 3.1 Bus
USB Device: USB 3.1 Bus
USB Device: USB 3.0 Bus
USB Device: USB3.1 Hub
USB Device: UMC204HD 192k
USB Device: USB2.1 Hub
USB Device: CHERRY Wired Keyboard
USB Device: Jabra Elite 65t
Thunderbolt Bus: Mac mini, Apple Inc.
Thunderbolt Bus: Mac mini, Apple Inc.

Oh! The runtime option -o runtime should be removed from the codesign command to resolve the Library Validation error. The app still reports an outdated version, this maybe due to not rm -r build your build directory in between builds?

That’s a success! Now it works, even if I run the app from the build directory.

Regarding the reported version, I don’t know hat I did, in general I delete dthe content of the builddirectory by hand as the rm -rf always complains that the directory is not empty and refuses to delete it.
But I’m running the correct version (5.8-3035-g42fecdada).

Thanks a lot for your help and patience.

Edit: actually the app runs fine from the builddirectory only if I have run it first from the Applications directory


Yes the app is actually referring to and hardcoded to what is in /Applications. Turning off runtime allows the launch from elsewhere, while the behavior of the notarized app won’t allow such a run.
At times when rm -r a dir on mac, the hidden visual metadata files will get updated following removal of files, and it takes a second rm -r to finally clear it.

Now my question for you is, does the Dynamic Range Compression module in Exposure crash for you?

No it doesn’t crash (tried on raws from 3 different cameras, Pentax K10D and Fujifilm X-T1 and X-T2).

1 Like

Yes it does. Not only in Dynamic Range Compression module, also crash in noise reduction module (luminance control in curve mode)
Mac mini M1 here


1 Like

Thanks @Fafango , which macOS version are you running?

11.5.2 Big Sur

1 Like

No crash here in the Noise reduction module either.
Mac mini, Big Sur 11.5.2 as well.

The latest build:

https://kd6kxr.keybase.pub/RawTherapee_macOS_11.3_arm64_5.8-3046-g5268b94cf.zip

1 Like

Crashes on turning on the Dynamic Range module, nut not with the Noise Reduction module:

It feels very fast! :smiley: but still crashes in noise reduction module (luminance control in curve mode)

I had the same problem with the Intel build and finally solved it by manually setting the Threads parameter in Preferences/Performance to 2 (Preferences - RawPedia)