Status Update
Comments
am...@fold.money <am...@fold.money> #2
Not able to edit the description.
Here is what crash is related to ->
val focusRequester = remember { FocusRequester() }
PinInput(
pageSidePadding = pageSidePadding,
modifier = modifier.focusRequester(focusRequester),
length = noOfBoxes,
onValueChanged = change,
value = text,
)
// LaunchedEffect(Unit) {
// focusRequester.requestFocus()
// }
This launched effect is causing the issue in my case.
se...@google.com <se...@google.com>
ra...@google.com <ra...@google.com> #3
Can you create a smaller repro with a simplified implementation of PinInput? Does PinInput use a Modifier.focusable() internally?
am...@fold.money <am...@fold.money> #4
Sure will add.
am...@fold.money <am...@fold.money> #5
Found the root cause of the issue.
I basically have a text field which is not visible.
TextField(
value = value,
onValueChange = {
if (it.length <= length) {
if (it.all { c -> c in '0'..'9' }) {
onValueChanged(it)
}
if (it.length >= length) {
keyboard?.hide()
}
}
},
// Hide the text field
modifier = modifier
.focusRequester(focusRequester = focusRequester)
.size(0.dp) // trouble causing line,
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.NumberPassword,
),
)
There is a launchedeffect at the end of it's parent composable which requests the focus.
LaunchedEffect(Unit) {
focusRequester.requestFocus()
}
Crash happens with the mentioned error, but If I change the size to a non zero value, crash doesn't occur anymore.
For my usecase textfield is just a placeholder, data in textfield is beautified and then shown separately.
jo...@veeva.com <jo...@veeva.com> #6
Seeing a similar crash in our app. We do request focus as mentioned previously but haven't been able to confirm if this is what is causing the crash.
Fatal Exception: java.lang.IllegalStateException: Expected BringIntoViewRequester to not be used before parents are placed.
at androidx.compose.foundation.gestures.ContentInViewModifier.calculateRectForParent(ContentInViewModifier.java:45)
at androidx.compose.foundation.relocation.BringIntoViewResponderModifier$bringChildIntoView$parentRect$1.invoke(BringIntoViewResponderModifier.java:17)
at androidx.compose.foundation.relocation.BringIntoViewResponderModifier$bringChildIntoView$parentRect$1.invoke(BringIntoViewResponderModifier.java:17)
at androidx.compose.foundation.relocation.AndroidBringIntoViewParent.a(AndroidBringIntoViewParent.java:4)
at androidx.compose.foundation.relocation.BringIntoViewResponderModifier$bringChildIntoView$2$2.invokeSuspend(BringIntoViewResponderModifier.java:45)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(BaseContinuationImpl.java:8)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.java:100)
at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.java:22)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.java:22)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.java:2)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7703)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952)
ma...@gmail.com <ma...@gmail.com> #7
We are using foundation library v1.4.1. Please help us to find root cause or resolution for this crash.
Please find logs
java.lang.IllegalStateException: Expected BringIntoViewRequester to not be used before parents are placed.
at androidx.compose.foundation.gestures.ContentInViewModifier.calculateRectForParent()(ContentInViewModifier.java:117)
at androidx.compose.foundation.relocation.BringIntoViewResponderNode.getResponder()(BringIntoViewResponderNode.java:136)
at androidx.compose.foundation.relocation.BringIntoViewResponderNode$bringChildIntoView$parentRect$1.invoke()(BringIntoViewResponderNode.java:160)
at androidx.compose.foundation.relocation.BringIntoViewResponderNode$bringChildIntoView$parentRect$1.invoke()(BringIntoViewResponderNode.java:160)
at androidx.compose.foundation.relocation.BringIntoViewResponder_androidKt$defaultBringIntoViewParent$1.bringChildIntoView()(BringIntoViewResponder_androidKt.java:31)
at androidx.compose.foundation.relocation.BringIntoViewResponderNode$bringChildIntoView$2$2.invokeSuspend()(BringIntoViewResponderNode.java:179)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith()(BaseContinuationImpl.java:30)
at kotlinx.coroutines.DispatchedTask.run()(DispatchedTask.java:106)
at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch()(AndroidUiDispatcher.java:79)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch()(AndroidUiDispatcher.java:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run()(AndroidUiDispatcher.java:57)
at android.os.Handler.handleCallback()(Handler.java:873)
at android.os.Handler.dispatchMessage()(Handler.java:99)
at android.os.Looper.loop()(Looper.java:211)
at android.app.ActivityThread.main()(ActivityThread.java:6775)
at java.lang.reflect.Method.invoke()(Method.java:-2)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run()(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main()(ZygoteInit.java:858)
thread 8369 - OkHttp Dispatcher:
java.lang.Object.wait()(Object.java:-2)
java.lang.Thread.parkFor$()(Thread.java:2137)
sun.misc.Unsafe.park()(Unsafe.java:358)
java.util.concurrent.locks.LockSupport.parkNanos()(LockSupport.java:230)
java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill()(SynchronousQueue.java:461)
java.util.concurrent.SynchronousQueue$TransferStack.transfer()(SynchronousQueue.java:362)
java.util.concurrent.SynchronousQueue.poll()(SynchronousQueue.java:937)
java.util.concurrent.ThreadPoolExecutor.getTask()(ThreadPoolExecutor.java:1091)
java.util.concurrent.ThreadPoolExecutor.runWorker()(ThreadPoolExecutor.java:1152)
java.util.concurrent.ThreadPoolExecutor$Worker.run()(ThreadPoolExecutor.java:641)
java.lang.Thread.run()(Thread.java:764)
to...@gmail.com <to...@gmail.com> #8
Still a rare issue on Compose 1.8 last week snapshots.
Exception java.lang.IllegalStateException: Expected BringIntoViewRequester to not be used before parents are placed.
at androidx.compose.foundation.internal.InlineClassHelperKt.throwIllegalStateException (InlineClassHelper.kt:26)
at androidx.compose.foundation.gestures.ContentInViewNode.calculateRectForParent (ContentInViewNode.kt:462)
at androidx.compose.foundation.relocation.BringIntoViewResponderNode$bringChildIntoView$parentRect$1.invoke (BringIntoViewResponder.kt:171)
at androidx.compose.foundation.relocation.BringIntoViewResponderNode$bringChildIntoView$parentRect$1.invoke (BringIntoViewResponder.kt:171)
at androidx.compose.foundation.relocation.BringIntoViewResponder_androidKt$defaultBringIntoViewParent$1.bringChildIntoView (BringIntoViewResponder.android.kt:29)
at androidx.compose.foundation.relocation.BringIntoViewResponderNode$bringChildIntoView$2$2.invokeSuspend (BringIntoViewResponder.kt:192)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:101)
at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch (AndroidUiDispatcher.android.kt:79)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch (AndroidUiDispatcher.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run (AndroidUiDispatcher.android.kt:57)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loopOnce (Looper.java:210)
at android.os.Looper.loop (Looper.java:299)
at android.app.ActivityThread.main (ActivityThread.java:8118)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:556)
al...@rockettrade.com <al...@rockettrade.com> #9
Is it a possible workaround to set the Textfield to 0.01.dp or even lower, and set it's alpha to 0f? If the size is an issue, it could be put in a box with the actually displayed component being on top of it, assuming it is bigger than 0.01.dp?
If the aforementioned textfield is within a lazycolumn, we solved this crash by first making sure that we scroll to that component (becomes visible on the screen), then call the focusrequester. It is quite tricky, as LazyColumn does not really offer a good way of scrolling to a specific composable, especially if the LazyColumn has both item {} and later below somewhere items() as well.
Description
Jetpack Compose component(s) used:
Android Studio Build:
Android Studio Electric Eel | 2022.1.1
Build #AI-221.6008.13.2211.9477386, built on January 11, 2023
Runtime version: 11.0.15+0-b2043.56-8887301 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Kotlin version: 1.7.20
Steps to Reproduce or Code Sample to Reproduce:
1.
2.
3.
Stack trace (if applicable):
```
FATAL EXCEPTION: main
Process: money.fold.marble, PID: 25006
java.lang.IllegalStateException: Expected BringIntoViewRequester to not be used before parents are placed.
at androidx.compose.foundation.gestures.ContentInViewModifier.calculateRectForParent(ContentInViewModifier.kt:117)
at androidx.compose.foundation.relocation.BringIntoViewResponderModifier$bringChildIntoView$parentRect$1.invoke(BringIntoViewResponder.kt:152)
at androidx.compose.foundation.relocation.BringIntoViewResponderModifier$bringChildIntoView$parentRect$1.invoke(BringIntoViewResponder.kt:152)
at androidx.compose.foundation.relocation.AndroidBringIntoViewParent.bringChildIntoView(BringIntoViewResponder.android.kt:43)
at androidx.compose.foundation.relocation.BringIntoViewResponderModifier$bringChildIntoView$2$2.invokeSuspend(BringIntoViewResponder.kt:171)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8057)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@88c75f2, androidx.compose.runtime.BroadcastFrameClock@aea2443, StandaloneCoroutine{Cancelling}@b900ac0, AndroidUiDispatcher@1b43f9]
2023-01-25 11:47:22.903 25006-25006 Process money.fold.marble I Sending signal. PID: 25006 SIG: 9
```