Status Update
Comments
ha...@reddit.com <ha...@reddit.com> #2
Looks like I botched the title, it should be "Crash when dynamically adding ComposeView to RecyclerView item"
ma...@google.com <ma...@google.com> #3
Ryan, please take a look or triage accordingly
ry...@google.com <ry...@google.com> #5
This has been addressed in RecyclerView 1.3.1-rc01; please let us know if it's still happening.
ha...@reddit.com <ha...@reddit.com> #6
I can confirm this is fixed in RecyclerView 1.3.1-rc01. Thanks a lot!
Description
Steps to Reproduce or Code Sample to Reproduce:
See MainActivity in attached sample project, or:
Note: RV refers to
RecyclerView
RecyclerView
RecyclerView
are emptyFrameLayout
sonBindViewHolder
of the RV adapter, createComposeView
and add it as a child to theFrameLayout
. CallsetContent
on theComposeView
with arbitrary layout (e.g. coloredBox
)notifyItemChanged(0, Any())
Behavior:
What I would expect to happen: No crash happens
What actually happens:
onBindViewHolder
call, theparent
field of theRecyclerView
item view will benull
, but itsmAttachInfo
will not benull
ComposeView
is added to the item view, itsisAttachedToWindow
will be true, and it will try to create a composition.ViewTreeLifecycleOwner
usingView.findViewTreeLifecycleOwner()
which tries walking up the view hierarchy to obtain the owner from the root view.parent
,View.findViewTreeLifecycleOwner()
returns null, andView.createLifecycleAwareWindowRecomposer()
throws and crashes the app.Stack trace (if applicable):