Fixed
Status Update
Comments
ch...@google.com <ch...@google.com>
si...@google.com <si...@google.com>
so...@google.com <so...@google.com>
si...@google.com <si...@google.com> #2
seems to be dup:
so...@google.com <so...@google.com> #3
Fundamentally the issue here is that the selection logic happening in composition depends on the text layout result which is available on measure. So we end up using stale TextLayoutResult which causes the issue.
ha...@google.com <ha...@google.com>
kl...@google.com <kl...@google.com> #4
This is the same exception as in
ha...@google.com <ha...@google.com> #5
There is a similar problem regarding Magnifier but I don't think these are directly related. The main cause for this issue is the async relation between TextFieldValue and layoutResult. Magnifier related crashes don't seem to be caused by changes in TextFieldValue or layout.
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-main
commit c1e913cdea06ac6cf01c596000d375013f1a1d7c
Author: Halil Ozercan <halilibo@google.com>
Date: Thu Jun 23 13:51:14 2022
Fix crash when selected text is cleared by state changes and re-added later
BasicTextField's String API manages the selection and composition completely internally. Therefore, its selection value stays the same across value changes that comes from hoisted state, instead of IME commands. In a case where selected text is removed by a state change and later added, text layout result lags behind. This change makes sure that selection handles are only drawn when layout result is in sync with the latest TextFieldValue.
Fix: b/208655565
Fix: b/214253689
Test: CoreTextFieldSelectionContentChangeTest.kt
Relnote: Fixed a crash where TextField is cleared and refilled while selection is active.
Change-Id: I1235b669921e67dcbec9e55a6d1a95ff609fe4b6
A compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSelectionContentChangeTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
https://android-review.googlesource.com/2133687
Branch: androidx-main
commit c1e913cdea06ac6cf01c596000d375013f1a1d7c
Author: Halil Ozercan <halilibo@google.com>
Date: Thu Jun 23 13:51:14 2022
Fix crash when selected text is cleared by state changes and re-added later
BasicTextField's String API manages the selection and composition completely internally. Therefore, its selection value stays the same across value changes that comes from hoisted state, instead of IME commands. In a case where selected text is removed by a state change and later added, text layout result lags behind. This change makes sure that selection handles are only drawn when layout result is in sync with the latest TextFieldValue.
Fix:
Fix:
Test: CoreTextFieldSelectionContentChangeTest.kt
Relnote: Fixed a crash where TextField is cleared and refilled while selection is active.
Change-Id: I1235b669921e67dcbec9e55a6d1a95ff609fe4b6
A compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSelectionContentChangeTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
Description
For reproduction, see applied project and demo video
screen-20211202-121335.mp4