Is there any sample which uses movableContent whil...
# compose
s
Is there any sample which uses movableContent while also receiving parameters? The official samples here don’t do that. I got issues with it still showing the parameters passed in the previous invokation, showing stale data and as a result and I wonder if I am misusing them somehow. a weird error message
java.lang.ArrayIndexOutOfBoundsException: src.length=16 srcPos=12 dst.length=16 dstPos=11 length=-7
(edit) Seems like movableContentOf + SubCompose still don’t play well with each other even after the 1.3 fix which should fix some of the problems this combo had.
I am trying to use them now that moving them in and out of subcomposition is supposed to work ever since compose 1.3, hence maybe the references to subcomposition in the full stacktrace
Copy code
java.lang.ArrayIndexOutOfBoundsException: src.length=16 srcPos=12 dst.length=16 dstPos=11 length=-7
  at java.lang.System.arraycopy(Native Method)
  at kotlin.collections.ArraysKt___ArraysJvmKt.copyInto(_ArraysJvm.kt:1247)
  at androidx.compose.runtime.collection.MutableVector.removeAt(MutableVector.kt:795)
  at androidx.compose.ui.node.MutableVectorWithMutationTracking.removeAt(MutableVectorWithMutationTracking.kt:43)
  at androidx.compose.ui.node.LayoutNode.removeAt$ui_release(LayoutNode.kt:287)
  at androidx.compose.ui.node.UiApplier.remove(UiApplier.android.kt:35)
  at androidx.compose.runtime.ComposerImpl$realizeMovement$1.invoke(Composer.kt:3769)
  at androidx.compose.runtime.ComposerImpl$realizeMovement$1.invoke(Composer.kt:3769)
  at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:808)
  at androidx.compose.runtime.CompositionImpl.dispose(Composition.kt:608)
  at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.disposeCurrentNodes(SubcomposeLayout.kt:705)
  at androidx.compose.ui.layout.SubcomposeLayoutState.disposeCurrentNodes$ui_release(SubcomposeLayout.kt:230)
  at androidx.compose.ui.layout.SubcomposeLayoutKt$SubcomposeLayout$5$1$invoke$$inlined$onDispose$1.dispose(Effects.kt:485)
  at androidx.compose.runtime.DisposableEffectImpl.onForgotten(Effects.kt:85)
  at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1080)
  at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:818)
  at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:839)
  at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:585)
  at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:503)
  at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:34)
  at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109)
  at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
  at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:970)
  at android.view.Choreographer.doCallbacks(Choreographer.java:796)
  at android.view.Choreographer.doFrame(Choreographer.java:727)
  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
  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:7656)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
  Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@28aa296, androidx.compose.ui.platform.MotionDurationScaleImpl@8951e17, StandaloneCoroutine{Cancelling}@3730204, AndroidUiDispatcher@5ad43ed]
j
You should file a bug about that regardless. Either the compiler should prevent you or it should work. You should never see a stacktrace like that.
s
Yeap, I’m working on making a min repro atm
Oh damn I think I created it in a topic which is not publicly available 🤦‍♂️ I just got a number
258053979
and this is my minimal reproduction repository https://github.com/StylianosGakis/subcompose-movablecontent-bug I posted it on
Android Public Tracker > App Development > Jetpack Compose > Compiler plug-in and runtime
as I assumed this has to be a problem in the
runtime
artifact since movableContentOf lives there. There were some changes that were supposed to enable this interaction in compose 1.3 after I remember having this discussion https://kotlinlang.slack.com/archives/CJLTWPH7S/p1660896793260219 which links to this commit https://android-review.googlesource.com/c/platform/frameworks/support/+/2199821. But alas it seems like it’s not entirely working yet.
j
weird. there's a public issue created 30m ago in that component: https://issuetracker.google.com/issues?q=status:open%20componentid:610764
can you still see the issue? It may have flagged you as spam or something.
s
No I can’t seem to find it in any way. If it is in fact hidden, how would I know if it exists or not?
Damn if it was marked as spam that’d be super unfortunate 😬
s
Getting “Access denied for $my_email” banner at the bottom
j
yeah same. it's okay though. we can (legitimately) summon nice people like @Leland Richardson [G] (who appears to be online) who can probably help and are just as eager to see the compiler not produce code which crashes at runtime
i usually would force politely ask adamp as my go-to but he appears offline at the moment
s
Yeah if someone could internally look at it I would be very thankful! I did not manage to reproduce the crash in my minimal repro btw. But I did manage to make it render wrong, aka have the <T> that is passed in to the movableContent to still show the stale data from the old invocation (you can check the video on the github repo to see that). In the real app I think what my crash was referring to is that since it was crashing when clicking it, the lambda that I was passing from the two invocations were different and I presume it was still trying to call the old lambda, resulting in this out of bounds exception. But again, this is all an assumption. In my real example where it crashed, it was a bit more complex. The container was a
ModalBottomSheetLayout
on the first if branch (this has the SubCompose call) and the other branch was just some `Box`es and `Column`s (No SubCompose existing on this call)
s
seems like antispam bot felt like it is spam for some reason 🙂 I restored it
s
Ah thanks! Any specific reason why so I can avoid in the future? I think I only had a link to this slack archives and my GitHub repo. Could it be that the slack link looked shady? This is what I'm referring to as " slack archives": https://kotlinlang.slack.com/archives/C0922A726/p1655833311041639?thread_ts=1655833311.041639&amp;cid=C0922A726
s
not aware of any reason, tbh, not sure which heuristic it uses 🙂
l
We've been getting a lot of false-positives on issues getting marked as spam in the past week or so. We're working with the team behind it to try and get the spam detection either turned off or adjusted to prevent this. Sorry about this 😕 it's really annoying
i updated the bug and added some additional context from this thread. From my looking at the code, it looks like you're not necessarily using it inside of subcomposition, but you're toggling between it and a subcomposition, which maybe is causing some corner case that hadn't been tested. Definitely looks like a bug on our end though.
s
Thanks Leland! I am gonna give some more context too since this stack trace isn’t exactly what I get in the Github project I linked above but in my original app, so I don’t want to confuse you. Luckily that one is open sourced too so I will give you all the info I can, just gimme a minute, writing the explanation there 😊
l
thanks
s
I hope the bot doesn’t again feel like me posting 7 links in the response is bot behavior 😅