Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Jetpack Compose version: 1.7.5
Jetpack Compose component(s) used: ObserverModifierNode
Android Studio Build: Android Studio Ladybug | 2024.2.1 #AI-242.21829.142.2421.12409432
Kotlin version: 1.9
Steps to Reproduce or Code Sample to Reproduce:
If a ComposeView is used in RecyclerView, the views get detached when scrolled off screen and reattached again when scrolled back or recycled. When the view is detached, snapshot observations registered within the view get cleared (including any registered using
ObserverModifierNode
). When the view gets reattached, theObserverModifierNode
doesn't get notified about this and the observers don't get resubscribed.If the ComposeView's content is wrapped with
key(position) {}
, this doesn't happen when views are recycled, but still happens when a view gets detached/reattached without being recycled.Changing the node to the following fixes the issue: