Fixed
Status Update
Comments
cl...@google.com <cl...@google.com>
an...@google.com <an...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 74eb06352cc3bf56d30d77b9434ef4a176b8f23f
Author: Adam Powell <adamp@google.com>
Date: Thu Mar 11 10:19:43 2021
Defer ViewTree dependency checks for ComposeView
Wait to check for the presence of required ViewTree dependencies until
we are both attached to a window and a composition is created. These
checks shouldn't trigger if a ComposeView hasn't setContent yet, as the
dependencies aren't yet needed.
Relnote: "Deferred check for ViewTree dependencies of ComposeView"
Fixes: 182466548
Test: existing tests
Change-Id: I8dbbf72f5646a6420c41995cc38732bce6b53d55
M compose/ui/ui/api/1.0.0-beta02.txt
M compose/ui/ui/api/current.txt
M compose/ui/ui/api/public_plus_experimental_1.0.0-beta02.txt
M compose/ui/ui/api/public_plus_experimental_current.txt
M compose/ui/ui/api/restricted_1.0.0-beta02.txt
M compose/ui/ui/api/restricted_current.txt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/ComposeView.android.kt
https://android-review.googlesource.com/1629419
Branch: androidx-main
commit 74eb06352cc3bf56d30d77b9434ef4a176b8f23f
Author: Adam Powell <adamp@google.com>
Date: Thu Mar 11 10:19:43 2021
Defer ViewTree dependency checks for ComposeView
Wait to check for the presence of required ViewTree dependencies until
we are both attached to a window and a composition is created. These
checks shouldn't trigger if a ComposeView hasn't setContent yet, as the
dependencies aren't yet needed.
Relnote: "Deferred check for ViewTree dependencies of ComposeView"
Fixes: 182466548
Test: existing tests
Change-Id: I8dbbf72f5646a6420c41995cc38732bce6b53d55
M compose/ui/ui/api/1.0.0-beta02.txt
M compose/ui/ui/api/current.txt
M compose/ui/ui/api/public_plus_experimental_1.0.0-beta02.txt
M compose/ui/ui/api/public_plus_experimental_current.txt
M compose/ui/ui/api/restricted_1.0.0-beta02.txt
M compose/ui/ui/api/restricted_current.txt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/ComposeView.android.kt
Description
Jetpack Compose release version: 1.0.0-beta02
Developers not using AppCompat version 1.3+ nor Fragment 1.3+ can hit this error (i.e. the need of manually setting owners for
ComposeView
ViewTreeLifecycleOwner
andViewTreeSavedStateRegistryOwner
) when usingComposeView
in a XML file even thoughComposeView
'ssetContent
method hasn't been called.These checks seem too aggressive and are done way earlier they're expected. I'd expect these checks to be called when
setContent
is called, not before.The workaround seen in the community is creating a
ComposeViewStub
that they use in XML and replace with aComposeView
at runtime. Then, LayoutParams and id are reassigned, the right owners are set, andsetContent
is called.