Skip to content

[WEB] Scrollbar oscillation cause infinite layout loop #2334

Description

@VickyStash

Description

On web with classic (non-overlay) scrollbars — i.e. Windows/Linux Chrome and macOS with "Always show scroll bars", FlashList v2 can enter an infinite layout loop and crash with Maximum update depth exceeded because the vertical scrollbar's own appearance/disappearance feeds back into the list's cross-axis (width) measurement.

When list content height sits right at the threshold where it just barely overflows the viewport, the browser shows a vertical scrollbar. The scrollbar consumes ~15–17px of width, which reduces the measured client width FlashList uses as boundedSize. The narrower width re-flows items so the content no longer overflows → the scrollbar is removed → the measured width grows back → content overflows again → the scrollbar returns → and so on, forever.

This is web-specific: native platforms use overlay scrollbars that don't consume layout width, so they never oscillate.

Current behavior

  • The list rapidly re-lays-out, the scrollbar visibly flickers, and React throws Maximum update depth exceeded (setState loop in updateLayoutParams → recompute layout → measure → updateLayoutParams …), crashing the app.
  • Happens whenever content size is near the boundary at which adding/removing the scrollbar flips whether the content overflows.

Expected behavior

FlashList should not let the scrollbar's own width feedback-loop the layout.

Reproduction

Expo Snack or minimal reproduction link:

Make sure to test on web with classic (non-overlay) scrollbar. If you use MacOS fo to Settings -> Appearance -> Windows -> Show scroll bars -> Always.

https://snack.expo.dev/@vikstash/flashlist_loop_crash

Platform

  • iOS
  • Android
  • Web (if applicable)

Environment

React Native info output:
Paste output here

FlashList version:
2.3.0

Additional context

Root cause is in LinearLayoutManager.ts, method updateLayoutParams. boundedSize is taken directly from the measured window size with no detection of scrollbar-induced oscillation, so the scrollbar appearing/disappearing keeps changing the measured width and re-triggering layout.

Checklist

  • I've searched existing issues and couldn't find a duplicate
  • I've provided a minimal reproduction (Expo Snack preferred)
  • I'm using the latest version of @shopify/flash-list
  • I've included all required information above

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions