Hii, Im facing this Crash - iOS fatal: `ArrayIndex...
# compose-ios
s
Hii, Im facing this Crash - iOS fatal:
ArrayIndexOutOfBoundsException
in LazyStaggeredGridMeasure during LookaheadPass with StaggeredGridCells.Adaptive inside AnimatedPane 50+ crashes for 41 users in the last 7 days
We're hitting a fatal crash in production on iOS (Compose Multiplatform 1.10.1, Compose Foundation 1.10.1):
Copy code
kotlin.ArrayIndexOutOfBoundsException at LazyStaggeredGridMeasure.kt:269
Setup: - LazyVerticalStaggeredGrid(columns = StaggeredGridCells.Adaptive(150.dp)) - Hosted in ListDetailPaneScaffold -> AnimatedPane - Crash commonly occurs on back navigation (Detail -> Home) Top of stack:
Copy code
ThrowArrayIndexOutOfBoundsException (RuntimeUtils.kt:41)
  LazyStaggeredGridMeasure.measure (LazyStaggeredGridMeasure.kt:269)
  rememberStaggeredGridMeasurePolicy (LazyStaggeredGridMeasure.kt:184)
  LazyLayout (Composer.kt:189)
  InnerNodeCoordinator.LookaheadDelegateImpl.measure (MeasurePolicy.kt:88)
  CupertinoOverscrollNode.measure (Measurable.kt:30)
  LayoutModifierNodeCoordinator.LookaheadDelegateForLayoutModifierNode.measure
  LookaheadPassDelegate.remeasure (OwnerSnapshotObserver.kt:138)
  LookaheadPassDelegate.measure (LookaheadPassDelegate.kt:404)
  BoxMeasurePolicy.measure (Measurable.kt:30)
No app code at throw site, entirely within Compose framework. Questions: 1) Is this a known issue for LookaheadScope + LazyVerticalStaggeredGrid + Adaptive columns on iOS? 2) Is there an existing issue ID / planned fix? 3) Should staggered grid measure guard lane-count changes across lookahead/actual passes?
m
this issue comment seems to resemble your situation, though the poster declined to provide a reproducible sample
👀 1
s
Hey @Mark Murphy, thanks for pointing us to that issue comment. That's exactly our situation. We investigated the root cause and found it's a measurement race: Adaptive computes the column count per pass, and LookaheadScope (from AnimatedPane) runs two passes with different widths during animation. When those widths cross a column-count boundary, the lane arrays go out of sync → ArrayIndexOutOfBoundsException. We applied the workaround from that thread, replacing
Adaptive
with
Fixed(N)
computed via BoxWithConstraints, so the lane count is determined once at composition time, not per measurement pass. Shipping it now and will keep an eye on crash reports post-release. We also added our findings to the issue tracker. Thanks again for the quick pointer!
👍🏻 1