Skip to content

Render lazy-stack on Android with a LazyColumn - #216

Merged
simonhamp merged 2 commits into
feat/lazy-stackfrom
feat/lazy-stack-android
Nov 19, 2026
Merged

simonhamp merged 2 commits into
feat/lazy-stackfrom
feat/lazy-stack-android

Conversation

@simonhamp

Copy link
Copy Markdown
Member

The Android renderer for <native:lazy-stack>, as a Compose LazyColumn. Stacked on the iOS PR, so merge that first.

  • Children are keyed by node id.
  • gap-* sets the spacing between rows, content-padding becomes contentPadding, and p-* and bg-* work as on any element.
  • shows-indicators does nothing, since LazyColumn has no scrollbar.
  • When you're scrolled down, rows added above keep your place. When you're at the very top, LazyColumn would also hold its place and the new rows would land out of sight, so the renderer scrolls back to the top when you were there.
  • Inside a scroll view it falls back to a plain column, like lazy_grid.
  • The manifest now points Android at this renderer instead of ScrollViewRenderer.

Numbers

Heimdall firehose on an API 35 emulator, 60 rows a second for 60 seconds:

  • At the top: 59 to 60 updates a second for the first 40 s, 56 to 58 after. Frame time p50 17 ms.
  • Scrolled down: 58 to 59 updates a second, frame time p50 17 ms, p99 22 ms. The visible rows stayed put.

Worth checking

  • Not run on a real Android phone.
  • The slower last 20 s at the top lined up with slower parsing, which points at emulator load, but that isn't confirmed.

Tests: 4 new Robolectric tests. The existing list tests and the 501 PHP tests pass.

🤖 Generated with Claude Code

simonhamp and others added 2 commits November 15, 2026 15:28
Android pointed lazy_stack at the scroll view renderer as a stopgap, which
ignored content-padding. LazyStackRenderer replaces it and matches iOS:

- children are keyed by node id
- gap-* becomes the column's spacing
- p-* and bg-* come in on the modifier like any element
- content_padding_* becomes the LazyColumn's contentPadding
- shows-indicators is accepted but does nothing, since a LazyColumn has
  no scroll indicator

A LazyColumn keeps the first visible child in place by key when children
are added above it, which is right for a reader scrolled down. It does that
at the very top too, so new rows would land above the screen. The renderer
checks during composition, before the new children are measured, whether the
reader was at the top, and if so asks for the top again with
requestScrollToItem(0).

Inside a scroll view the height is unbounded and a LazyColumn would throw,
so it falls back to a plain column, like the lazy grid does.

On an API 35 emulator with the heimdall firehose (60 rows a second, capped
at 1,000), the main thread applied 56 to 60 updates a second for the whole
minute, before and after the cap, with new rows showing at the top. Scrolled
down, the rows on screen stayed put until they were trimmed off the end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pint reads a docblock line starting with @ as a phpdoc tag, so the
@foreach/@Endforeach in the example tripped phpdoc_separation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simonhamp
simonhamp merged commit 2ce095f into feat/lazy-stack Nov 19, 2026
4 checks passed
@simonhamp
simonhamp deleted the feat/lazy-stack-android branch November 19, 2026 21:52
simonhamp added a commit that referenced this pull request Nov 19, 2026
* Add native:lazy-stack, a lazily drawn vertical scroll

A new element for long feeds that change often. On iOS it is a ScrollView
with a LazyVStack, and each child is identified by its node id.

native:list is a SwiftUI List, and a List gets slower with every row
inserted into it. In the heimdall firehose (60 keyed inserts a second,
capped at 1,000 rows) a List update cost about 10 ms after 100 inserts and
250 to 600 ms once full. The same rows in a lazy stack stayed at about
5.5 ms of main-thread time per update and 60 fps through 3,600 inserts on
the simulator.

It is deliberately small: children, gap-* spacing, the usual padding and
background, a content-padding attribute that pads the scrolled content,
and shows-indicators. No separators, swipe actions, pull-to-refresh,
sections or row callbacks. native:list is unchanged.

A child added above the screen doesn't move what the reader is looking
at: scrollPosition keeps the top child in place. A reader at the very top
is scrolled back to the top so new children show.

Android has no renderer of its own yet. The manifest points it at the
scroll view's renderer, which ignores content-padding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep Blade directives out of the LazyStack docblock

Pint reads a docblock line starting with @ as a phpdoc tag, so the
@foreach/@Endforeach in the example tripped phpdoc_separation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Render lazy-stack on Android with a LazyColumn (#216)

* Draw native:lazy-stack with a LazyColumn on Android

Android pointed lazy_stack at the scroll view renderer as a stopgap, which
ignored content-padding. LazyStackRenderer replaces it and matches iOS:

- children are keyed by node id
- gap-* becomes the column's spacing
- p-* and bg-* come in on the modifier like any element
- content_padding_* becomes the LazyColumn's contentPadding
- shows-indicators is accepted but does nothing, since a LazyColumn has
  no scroll indicator

A LazyColumn keeps the first visible child in place by key when children
are added above it, which is right for a reader scrolled down. It does that
at the very top too, so new rows would land above the screen. The renderer
checks during composition, before the new children are measured, whether the
reader was at the top, and if so asks for the top again with
requestScrollToItem(0).

Inside a scroll view the height is unbounded and a LazyColumn would throw,
so it falls back to a plain column, like the lazy grid does.

On an API 35 emulator with the heimdall firehose (60 rows a second, capped
at 1,000), the main thread applied 56 to 60 updates a second for the whole
minute, before and after the cap, with new rows showing at the top. Scrolled
down, the rows on screen stayed put until they were trimmed off the end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep Blade directives out of the LazyStack docblock

Pint reads a docblock line starting with @ as a phpdoc tag, so the
@foreach/@Endforeach in the example tripped phpdoc_separation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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