Files
amethyst/commons
Vitor PamplonaandClaude Opus 5 9c38240e3e perf(polls): make the results screen scroll like the rest of the app
Scrolling the results page cost 250ms per frame against 42ms on the home feed —
same debug build, same device, same swipe — with twelve rows and barely a
screenful of content. Every janky frame was Slow UI thread; the GPU never went
above 7ms, and the page renders one frame in eight seconds when left alone, so
all of it was composition work provoked by scrolling.

Three causes, measured one at a time.

The summary was list content. Header, option bars and chips each sat in their
own `item {}`, so scrolling disposed and rebuilt the whole block — nine
user-observing composables and two bar animations restarted — every time it left
and re-entered the viewport. It is one static block above a list, so it now sits
above the list, and the LazyColumn holds only voters.

The first `build()` ran on the composition thread. `uiState` is `flowOn(Default)`,
but `stateIn`'s initialValue was an eager build: it sorted every voter and
materialised every row synchronously wherever the ViewModel was constructed. Fine
at twelve voters, not fine on the thousand-voter poll this screen exists for. The
initial value is now a placeholder and `hasTally` keeps the footer from reading it
as a poll with no votes.

The voter row carried a NIP-05 line. `UserLine` is the app's short-list row — the
mention picker, follow import — and its supporting slot opens a third per-row
observer and a verified NIP-05 lookup for a list of people the reader has mostly
never met. The row is now the same `SlimListItem` primitive with avatar, name and
the vote, which is what the screen is for.

    scrolling, median frame / 90th        before    after
    poll results                          250ms     38ms      (550 -> 77)
    home feed, for scale                   42ms     42ms      (73)

The NIP-05 line is the one thing lost here, and it was worth 60ms a frame on its
own (97ms with it, 38ms without, after the other two fixes). Putting it back is
one call site if identity disambiguation matters more than the scroll.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 21:13:11 -04:00
..