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

Upgrade compose version from 1.1.1 to 1.3.0-beta02, the TextField of my desktop application could not input any Chinese character #2493

Closed
GaoXing0608 opened this issue Nov 23, 2022 · 3 comments · Fixed by JetBrains/compose-multiplatform-core#339

Comments

@GaoXing0608
Copy link

2022-11-23 09:21:27,186 INFO (UncaughtExceptionHandler.kt:53)- java.lang.NullPointerException: Cannot read field "x" because "rc" is null
at java.desktop/sun.awt.windows.WInputMethod$1.run(WInputMethod.java:617)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:746)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:744)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:743)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)


When I press the Space and Enter key to input the Chinese character, the application crashed. It is normal when I input english character.

@dima-avdeev-jb
Copy link
Contributor

Thanks for the report!

@igordmn
Copy link
Collaborator

igordmn commented Nov 23, 2022

Reproducible in 1.2.1.

the application crashed.

In the todoapp-lite example, application itself doesn't crash (on my machine), we only see the crash in the logs.

We still can type Chinese text, but the popup is wrongly positioned.

Investigating further...

@GaoXing0608
Copy link
Author

Cannot read field "x" because "rc" is null

Because of I have set the UncaughtExceptionHandler for my application and exit the application while it catched.


Main.kt
fun App() {

MaterialTheme {
    val content = mutableStateOf("")
    TextField(
        value = content.value,
        onValueChange = {
            content.value = it
        }
    )
}

}

fun main() = application {

Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler())

Window(onCloseRequest = ::exitApplication) {
    App()
}

}


UncaughtExceptionHandler.kt
class UncaughtExceptionHandler: Thread.UncaughtExceptionHandler {
override fun uncaughtException(t: Thread?, e: Throwable?) {

    // Some operation for saving the crash log

    // Exit the application
    exitProcess(0)
}

}


So there are some bugs of TextFiled while inputing Chinese charcter

igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Dec 1, 2022
Fixes JetBrains/compose-multiplatform#2040
Fixes JetBrains/compose-multiplatform#2493

notifyFocusedRect was deprecated in https://android-review.googlesource.com/c/platform/frameworks/support/+/1959647

On Android, before deprecation this method was used to scroll to the focused text input.
This functionality was extracted to the text field itself, but we had another functionality on the other platforms.
On Desktop we show text input popup near text input (for some languages):
JetBrains/compose-multiplatform#2040 (comment)

I think that this method is the right choice to implement this functionality, but I am not completely sure. Here my thoughts about alternatives:

1. Use BringIntoViewRequester. Not sure that it is possible, because its purpose - to show the view to the user, not use the passed information to determine the text popup position
2. Get information about focused area from another source that is not related to text input. For example, we can inject FocusManager, and retrieve the focused rect from it. Probably not a good idea, because the rect of arbitrary focused node isn't the same thing as the rect of focused input area.
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Dec 5, 2022
* PlatformTextInputService. Undeprecate notifyFocusedRect

Fixes JetBrains/compose-multiplatform#2040
Fixes JetBrains/compose-multiplatform#2493

notifyFocusedRect was deprecated in https://android-review.googlesource.com/c/platform/frameworks/support/+/1959647

On Android, before deprecation this method was used to scroll to the focused text input.
This functionality was extracted to the text field itself, but we had another functionality on the other platforms.
On Desktop we show text input popup near text input (for some languages):
JetBrains/compose-multiplatform#2040 (comment)

I think that this method is the right choice to implement this functionality, but I am not completely sure. Here my thoughts about alternatives:

1. Use BringIntoViewRequester. Not sure that it is possible, because its purpose - to show the view to the user, not use the passed information to determine the text popup position
2. Get information about focused area from another source that is not related to text input. For example, we can inject FocusManager, and retrieve the focused rect from it. Probably not a good idea, because the rect of arbitrary focused node isn't the same thing as the rect of focused input area.

* Keep @deprecated until we don't merget this into AOSP
copybara-service bot pushed a commit to androidx/androidx that referenced this issue Jan 6, 2023
Fixes JetBrains/compose-multiplatform#2040
Fixes JetBrains/compose-multiplatform#2493

notifyFocusedRect was deprecated in https://android-review.googlesource.com/c/platform/frameworks/support/+/1959647

On Android, before deprecation this method was used to scroll to the focused text input.
This functionality was extracted to the text field itself, but we had another functionality on the other platforms.
On Desktop we show text input popup near text input (for some languages):
JetBrains/compose-multiplatform#2040 (comment)

I think that this method is the right choice to implement this functionality, but I am not completely sure. Here my thoughts about alternatives:

1. Use BringIntoViewRequester. Not sure that it is possible, because its purpose - to show the view to the user, not use the passed information to determine the text popup position
2. Get information about focused area from another source that is not related to text input. For example, we can inject FocusManager, and retrieve the focused rect from it. Probably not a good idea, because the rect of arbitrary focused node isn't the same thing as the rect of focused input area.

Bug: b/262648050
Change-Id: I23a0425b573a644fcc114a2b60d7bbbdaf5b04ed
Test: manual on Windows (./gradlew run1 -Pandroidx.compose.multiplatformEnabled=true), with Chinese keyboard layout
Relnote: `notifyFocusedRect` methods in `TextInputSession` and `TextInputService` are not deprecated again.
eymar pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Jan 13, 2023
* PlatformTextInputService. Undeprecate notifyFocusedRect

Fixes JetBrains/compose-multiplatform#2040
Fixes JetBrains/compose-multiplatform#2493

notifyFocusedRect was deprecated in https://android-review.googlesource.com/c/platform/frameworks/support/+/1959647

On Android, before deprecation this method was used to scroll to the focused text input.
This functionality was extracted to the text field itself, but we had another functionality on the other platforms.
On Desktop we show text input popup near text input (for some languages):
JetBrains/compose-multiplatform#2040 (comment)

I think that this method is the right choice to implement this functionality, but I am not completely sure. Here my thoughts about alternatives:

1. Use BringIntoViewRequester. Not sure that it is possible, because its purpose - to show the view to the user, not use the passed information to determine the text popup position
2. Get information about focused area from another source that is not related to text input. For example, we can inject FocusManager, and retrieve the focused rect from it. Probably not a good idea, because the rect of arbitrary focused node isn't the same thing as the rect of focused input area.

* Keep @deprecated until we don't merget this into AOSP
MatkovIvan pushed a commit to MatkovIvan/compose-multiplatform that referenced this issue May 10, 2023
* PlatformTextInputService. Undeprecate notifyFocusedRect

Fixes JetBrains#2040
Fixes JetBrains#2493

notifyFocusedRect was deprecated in https://android-review.googlesource.com/c/platform/frameworks/support/+/1959647

On Android, before deprecation this method was used to scroll to the focused text input.
This functionality was extracted to the text field itself, but we had another functionality on the other platforms.
On Desktop we show text input popup near text input (for some languages):
JetBrains#2040 (comment)

I think that this method is the right choice to implement this functionality, but I am not completely sure. Here my thoughts about alternatives:

1. Use BringIntoViewRequester. Not sure that it is possible, because its purpose - to show the view to the user, not use the passed information to determine the text popup position
2. Get information about focused area from another source that is not related to text input. For example, we can inject FocusManager, and retrieve the focused rect from it. Probably not a good idea, because the rect of arbitrary focused node isn't the same thing as the rect of focused input area.

* Keep @deprecated until we don't merget this into AOSP
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Nov 15, 2023
* PlatformTextInputService. Undeprecate notifyFocusedRect

Fixes JetBrains/compose-multiplatform#2040
Fixes JetBrains/compose-multiplatform#2493

notifyFocusedRect was deprecated in https://android-review.googlesource.com/c/platform/frameworks/support/+/1959647

On Android, before deprecation this method was used to scroll to the focused text input.
This functionality was extracted to the text field itself, but we had another functionality on the other platforms.
On Desktop we show text input popup near text input (for some languages):
JetBrains/compose-multiplatform#2040 (comment)

I think that this method is the right choice to implement this functionality, but I am not completely sure. Here my thoughts about alternatives:

1. Use BringIntoViewRequester. Not sure that it is possible, because its purpose - to show the view to the user, not use the passed information to determine the text popup position
2. Get information about focused area from another source that is not related to text input. For example, we can inject FocusManager, and retrieve the focused rect from it. Probably not a good idea, because the rect of arbitrary focused node isn't the same thing as the rect of focused input area.

* Keep @deprecated until we don't merget this into AOSP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants