https://kotlinlang.org logo
#compose
Title
# compose
s

sindrenm

11/26/2021, 8:33 AM
Has anyone here experienced
View.measure
crashes in Accompanist (probably accompanist-pager) starting on v0.19.0? Suspect it comes from the refactor to using a
LazyList
introduced in that version, and we're seeing it across multiple devices in production, but we're unable to reproduce it locally, and we're a little lost on how to debug this. 😅 GitHub issue: https://github.com/google/accompanist/issues/847
👍🏼 1
👍 3
a

Albert Chang

11/26/2021, 9:53 AM
SizeModifier
appears in the stack trace but Pager doesn't seem to use any size modifiers. Are you using size modifiers (`Modifier.size()`/`Modifier.width()`/`Modifier.height()` or those with
required
) which constrain the same axis as Pager in your code? If so, can you post it?
z

Zoltan Demant

11/26/2021, 9:59 AM
I saw a lot of this earlier on, no longer the case though - using
0.21.3-beta
(not sure if I accidentally fixed it locally, or the updates did). Care to share some code?
s

Stylianos Gakis

11/26/2021, 10:07 AM
We experienced this exact problem too when the code looked like this on accompanist 0.20.0. It hasn’t appeared yet after we’ve downgraded to 0.18.0 on this commit but I’m keeping an eye on it. Mentioned here that we only got it however on a very specific API-device combo, worked fine on all the other devices I tried it on, even on another Android 9 Samsung device.
l

Lucien Guimaraes

11/26/2021, 10:14 AM
Mentioned here that we only got it however on a very specific API-device combo, worked fine on all the other devices I tried it on, even on another Android 9 Samsung device.
That's strange, for me the issue is also on Android 11 / 10 / 8.1.0 and on many devices. Here's some screenshots of the issue from Sentry (before I rollback to Accompanist 0.18.0).
🤔 1
a

Albert Chang

11/26/2021, 10:44 AM
It turns out that Pager does use size modifier and the crash is happening during the measurement of `Modifier.fillParentMaxWidth()`/`Modifier.fillParentMaxHeight()` here. However I have no idea why.
l

Lucien Guimaraes

11/26/2021, 11:31 AM
Two days ago they changed this part to fix some issue with measurements here. Wondering if this will fix the issue 🤔
s

sindrenm

11/26/2021, 11:31 AM
But it should be okay to use `fillParentMaxWidth()`/`fillParentMaxHeight()`, though, shouldn't it? I sort of get why this could happen if one used `fillMaxWidth()`/`fillMaxHeight()`, since the lazy lists have infinite width/height, but that's not the case here. Also, there are even checks in Compose's layout measuring to see if the size is
Infinity
(
== Int.MAX_VALUE
), in which case it should use the
minWidth
instead. In our crashes, we're seeing
Int.MAX_VALUE - 127
, however.
a

Albert Chang

11/26/2021, 1:51 PM
Yeah it should be ok, and that’s why it’s a bug.
s

sindrenm

11/26/2021, 2:33 PM
Ahh, like that! 😅
3 Views