Official-Kodi-Remote-iOS
Official-Kodi-Remote-iOS copied to clipboard
Crash in textField:shouldChangeCharactersInRange:replacementString:
Following crash log is reported by ASC (mutate error). We have seen similar crashes in the past, and I remember that the proposed solution was seen as not needed. Let us discuss this again, as I do not remind the PR where we covered this topic.
Incident Identifier: EBE28BF6-5B9A-4D66-A02A-A5C4DB3C22A6
Hardware Model: iPhone13,3
Process: Kodi Remote [1731]
Path: /private/var/containers/Bundle/Application/2D971992-8DFA-46C8-B51B-224E403517AE/Kodi Remote.app/Kodi Remote
Identifier: it.joethefox.XBMC-Remote
Version: 1.10 (3228)
AppStoreTools: 13C90b
AppVariant: 1:iPhone13,3:15
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: it.joethefox.XBMC-Remote [952]
Date/Time: 2022-03-01 00:20:23.7807 +0100
Launch Time: 2022-02-25 00:42:45.0765 +0100
OS Version: iPhone OS 15.3 (19D49)
Release Type: User
Baseband Version: 2.23.02
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x180c510fc __exceptionPreprocess + 220 (NSException.m:200)
1 libobjc.A.dylib 0x19949dd64 objc_exception_throw + 60 (objc-exception.mm:565)
2 CoreFoundation 0x180d5a564 _CFThrowFormattedException + 116 (CFObject.m:2072)
3 CoreFoundation 0x180cf65c8 mutateError + 204 (CFObject.m:0)
4 CoreFoundation 0x180bf44bc -[__NSCFString replaceCharactersInRange:withString:] + 72 (CFObject.m:462)
5 Foundation 0x1824047c0 -[NSString stringByReplacingCharactersInRange:withString:] + 80 (NSString.m:783)
6 Kodi Remote 0x100690d3c -[XBMCVirtualKeyboard textField:shouldChangeCharactersInRange:replacementString:] + 340 (XBMCVirtualKeyboard.m:187)
7 UIKitCore 0x1841e46e4 -[UITextField _delegateShouldChangeCharactersInTextStorageRange:replacementString:delegateCares:] + 164 (UITextField.m:7712)
8 UIKitCore 0x1841dfd08 -[UITextField keyboardInput:shouldInsertText:isMarkedText:] + 332 (UITextField.m:5841)
9 UIKitCore 0x1841d40a0 -[UIFieldEditor keyboardInput:shouldInsertText:isMarkedText:] + 152 (UIFieldEditor.m:462)
10 UIKitCore 0x183d97a48 -[UIKeyboardCameraSession _updatePreviewWithString:] + 104 (UIKeyboardCameraSession.m:281)
11 UIKitCore 0x183d9808c -[UIKeyboardCameraSession keyboardCameraDidUpdateString:] + 296 (UIKeyboardCameraSession.m:373)
12 UIKitCore 0x18424dff4 -[UIKeyboardCameraViewController keyboardCameraDidUpdateString:] + 84 (UIKeyboardCameraViewController.m:221)
13 UIKitCore 0x183dadeb4 -[UIKeyboardCameraRemoteViewController keyboardCameraDidUpdateString:] + 68 (UIKeyboardCameraRemoteViewController.m:27)
14 CoreFoundation 0x180bda3a4 __invoking___ + 148
15 CoreFoundation 0x180bf7b74 -[NSInvocation invoke] + 468 (NSForwarding.m:3378)
16 libdispatch.dylib 0x1808c3670 _dispatch_client_callout + 20 (object.m:560)
17 libdispatch.dylib 0x1808c7128 _dispatch_block_invoke_direct + 264 (queue.c:489)
18 FrontBoardServices 0x1928969c4 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 48 (FBSSerialQueue.m:157)
19 FrontBoardServices 0x192895d8c -[FBSSerialQueue _targetQueue_performNextIfPossible] + 220 (FBSSerialQueue.m:181)
20 FrontBoardServices 0x19289a414 -[FBSSerialQueue _performNextFromRunLoopSource] + 28 (FBSSerialQueue.m:194)
21 CoreFoundation 0x180c730d0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1972)
22 CoreFoundation 0x180c83d90 __CFRunLoopDoSource0 + 208 (CFRunLoop.c:2016)
23 CoreFoundation 0x180bbe098 __CFRunLoopDoSources0 + 268 (CFRunLoop.c:2053)
24 CoreFoundation 0x180bc38a4 __CFRunLoopRun + 820 (CFRunLoop.c:2951)
25 CoreFoundation 0x180bd7468 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
26 GraphicsServices 0x19c77738c GSEventRunModal + 164 (GSEvent.c:2200)
27 UIKitCore 0x18357a5d0 -[UIApplication _run] + 1100 (UIApplication.m:3493)
28 UIKitCore 0x1832f8f74 UIApplicationMain + 364 (UIApplication.m:5047)
29 Kodi Remote 0x1005c5114 main + 88 (main.m:15)
30 dyld 0x100a09aa4 start + 520 (dyldMain.cpp:879)
Kernel Triage:
VM - Compressor failed a blocking pager_get
On StackOverflow I found threads which pointed to using a mutable string when calling replaceCharactersInRange:withString:
, even though this is not required as per documentation, like:
NSMutableString *textFieldString = [theTextField.text mutableCopy];
NSString *stringToSend = [textFieldString stringByReplacingCharactersInRange:range withString:string];
instead of
NSString *stringToSend = [theTextField.text stringByReplacingCharactersInRange:range withString:string];
Same time this might also avoid concurring write access to theTextField.text
.
@kambala-decapitator, what is your take on this?
the crash is very weird - how can immutable string be mutated... also the keyboard private class name is quite suspicious - how is it related to camera?
the proposed fix should help, true (or by just using copy
), but I'd rather want to understand the source of the issue. Fast googling also revealed that it might be related to the native swipe keyboard (haven't tested, I use MS SwiftKey).
also as I see, in this delegate method we don't actually change the text, but rather simply send the adjusted text to Kodi. I think it'd be better to use the tool suited exactly for this - detect when text has changed, https://developer.apple.com/documentation/uikit/uitextfieldtextdidchangenotification?language=objc
Did not see this crash since months. Will not be worth looking into this further.