On Device Translation crashes app when translating multiple words
Rather than crashing the app with no information about why I would expect to get an error message back or an exception thrown that could be caught with a try/catch.
This should be reproducible in the sample project. That is where I found it.
Hi @fbernaly Can i handle this.. seem to be a try-and-catch block needed
@bensonarafat : go ahead, give it a try, make sure to provide testing steps in the PR.
great
@fbernaly this crash seems to happen only in IOS and the emulator
@SuperWes : could you confirm that you reproduce this in the simulator? or in a real device?
Any updates on this? I am facing the same issue on iOS simulator. It works fine on android emulator tho
Sorry, I have been busy with work, I do not have an ETA for now. However, contributions are always welcome. Submit your PRs and I will review them.
Hello, I will try to find the right solution as soon as I get some free time but for the time being I used this nasty hack. I think it's not that good from performance perspective but does the job for now.
Since this only breaks on iOS, i did a platform check and then iterated over the whole string word by word, then translated each word instead of the whole line string at once.
Here's the code if someone wants to use it until we get a proper fix:
// it crashes on iOS when multi-word line is passed
if (Platform.isIOS) {
String translated = "";
for (var substr in text.split(" ")) {
translated =
"$translated ${await onDeviceTranslator.translateText(substr)}";
}
return translated;
} else {
return await onDeviceTranslator.translateText(text);
}
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.