Emoji picker: keep pictures in view, ask for picker emoji at 48 px (#619) #625

Merged
charles merged 1 commit from fix/619-picker-flicker into textchat 2026-11-15 09:35:26 +00:00
Owner

Cause

Since 292a6706 ("Play animated emoji in the expression picker", first shipped in nightly 291), the picker plays the animated custom emoji in view. Its 40 px cells built their URLs with emoji::url, which gives the 240 px enlarged rung to anything over 24 px (widgets/emoji.rs, url). That is 225 KiB a frame, about 8.8 MiB for a 40-frame animated emoji. A section of animated emoji in view then wants several times the image store's 96 MiB (images::DEFAULT_MAX_BYTES).

Images::store (crates/fluxer-ui/src/images.rs) made room for each arrival by evicting the least recently requested entries. Those were the other pictures on screen, the guild icons of the picker's rail and of the app's community rail among them. The next request pass (App::request_images, on every hover, scroll or snapshot) asked for them again, their arrival evicted others, and so it went on with no end. That explains the screenshot: random empty cells in one frame, images missing all over the app, rail icons flipping between picture and initials.

Reproduction (reaction picker, community of 72 custom emoji, half animated, fake proxy answering at the URL's size with 40 frames): 156 of the 166 wanted pictures are missing on every frame and all 156 are loaded again, with the store pinned at its budget (87.9 MiB). It looks the same with the cursor still (frames come from snapshots), while hovering cells, and while scrolling.

Bisect, using the same test: nightly 290 (c24495a) passes. 291 (bea187b), 297 (2e1825b), 304 (dc426c1) and 307 (3208c85) all fail. PR #540 (#535, wanted_animated for quick reactions) is not the cause: it adds at most a few 128 px URLs while a message is hovered or its menu is open, and it does not change what the picker asks for. PR #608 does not touch the picker's images.

Fix

  • Picker emoji at 48 px, as in the web picker (EMOJI_PICKER_CUSTOM_EMOJI_SIZE = 48, EmojiRenderer.tsx). New emoji::url_at / emoji::view_at take the rung explicitly, and the grid's cells use emoji_grid::EMOJI_RUNG. A 40-frame animated emoji is now 360 KiB, and the same screen wants 15 MiB. The inspector is unchanged. As before, the grid animates every animated emoji when "Animate emoji" is on, which is what the original does (useShouldAnimate({kind: 'emoji'})).
  • The store never evicts what is in view. The shell asks for the screen's whole set with the new Images::request_all. A load can then evict only entries outside that set. If what is in view does not fit, the budget gives way and the view does not. A late load of an image that is no longer in view and does not fit is dropped.

Tests

  • crates/fluxer-ui/tests/picker_images.rs runs the shell's request pass (media::wanted → request_all → loads answered one frame later) over 30 frames, in three cases: still, hovering cells, scrolling. It asserts: no reloads, nothing wanted is missing, the same cells draw every frame (still and hovering), no loads at all once settled (still), and the store stays within its budget. It fails on 291, 297, 304 and 307 and passes on 290. With only the store change (rung back at 240) it still fails on the budget check.
  • images::tests::images_in_view_are_never_evicted_and_the_rest_gives_way.
  • tests/message_actions.rs (including animated_quick_reactions_play) and tests/expression_picker.rs pass. The emoji_picker* goldens are unchanged.
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: all steps passed.

Not reproduced headlessly: the black band across the grid in the screenshot (it would need the GPU). It is probably a side effect of the same churn, since every reload makes new image handles to upload. The real fluxer-platform loader was not exercised: its 64 MiB memory tier was also smaller than the set, so each reload read from disk and decoded again.

Refs #619

🤖 Generated with Claude Code

## Cause Since 292a6706 ("Play animated emoji in the expression picker", first shipped in nightly **291**), the picker plays the animated custom emoji in view. Its 40 px cells built their URLs with `emoji::url`, which gives the 240 px *enlarged* rung to anything over 24 px (`widgets/emoji.rs`, `url`). That is 225 KiB a frame, about **8.8 MiB for a 40-frame animated emoji**. A section of animated emoji in view then wants several times the image store's 96 MiB (`images::DEFAULT_MAX_BYTES`). `Images::store` (`crates/fluxer-ui/src/images.rs`) made room for each arrival by evicting the least recently requested entries. Those were the other pictures on screen, the guild icons of the picker's rail and of the app's community rail among them. The next request pass (`App::request_images`, on every hover, scroll or snapshot) asked for them again, their arrival evicted others, and so it went on with no end. That explains the screenshot: random empty cells in one frame, images missing all over the app, rail icons flipping between picture and initials. Reproduction (reaction picker, community of 72 custom emoji, half animated, fake proxy answering at the URL's size with 40 frames): **156 of the 166 wanted pictures are missing on every frame and all 156 are loaded again**, with the store pinned at its budget (87.9 MiB). It looks the same with the cursor still (frames come from snapshots), while hovering cells, and while scrolling. Bisect, using the same test: nightly 290 (c24495a) passes. 291 (bea187b), 297 (2e1825b), 304 (dc426c1) and 307 (3208c85) all fail. PR #540 (#535, `wanted_animated` for quick reactions) is not the cause: it adds at most a few 128 px URLs while a message is hovered or its menu is open, and it does not change what the picker asks for. PR #608 does not touch the picker's images. ## Fix - **Picker emoji at 48 px, as in the web picker** (`EMOJI_PICKER_CUSTOM_EMOJI_SIZE = 48`, `EmojiRenderer.tsx`). New `emoji::url_at` / `emoji::view_at` take the rung explicitly, and the grid's cells use `emoji_grid::EMOJI_RUNG`. A 40-frame animated emoji is now 360 KiB, and the same screen wants 15 MiB. The inspector is unchanged. As before, the grid animates every animated emoji when "Animate emoji" is on, which is what the original does (`useShouldAnimate({kind: 'emoji'})`). - **The store never evicts what is in view.** The shell asks for the screen's whole set with the new `Images::request_all`. A load can then evict only entries outside that set. If what is in view does not fit, the budget gives way and the view does not. A late load of an image that is no longer in view and does not fit is dropped. ## Tests - `crates/fluxer-ui/tests/picker_images.rs` runs the shell's request pass (`media::wanted` → `request_all` → loads answered one frame later) over 30 frames, in three cases: still, hovering cells, scrolling. It asserts: no reloads, nothing wanted is missing, the same cells draw every frame (still and hovering), no loads at all once settled (still), and the store stays within its budget. It fails on 291, 297, 304 and 307 and passes on 290. With only the store change (rung back at 240) it still fails on the budget check. - `images::tests::images_in_view_are_never_evicted_and_the_rest_gives_way`. - `tests/message_actions.rs` (including `animated_quick_reactions_play`) and `tests/expression_picker.rs` pass. The `emoji_picker*` goldens are unchanged. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci`: all steps passed. Not reproduced headlessly: the black band across the grid in the screenshot (it would need the GPU). It is probably a side effect of the same churn, since every reload makes new image handles to upload. The real `fluxer-platform` loader was not exercised: its 64 MiB memory tier was also smaller than the set, so each reload read from disk and decoded again. Refs #619 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The owner's report: in the emoji picker opened to add a reaction, almost
every icon flickers and images disappear across the app (community rail
too).

Cause: since 292a6706 (nightly 291) the picker plays the animated custom
emoji in view. Its 40 px cells asked for them through emoji::url, which
gives the 240 px "enlarged" rung to anything over 24 px: 225 KiB a frame,
about 9 MiB for a 40-frame emoji. A section of animated emoji in view then
wants several times the image store's 96 MiB. Images::store evicted the
least recently requested entries to fit each arrival, and those were the
other pictures on screen (and the guild icons of the rails), so the next
request pass (every hover, scroll or snapshot) asked for them again, whose
arrival evicted others, and so on forever. In the reproduction, 156 of 166
wanted pictures are missing on every frame and all 156 are reloaded.

Fix:
- The picker's cells ask for custom emoji at 48 px, as the web picker does
  (EMOJI_PICKER_CUSTOM_EMOJI_SIZE, EmojiRenderer.tsx): emoji::url_at and
  emoji::view_at take the rung explicitly; emoji_grid::EMOJI_RUNG. A
  40-frame animated emoji is now 360 KiB; the same screen wants 15 MiB.
- Images never evicts an image the screen asks for now: the shell asks for
  the whole set with Images::request_all, and a load evicts only entries
  not in that set. When what is in view does not fit, the budget gives way
  rather than the view; a late load of an image no longer in view that does
  not fit is dropped.

Tests: tests/picker_images.rs drives the shell's request pass
(media::wanted, request_all) against a fake proxy that answers at the
URL's size (40 frames for animated) with the reaction picker on a community
of 72 custom emoji, half animated: still, hovering cells, scrolling. Before
(nightlies 291, 297, 304, 307) all three fail with 156 reloads a frame; on
290 they pass. images::tests::images_in_view_are_never_evicted_and_the_rest_gives_way
covers the store.

Refs #619

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
charles merged commit 983a900d8d into textchat 2026-11-15 09:35:26 +00:00
Sign in to join this conversation.
No description provided.