I get the same error in the same place:
.onChange(of: vm.appleTraslationSourceText, { _, newValue in
guard configuration == nil else {
configuration?.invalidate()
return
}
configuration = TranslationSession.Configuration(
source: sourceLanguage,
target: targetLanguage)
})
.translationTask(configuration) { session in
Task { @MainActor in
do {
let response = try await session.translate(vm.appleTraslationSourceText) // <- fatal error here
targetText = response.targetText
} catch {
// code to handle error
}
}
}
This code, like yours, is very similar to Apple's demonstration code for translationTask(_:action:)
In my app you tap words to get a translation. If I tap too quickly on different words the crash will occur generating this error:
Translation/TranslationError+TranslationOnly.swift:54: Fatal error: Attempted to use TranslationSession after the view it was attached to has disappeared, which is not supported. Instead of storing a TranslationSession instance outside of the .translationTask closure, trigger a .translationTask to run again on a visible view and use that TranslationSession instance.
and
Refusing new translation request because text session has already been cancelled
So my problem seems to occur when requesting a new translation before the previous one has been returned.
Your scrollview could be requesting translations very often when scrolling?
Post
Replies
Boosts
Views
Activity
I had the same problem.
Open the invitation email on a device that DOESN'T have TestFlight installed.
Tap on the blue "View in TestFlight" button and you will be taken to a testflight.apple.com page which provides a redeem code.
Go to TestFlight on your test device, tap "Redeem" and enter the code.
There is no error. Character range: {47, 4} -> 'cede' " is indeed correct if " character range: {42, 13} -> 'unprecedented' "