Fixed
Status Update
Comments
ai...@googlemail.com <ai...@googlemail.com> #2
Forgot to mention, this also crashes the preview (the stack trace is from the preview).
Also, it is specifically the `return@FakeBox` in the code above that causes this to happen. Writing this particular code in another way such as `if(text != null) { /*expression*/ }` works just fine.
Also, it is specifically the `return@FakeBox` in the code above that causes this to happen. Writing this particular code in another way such as `if(text != null) { /*expression*/ }` works just fine.
cl...@google.com <cl...@google.com>
ai...@googlemail.com <ai...@googlemail.com> #3
I was using beta09 before, which definitely worked. I hadn't checked whether or not it was visible in any of the RCs
le...@google.com <le...@google.com> #4
This looks like a bug caused by the return@FakeBox. I will look into this. If this is currently blocking you, if you restructure your code to not use a named-early-return of the inline composable function, i am guessing that the error would go away.
Thank you for reporting such a nice and easy repro case!
Thank you for reporting such a nice and easy repro case!
tr...@gmail.com <tr...@gmail.com> #5
Looks like extremely critical bug making impossible to early return from composables. Its very frustrating, because the code often becomes too inconvinient.
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-main
commit ab0c058b28f3326fcf266626248808c509ab9b93
Author: Leland Richardson <lelandr@google.com>
Date: Wed Oct 06 17:56:17 2021
Emit balanced start/end groups for inline lambdas with early returns
Fixes: 173651155
Fixes: 195242921
Change-Id: Id8220b8a7731c4ddd065cd9fe50669a423829de1
M compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableFunctionBodyTransformer.kt
M compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ControlFlowTransformTests.kt
https://android-review.googlesource.com/1847147
Branch: androidx-main
commit ab0c058b28f3326fcf266626248808c509ab9b93
Author: Leland Richardson <lelandr@google.com>
Date: Wed Oct 06 17:56:17 2021
Emit balanced start/end groups for inline lambdas with early returns
Fixes: 173651155
Fixes: 195242921
Change-Id: Id8220b8a7731c4ddd065cd9fe50669a423829de1
M compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableFunctionBodyTransformer.kt
M compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ControlFlowTransformTests.kt
ca...@digitalchargingsolutions.com <ca...@digitalchargingsolutions.com> #7
Hi, we just faced this as well. Can you please tell us when this fix will be released? Thanks!
ww...@gmail.com <ww...@gmail.com> #8
For me this crash still happens on compose 1.0.5
ai...@googlemail.com <ai...@googlemail.com> #9
As others pointed out already, this still happens on 1.0.5
ba...@gmail.com <ba...@gmail.com> #10
I have this crash on Compose 1.1.1
ba...@gmail.com <ba...@gmail.com> #11
I have this crash on Compose 1.1.1 if simply type "return". But "return@SomeComposableFunction" works. For example "return@Column"
Description
```
@Preview(name = "BugRepro preview")
@Composable
private fun BugReproPreview() {
CustomTextBroken(null)
}
@Composable
fun CustomTextBroken(text: String?) {
FakeBox {
text ?: return@FakeBox
Text(text)
}
}
@Composable
inline fun FakeBox(content: @Composable () -> Unit) {
content()
}
```
The same happens with `Box` or any other inlined composable. Interestingly, removing the inline modifier from `FakeBox` above allows this to work. This previously work on older beta versions of compose before these methods were inlined.
Stacktrace:
```
java.lang.IllegalStateException: Compose Runtime internal error. Unexpected or incorrect use of the Compose internal runtime API (Start/end imbalance). Please report to Google or use
at androidx.compose.runtime.ComposerKt.composeRuntimeError(Composer.kt:3455)
at androidx.compose.runtime.ComposerImpl.finalizeCompose(Composer.kt:3539)
at androidx.compose.runtime.ComposerImpl.endRoot(Composer.kt:1233)
at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:2583)
at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:2517)
at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:476)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:727)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:432)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:144)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:135)
at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:727)
at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:135)
at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:187)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:196)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:142)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:135)
at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:814)
at android.view.View.dispatchAttachedToWindow(View.java:20479)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3489)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:44)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:360)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:431)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:141)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:714)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$7(RenderTask.java:870)
at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$2.run(RenderExecutor.kt:187)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
```