Skip to content

Don't inherit the presenter's scroll axes into a presentation#477

Open
garthvh wants to merge 1 commit into
skiptools:mainfrom
garthvh:fix/presentation-scroll-axes
Open

Don't inherit the presenter's scroll axes into a presentation#477
garthvh wants to merge 1 commit into
skiptools:mainfrom
garthvh:fix/presentation-scroll-axes

Conversation

@garthvh

@garthvh garthvh commented Jul 10, 2026

Copy link
Copy Markdown

Problem

Presenting a .sheet whose content is a List (or any lazy container) from a button inside a ScrollView crashes on Android. It works fine on iOS.

java.lang.IllegalStateException: Asking for intrinsic measurements of SubcomposeLayout
layouts is not supported. This includes components that are built on top of
SubcomposeLayout, such as lazy lists, BoxWithConstraints, TabRow, etc.

and, on the path before the lazy content is reached, the intrinsic measurement (maxHeight == Constraints.Infinity) also overflows IgnoresSafeAreaLayout's expansion arithmetic:

java.lang.IllegalArgumentException: maxWidth must be >= than minWidth, ...
  at skip.ui.ComposeLayoutsKt$IgnoresSafeAreaLayout$...measure(ComposeLayouts.kt)

Cause

A presentation is a new layout root, but PresentationRoot left the presenter's _scrollAxes / _layoutScrollAxes in the environment. When the sheet is presented from within a ScrollView, ComposeFlexibleContainer then sizes expanding content in the sheet with Modifier.height(IntrinsicSize.Max) — the "fill in a scroll direction" path — as if the sheet were laid out in the presenter's scroll direction. Asking a List for its intrinsic height is what Compose forbids, hence the crash.

Fix

  • PresentationRoot: reset _layoutScrollAxes and _scrollAxes to empty at the presentation boundary, so the presentation lays out from a clean root and doesn't inherit an intrinsic-sizing regime from whatever presented it.
  • IgnoresSafeAreaLayout: guard the safe-area expansion against an Infinity incoming constraint the same way the existing constraint(_:subtracting:) helper does (preserve Infinity, clamp to the min constraints), so any intrinsic measurement pass can't overflow Int into a negative maxWidth.

Reproduce

Present a sheet containing a List from a Button inside a ScrollView. Crashes on Android before this change; renders and scrolls after.

Verification

Built and run on an Android emulator: the sheet (including a sheet-presented-from-a-sheet, and a List with sub-rows) renders, scrolls, and dismisses cleanly. iOS behavior is unchanged. Related to #191, though that report is a genuinely-nested scroll case; this one is scroll-axis inheritance leaking across the presentation boundary.

A sheet (or other presentation) is a new layout root, but PresentationRoot
left the presenter's `_scrollAxes` / `_layoutScrollAxes` in the environment.
When a sheet is presented from inside a ScrollView, expanding content in the
sheet is then sized with `IntrinsicSize.Max` — as if it were laid out in the
presenter's scroll direction (ComposeFlexibleContainer). For a sheet whose
content is a List (or any lazy container) that intrinsic pass crashes:

    java.lang.IllegalStateException: Asking for intrinsic measurements of
    SubcomposeLayout layouts is not supported.

and, before reaching the lazy content, the intrinsic constraint (maxHeight ==
Constraints.Infinity) also overflows IgnoresSafeAreaLayout's expansion
arithmetic:

    java.lang.IllegalArgumentException: maxWidth must be >= than minWidth

Reset both scroll-axis environment values at the presentation boundary so the
sheet lays out from a clean root, and guard IgnoresSafeAreaLayout's expansion
against the Infinity constraint the same way the existing
`constraint(_:subtracting:)` helper does (preserve Infinity, clamp to the
mins) so an intrinsic measurement can never overflow it.

Repro: present a sheet containing a List from a button inside a ScrollView;
it crashes on Android (fine on iOS). Related to skiptools#191.
@cla-bot

cla-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to the Skip community. We require contributors to sign our contributor license agreement (CLA), and we don't seem to have the user(s) @garthvh on file. In order for us to review and merge your code, for each noted user please add your GitHub username to Skip's .clabot file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant