[Ink Recognition] Crash when attempting to run on iOS
Title: Crash when attempting to run on iOS.
Describe the bug I'm using the ink_recognition library, but it's crashing when trying to download the model on iOS 12 with an iPhone 6 (physical device) and when attempting to run recognition on iOS 16 with an iPhone 14 Pro Max (simulator). I'm using the "pt-BR" model, but the same issue occurs with the "en-US" model. When testing on Android, the model downloads and runs without any issues.
To Reproduce Steps to reproduce the behavior:
- Try to download the model in iOS 12.
- Try to recognize a draw in any iOS version.
Expected behavior The drawing should be recognized without any issues.
Platform (please complete the following information):
- OS: iOS
- Device: iPhone 6 (physical device) and iPhone 14 Pro Max (simulator)
- OS: iOS 12.5.5 and iOS 16
- Flutter/Dart Version: Flutter 3.13.1, Dart 3.1.0
Additional context Download Method:
final _modelIdentifier = 'pt-BR';
Future<void> downloadInkRecognitionModel() async {
try {
await _modelManager.downloadModel(
_modelIdentifier,
isWifiRequired: false,
);
} catch (e) {
rethrow;
}
}
Crash log:
2023-08-30 15:54:31.909774-0300 Runner[27258:1239673] *** Terminating app
due to uncaught exception 'NSInvalidArgumentException', reason: '*** -
[__NSCFConstantString stringByAppendingString:]: nil argument'
*** First throw call stack:
(
0 CoreFoundation 0x000000010f7058ab
__exceptionPreprocess + 242
1 libobjc.A.dylib 0x000000010d3dbba3
objc_exception_throw + 48
2 Foundation 0x0000000111b26242 -[NSString
stringByAppendingFormat:] + 0
3 Runner 0x0000000102e52889 -
[MLKDigitalInkRecognitionModel initWithModelIdentifier:] + 87
4 Runner 0x00000001035617c2 -
[GoogleMlKitDigitalInkRecognitionPlugin handleDetection:result:] + 206
5 Runner 0x0000000103561613 -
[GoogleMlKitDigitalInkRecognitionPlugin handleMethodCall:result:] + 220
6 Flutter 0x00000001160b56bd __45-
[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 168
7 Flutter 0x0000000115a77f52
___ZN7flutter25PlatformMessageHandlerIos21HandlePlatformMessageENSt21
+ 94
8 libdispatch.dylib 0x000000010f465d18
_dispatch_call_block_and_release + 12
9 libdispatch.dylib 0x000000010f466f5b
_dispatch_client_callout + 8
10 libdispatch.dylib 0x000000010f477d55
_dispatch_main_queue_drain + 1463
11 libdispatch.dylib 0x000000010f477790
_dispatch_main_queue_callback_4CF + 31
12 CoreFoundation 0x000000010f664b1f
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 CoreFoundation 0x000000010f65f436 __CFRunLoopRun
+ 2482
14 CoreFoundation 0x000000010f65e6a7
CFRunLoopRunSpecific + 560
15 GraphicsServices 0x000000011159128a
GSEventRunModal + 139
16 UIKitCore 0x00000001296d9ad3 -[UIApplication _run]
+ 994
17 UIKitCore 0x00000001296de9ef UIApplicationMain +
123
18 Runner 0x0000000102cde89f main + 63
19 dyld 0x000000010c5772bf start_sim + 10
20 ??? 0x0000000203dfd52e 0x0 + 8654935342
21 ??? 0x0000000203df8000 0x0 + 8654913536
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[__NSCFConstantString stringByAppendingString:]: nil argument'
terminating with uncaught exception of type NSException
CoreSimulator 857.14 - Device: iPhone 14 Pro (10D7DFC9-26BD-4669-9F40-
B5F023DA9FE4) - Runtime: iOS 16.2 (20C52) - DeviceType: iPhone 14 Pro
I am getting same in android also.
I am getting same in android also.
@fbernaly
At present, I can only modify the code as follows to ensure normal operation;
Annotate all if (! GenericModelManager. isModelDownloaded (model))
Only judge on the Flutter platform first
public void isModelDownloaded(RemoteModel model, @NonNull final MethodChannel.Result result) {
// IsModelDownloaded myCallable = new IsModelDownloaded(remoteModelManager.isModelDownloaded(model)); // Future<Boolean> taskResult = executorService.submit(myCallable); // try { // return taskResult.get(); // } catch (InterruptedException | ExecutionException e) { // e.printStackTrace(); // } // return null; try { remoteModelManager.isModelDownloaded(model) .addOnSuccessListener(new OnSuccessListener<Boolean>() { @Override public void onSuccess(@NonNull Boolean isDownloaded) { result.success(isDownloaded); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { result.error("Check model failed!", e.getMessage(), e); } }); } catch (Exception e) { result.error("Exception", e.getMessage(), e); } }
Thanks, will take a look
I implemented some changes in my project by switching the language model exclusively to 'pt'. Consequently, ink_recognition is now functional on iOS again, albeit exclusively for iOS 14 and later versions. I conducted tests on the following platforms:
- iPhone 6 Plus (Physical device) with iOS 12.5.7
- iPhone XR (Physical device) with iOS 13.7
- iPhone 8 (Virtual device) with iOS 14.0.1
- iPhone 14 Plus (Virtual device) with iOS 16.4
Out of these devices, only the virtual ones with iOS 14+ operated smoothly. Earlier versions resulted in the app abruptly closing without generating a crash log on Crashlytics. Unfortunately, I lack an adapter to connect the physical iPhone to my Mac for conducting development tests, so I do not possess a detailed log of the incident.
@fbernaly any updates on this? I would really appreciate a fix for this, because currently, I can not use this package on iOS at all due to this crash.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.