Crash in -[NSLayoutConstraint setConstant:] + 96 (NSLayoutConstraint.m:750)

Hello,

I've noticed a few rare crashes with the following stacktrace reported on AppStore connect:

Hardware Model:      iPhone16,2
AppStoreTools:         15F31e
AppVariant:               1:iPhone16,2:17.4
OS Version:               iPhone OS 17.5.1 (21F90)

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: SIGNAL 6 Abort trap: 6
Terminating Process: <App> [15575]

Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation					0x1a3d38f20 __exceptionPreprocess + 164 (NSException.m:249)
1   libobjc.A.dylib				     	0x19bbbe018 objc_exception_throw + 60 (objc-exception.mm:356)
2   Foundation					      	0x1a323f868 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 188 (NSException.m:252)
3   CoreAutoLayout					0x1c4eabcc8 -[NSLayoutConstraint _setSymbolicConstant:constant:symbolicConstantMultiplier:] + 552 (NSLayoutConstraint.m:669)
4   CoreAutoLayout					0x1c4eab674 -[NSLayoutConstraint setConstant:] + 96 (NSLayoutConstraint.m:750)
5   <App>						          	0x10486d578 closure #1 in BaseChatTableViewCell.requestPreview(for:with:) + 540 (BaseChatTableViewCell+File.swift:162)
6   <App>						          	0x10486d73c thunk for @escaping @callee_guaranteed (@in_guaranteed URLRequest, @guaranteed NSHTTPURLResponse?, @guaranteed UIImage) -> () + 164 (<compiler-generated>:0)
7   <App>						          	0x104c4f814 __85-[UIImageView(AFNetworking) setImageWithURLRequest:placeholderImage:success:failure:]_block_invoke + 176 (UIImageView+AFNetworking.m:118)
8   <App>					          		0x104c3cc74 __78-[AFImageDownloader downloadImageForURLRequest:withReceiptID:success:failure:]_block_invoke.88 + 52 (AFImageDownloader.m:276)
9   libdispatch.dylib				0x1abbdc13c _dispatch_call_block_and_release + 32 (init.c:1530)
10  libdispatch.dylib				0x1abbdddd4 _dispatch_client_callout + 20 (object.m:576)
11  libdispatch.dylib				0x1abbec5a4 _dispatch_main_queue_drain + 988 (queue.c:7898)
12  libdispatch.dylib				0x1abbec1b8 _dispatch_main_queue_callback_4CF + 44 (queue.c:8058)
13  CoreFoundation					0x1a3d0b710 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1780)
14  CoreFoundation					0x1a3d08914 __CFRunLoopRun + 1996 (CFRunLoop.c:3149)
15  CoreFoundation					0x1a3d07cd8 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
16  GraphicsServices				0x1e8bb81a8 GSEventRunModal + 164 (GSEvent.c:2196)
17  UIKitCore						0x1a634090c -[UIApplication _run] + 888 (UIApplication.m:3713)
18  UIKitCore						0x1a63f49d0 UIApplicationMain + 340 (UIApplication.m:5303)
19  <App>							0x1047c6c20 main + 80 (main.m:11)
20  dyld							0x1c73b9e4c start + 2240 (dyldMain.cpp:1298)

It crashes on the last line of

            let previewSize = BaseChatTableViewCell.getPreviewSize(from: imageSize, isMediaFile)

            self.filePreviewImageViewHeightConstraint?.constant = previewSize.height
            self.filePreviewImageViewWidthConstraint?.constant = previewSize.width

where previewSize is a CGSize. I am unable to reproduce the crash, nor am I able to understand why it crashes there. Anyone got an idea what could cause a crash on setting a constant?

Seems that one way to crash at setting the constant is to have a non-finite value. So for now I added a check for finite values. Let's see if this fixes the crashes I am seeing.

Crash in -[NSLayoutConstraint setConstant:] + 96 (NSLayoutConstraint.m:750)
 
 
Q