Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS TextField crash when using speech-to-text #4443

Closed
kodebach opened this issue Mar 7, 2024 · 2 comments · Fixed by JetBrains/compose-multiplatform-core#1183
Closed

iOS TextField crash when using speech-to-text #4443

kodebach opened this issue Mar 7, 2024 · 2 comments · Fixed by JetBrains/compose-multiplatform-core#1183
Assignees
Labels
bug Something isn't working crash ios p:critical Critical priority reproduced text

Comments

@kodebach
Copy link

kodebach commented Mar 7, 2024

Describe the bug
When using the builtin iOS speech-to-text feature to enter text into a TextField the app crashes with a stack trace pointing to Compose Multiplatform.

Affected platforms

  • iOS

Versions

  • Kotlin version*: 1.9.22
  • Compose Multiplatform version*: 1.6.0
  • OS version(s)*: confirmed on iOS 15.8 and 17.3.1
  • OS architecture: arm64
  • Device: confirmed on iPhone 7 (iOS 15.8) and iPhone XR (iOS 17.3.1)

To Reproduce

  1. Run an iOS app with a Compose Multiplatform TextField
  2. Tap the TextField to bring up the keyboard
  3. Tap the microphone icon to start speech-to-text
  4. Say something and wait for speech-to-text recognition
  5. App crashes

Expected behavior
No crash, and speech-to-text recognized text entered into TextField.

Additional context

It seems speech-to-text did work at some point: #2984

We have two similar but slightly different stack traces from production builds. The first one looks like this:

0   App             0x102e341d0 kfun:androidx.compose.ui.platform.toTextIterator#internal + 1040 (UIKitTextInputService.uikit.kt:0)
1   App             0x102e334a4 kfun:androidx.compose.ui.platform.UIKitTextInputService.object-2.isPositionAtBoundary#internal + 180 (UIKitTextInputService.uikit.kt:568)
2   App             0x102e57c78 kfun:androidx.compose.ui.platform.IOSSkikoInput#isPositionAtBoundary(kotlin.Int;platform.UIKit.UITextGranularity;kotlin.Long){}kotlin.Boolean-trampoline + 200 (IOSSkikoInput.uikit.kt:140)
3   App             0x102e57c78 kfun:androidx.compose.ui.window.IntermediateTextInputUIView.object-1.isPosition#internal + 492 (IntermediateTextInputUIView.uikit.kt:554)
4   App             0x1035def7c _6f72672e6a6574627261696e732e636f6d706f73652e75693a75692f6f70742f6275696c644167656e742f776f726b2f383339343731666333323931333563372f636f6d706f73652f75692f75692f7372632f75696b69744d61696e2f6b6f746c69... + 336
5   UIKitCore       0x184545094 +[UIDictationUtilities needsTrailingSpaceForPhrases:secureInput:] + 556 (UIDictationUtilities.m:388)
....

The second kind is almost identical, but the UIDictationUtilities method that calls into Compose is selectionStartInfoWithBlock instead.

In a debug build, we couldn't tell what UIKit method calls into Compose, but we found that a kotlin.NotImplementedError is thrown here:

https://github.com/JetBrains/compose-multiplatform-core/blob/99c5d1d3bd7eba7dbebcd42af0897f8862291822/compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/platform/UIKitTextInputService.uikit.kt#L614

UITextGranularity.UITextGranularityParagraph -> TODO("UITextGranularityParagraph iterator")

Is there any way for us to work around this issue, or is speech-to-text broken until Compose Multiplatform implements these TODOs?

@kodebach kodebach added bug Something isn't working submitted labels Mar 7, 2024
@igordmn
Copy link
Collaborator

igordmn commented Mar 7, 2024

Thanks!

@mazunin-v-jb, could you please help to reproduce it? I tried iOS Simulator 17.0, it doesn't crash

@igordmn igordmn added text crash ios help wanted Extra attention is needed p:critical Critical priority and removed submitted labels Mar 7, 2024
@jxdom
Copy link

jxdom commented Mar 11, 2024

I also encountered the same problem. When I use voice input, the iOS app crashes. I'm using iOS 17.4.

@igordmn igordmn added reproduced and removed help wanted Extra attention is needed labels Mar 11, 2024
ASalavei added a commit to JetBrains/compose-multiplatform-core that referenced this issue Mar 12, 2024
## Proposed Changes
Use iOS native implementation of `UITextInputTokenizerProtocol`
represented by the class `UITextInputStringTokenizer`.

The PR reverts changes of
#808 ,
however due to `textInput = this` parameter, the Fast Delete feature
keeps working as intended.

Fixes: JetBrains/compose-multiplatform#4443
ASalavei added a commit to JetBrains/compose-multiplatform-core that referenced this issue Mar 12, 2024
## Proposed Changes
Use iOS native implementation of `UITextInputTokenizerProtocol`
represented by the class `UITextInputStringTokenizer`.

The PR reverts changes of
#808 ,
however due to `textInput = this` parameter, the Fast Delete feature
keeps working as intended.

Fixes: JetBrains/compose-multiplatform#4443
@ASalavei ASalavei added changelog1.6.1 Temporary label for 1.6.1 changelog (will be removed) and removed changelog1.6.1 Temporary label for 1.6.1 changelog (will be removed) labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash ios p:critical Critical priority reproduced text
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants