Fixed
Status Update
Comments
da...@sucharda.cz <da...@sucharda.cz> #2
Still crashing with Compose 1.7.4.
I also tried moving sharedElement to BoxWithConstraints (rather than in its content), but did not help.
So the layout hierarchy looks like this (with more details and with "..." I replaced series of "normal" layouts):
NavHost -> ... -> AnimatedVisibility -> ... -> BoxWithConstraints with sharedElement -> some content
\> ... -> AnimatedVisibility -> ... -> LazyList -> ... -> Animated Visibility -> Selection container -> BoxWithConstraints with sharedElement -> some content
Any ideas?
I also tried moving sharedElement to BoxWithConstraints (rather than in its content), but did not help.
So the layout hierarchy looks like this (with more details and with "..." I replaced series of "normal" layouts):
NavHost -> ... -> AnimatedVisibility -> ... -> BoxWithConstraints with sharedElement -> some content
\> ... -> AnimatedVisibility -> ... -> LazyList -> ... -> Animated Visibility -> Selection container -> BoxWithConstraints with sharedElement -> some content
Any ideas?
jb...@google.com <jb...@google.com> #3
In your BoxWithConstraints
do you do any conditional composition? Things like:
if (constraintsExceedsCertainThreshold) composeSomeContent() else someOtherContent()
da...@sucharda.cz <da...@sucharda.cz> #4
No, it's just a `Text` which has different style depending on constraints.
Also note `sharedElement` is put on `BoxWithContraints` now, not on the content.
Thanks!
Also note `sharedElement` is put on `BoxWithContraints` now, not on the content.
Thanks!
da...@sucharda.cz <da...@sucharda.cz> #5
Based on the stacktrace, it seems like the item in question is composed but never placed. Do you use custom precompose
or prefetch logic in your lazy list?
jb...@google.com <jb...@google.com>
cl...@google.com <cl...@google.com> #6
No, nothing custom. Just the default prefetch logic.
There is also one `AnimatedContent` above the `BoxWithConstraints`. Could this cause issues?
Thank you for looking into this.
There is also one `AnimatedContent` above the `BoxWithConstraints`. Could this cause issues?
Thank you for looking into this.
ap...@google.com <ap...@google.com> #7
The AnimatedContent never skips measuring/placing children after it composes them. So I don't expect that to be the issue.
Since you mentioned the modifier is on BoxWithConstraints
rather than on the children of BoxWithConstraints
, my guess is it's most likely related to LazyList.
Can you clarify what type of LazyList you are using? Is it LazyColumn/Row or LazyGrid, or something else?
pr...@google.com <pr...@google.com> #8
Makes sense, thanks.
It's a LazyColumn.
It's a LazyColumn.
Description
Component used: Navigation
Version used: 2.5.1 and 2.5.2
Last known working version: 2.3.5
Devices/Android versions reproduced on: Huawei P20 Light / AN 9 (EMUI 9.1.0)
So our navigation is kinda complex so I will try to simplify the configuration. If there is a nested graph with arguments which cannot be null (and no default value is supplied) and
popUpTo
is used to remove nested graph during destination (nested) navigation it tries to recreate nested graph as a parent for the destination being navigated to.So now if the navigation is triggered like this:
It will pop fragments from back stack, but it will not change parent for
ChildFragment2
which will be set tochildNavGraph
and since it is not in the back stack anymore it will try to recreate it with default values. ButargumentLong
is not nullable and has no default value so it will crash:Note: Interesting thing is that it does not crash with non-nullable String argument for some reason (ah I see, it is because String NavType is nullable by default:
StringType: NavType<String?>
vsLongType: NavType<Long>
).Possible fixes for us:
popUpTo
to pop parent (navGraph) of a Fragment (node) from XML but usepopBackStack
from code instead.argumentLong
.Basically I am not sure if this an intended behavior or a bug. Gonna mark it as a bug because it worked in 2.3.5. I understand that Destination should have a parent but what is the reason to create a parent that does not exist and will never be displayed in this case, since it was already poped and thus it should not be displayed to the user.
At the moment two solutions come to mind:
LongType
and other types nullable same asStringType
. Again not sure if this can be done and it probably is not a proper solution (change).There might of course be other solutions that I cannot see.
Thank you for your time and help.