tv-samples: JetStream crashes on home screen

Sometimes JetStream’s home screen crashes when I move focus from the Iist in the ImmersiveList to other lists. The following is the stack trace:

 java.lang.IllegalStateException: node attached multiple times
                                                                                                    	at androidx.compose.ui.Modifier$Node.markAsAttached$ui_release(Modifier.kt:264)
                                                                                                    	at androidx.compose.ui.node.NodeChain.markAsAttached(NodeChain.kt:290)
                                                                                                    	at androidx.compose.ui.node.LayoutNode.onReuse(LayoutNode.kt:1344)
                                                                                                    	at androidx.compose.runtime.changelist.Operation$UseCurrentNode.execute(Operation.kt:319)
                                                                                                    	at androidx.compose.runtime.changelist.Operations.executeAndFlushAllPendingOperations(Operations.kt:307)
                                                                                                    	at androidx.compose.runtime.changelist.ChangeList.executeAndFlushAllPendingChanges(ChangeList.kt:77)
                                                                                                    	at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:970)
                                                                                                    	at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:999)
                                                                                                    	at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:1087)
                                                                                                    	at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3566)
                                                                                                    	at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3566)
                                                                                                    	at androidx.compose.runtime.CompositionImpl.composeInitial(Composition.kt:632)
                                                                                                    	at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:622)
                                                                                                    	at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcomposeInto(SubcomposeLayout.kt:498)
                                                                                                    	at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:471)
                                                                                                    	at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:462)
                                                                                                    	at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:446)
                                                                                                    	at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$Scope.subcompose(SubcomposeLayout.kt:862)
                                                                                                    	at androidx.compose.foundation.lazy.layout.LazyLayoutMeasureScopeImpl.measure-0kLqBqw(LazyLayoutMeasureScope.kt:125)
                                                                                                    	at androidx.tv.foundation.lazy.list.LazyListMeasuredItemProvider.getAndMeasure(LazyListMeasuredItemProvider.kt:49)
                                                                                                    	at androidx.tv.foundation.lazy.list.LazyListMeasureKt.measureLazyList-qnDatfE(LazyListMeasure.kt:169)
                                                                                                    	at androidx.tv.foundation.lazy.list.LazyListKt$rememberLazyListMeasurePolicy$1$1.invoke-0kLqBqw(LazyList.kt:324)
                                                                                                    	at androidx.tv.foundation.lazy.list.LazyListKt$rememberLazyListMeasurePolicy$1$1.invoke(LazyList.kt:190)
                                                                                                    	at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$3$2$1.invoke-0kLqBqw(LazyLayout.kt:107)
                                                                                                    	at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$3$2$1.invoke(LazyLayout.kt:100)
                                                                                                    	at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1.measure-3p2s80s(SubcomposeLayout.kt:704)
                                                                                                    	at androidx.compose.ui.node.InnerNodeCoordinator$LookaheadDelegateImpl.measure-BRTryo0(InnerNodeCoordinator.kt:81)
                                                                                                    	at androidx.compose.foundation.AndroidOverscrollKt$StretchOverscrollNonClippingLayer$2.invoke-3p2s80s(AndroidOverscroll.kt:584)
                                                                                                    	at androidx.compose.foundation.AndroidOverscrollKt$StretchOverscrollNonClippingLayer$2.invoke(AndroidOverscroll.kt:583)
                                                                                                    	at androidx.compose.ui.layout.LayoutModifierImpl.measure-3p2s80s(LayoutModifier.kt:291)
                                                                                                    	at androidx.compose.ui.node.LayoutModifierNodeCoordinator$LookaheadDelegateForLayoutModifierNode.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:64)
                                                                                                    	at androidx.compose.foundation.AndroidOverscrollKt$StretchOverscrollNonClippingLayer$1.invoke-3p2s80s(AndroidOverscroll.kt:568)
                                                                                                    	at androidx.compose.foundation.AndroidOverscrollKt$StretchOverscrollNonClippingLayer$1.invoke(AndroidOverscroll.kt:567)
                                                                                                    	at androidx.compose.ui.layout.LayoutModifierImpl.measure-3p2s80s(LayoutModifier.kt:291)
                                                                                                    	at androidx.compose.ui.node.LayoutModifierNodeCoordinator$LookaheadDelegateForLayoutModifierNode.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:64)
                                                                                                    	at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier.measure-3p2s80s(GraphicsLayerModifier.kt:646)

About this issue

  • Original URL
  • State: open
  • Created 8 months ago
  • Reactions: 1
  • Comments: 15

Most upvoted comments

throttleFactor 

@Daio-io what is ideal throttleFactor are you used? like throttleFactor = 2 or something else

@ChetanPatelPlayBoxTV For now we are just throttling input to reduce scroll speed as a bit of a bandaid so we can upgrade Compose etc until a full solution is available. This seems to be working in our tests but it is not bullet proof.

We just use a preview key modifier and a throttle factor to handle

 onPreviewKeyEvent { previewKey ->
        if (keyCodes.contains(previewKey.key.nativeKeyCode))
            if (previewKey.nativeKeyEvent.repeatCount % throttleFactor != 0)
                return@onPreviewKeyEvent true

        return@onPreviewKeyEvent false
    }

Just wrapped in our own Modifier 😃