feat(picker): small previews, a search across all packs and an index the browser keeps #16

Merged
dawid merged 1 commit from perf-usability into main 2026-11-28 20:33:22 +00:00
Owner

The picker was heavy and its search narrow. This makes it lighter and finds more, and the
server's extra cost is one-time.

What was measured

  • The images: the picker's cells are 64 px, but it loaded the packs' originals.
    • Fluent's are 256 px PNGs, and Noto's and OpenMoji's 512–618 px PNGs, at 20–40 KB each.
    • Animated Noto's are 512 px WebPs of 190–620 KB. One page of 120 was about 40 MB, and
      the browser had to decode 120 large animations at once.
    • Google serves the animations at 512 px only, so smaller ones must be made here.
  • The catalogue: /api/packs carried every sticker's name and keywords of all five packs
    on every page load, without HTTP caching, read from app data (S3 in the homelab) each time.
  • Search looked only in the open tab: Recent for anyone who had sent a sticker.

What changes

  • Previews (lib/Packs/Thumbnail.php): a 128 px still WebP beside each large original
    (<id>.thumb.webp), from the first frame of an animated one.
    • Made with Imagick, which must write WebP. An SVG, or an original under 12 KB, gets none,
      as it costs no more than a preview would.
    • Measured on real stickers (Nextcloud 35's Imagick): 1,882 KB of samples become 40 KB.
      Animated stickers are 2–4 KB instead of 190–620 KB, so a page of animated stickers is
      about 0.4 MB instead of 40 MB
      . Static ones are 3–7 KB instead of 20–40 KB.
    • The picker shows the preview. An animated sticker plays its original while the pointer is
      on it or it has the focus; the sticker sent is the original.
    • New builds make the previews. Existing builds get them from a background job,
      MakeThumbnails, which the update's repair step queues. It reads the images already there,
      so nothing is downloaded, and it takes about half an hour of one CPU (about 0.5 s per
      animated sticker). occ talk_stickers:packs --thumbnails does it at once.
    • Without Imagick with WebP, the picker shows the originals as before.
  • The index, cached: /api/packs now carries only the person's own packs and the address
    /api/index/<build>.
    • That address names the build, so it is served with
      Cache-Control: public, max-age=31536000, immutable, and the browser downloads it once per
      build. An old build's address redirects to the current one.
  • Search across all packs: typing searches every tab, the open one first, each sticker once.
    • Recent repeats stickers of the packs, so a sticker found in both is shown once.
    • Recent also keeps the preview and whether the sticker is animated.

Tests

  • On a real Nextcloud 35 (nextcloud-app-server, the extended tests/server/check.sh):
    • the catalogue names the index, and the index comes with
      public, max-age=31536000, immutable;
    • 1f600.thumb.webp is served as image/webp, 3,544 bytes (its original is 25 KB);
    • the image, the sent sticker's link and the page for phones still work.
  • PHPUnit: 24 tests.
    • ThumbnailTest and ThumbnailsForOldBuildsTest run with Imagick, in Nextcloud 35's image,
      and are skipped in CI's PHP image.
    • ThumbnailsForOldBuildsTest checks that an old build gets its previews once and that small
      and SVG stickers get none.
    • IndexTest checks the index's caching, its redirect and the 404 before a build.
  • composer cs:check, Psalm, node --check, tests/l10n.js (no new strings), markdownlint.

Cost

  • Storage: some 70 MB more in app data, for about 18,000 previews of 3–5 KB.
  • CPU: about half an hour of one CPU once (the job, or in each new build).
  • Then: far less traffic and decoding on every picker opening, and far fewer image requests
    through PHP and S3.
The picker was heavy and its search narrow. This makes it lighter and finds more, and the server's extra cost is one-time. ## What was measured - **The images:** the picker's cells are 64 px, but it loaded the packs' originals. - Fluent's are 256 px PNGs, and Noto's and OpenMoji's 512–618 px PNGs, at 20–40 KB each. - **Animated Noto's are 512 px WebPs of 190–620 KB.** One page of 120 was about **40 MB**, and the browser had to decode 120 large animations at once. - Google serves the animations at 512 px only, so smaller ones must be made here. - **The catalogue:** `/api/packs` carried every sticker's name and keywords of all five packs on every page load, without HTTP caching, read from app data (S3 in the homelab) each time. - **Search** looked only in the open tab: *Recent* for anyone who had sent a sticker. ## What changes - **Previews** (`lib/Packs/Thumbnail.php`): a 128 px still WebP beside each large original (`<id>.thumb.webp`), from the first frame of an animated one. - Made with Imagick, which must write WebP. An SVG, or an original under 12 KB, gets none, as it costs no more than a preview would. - Measured on real stickers (Nextcloud 35's Imagick): 1,882 KB of samples become **40 KB**. Animated stickers are 2–4 KB instead of 190–620 KB, so **a page of animated stickers is about 0.4 MB instead of 40 MB**. Static ones are 3–7 KB instead of 20–40 KB. - The picker shows the preview. An animated sticker plays its original while the pointer is on it or it has the focus; the sticker sent is the original. - New builds make the previews. Existing builds get them from a background job, `MakeThumbnails`, which the update's repair step queues. It reads the images already there, so nothing is downloaded, and it takes about half an hour of one CPU (about 0.5 s per animated sticker). `occ talk_stickers:packs --thumbnails` does it at once. - Without Imagick with WebP, the picker shows the originals as before. - **The index, cached:** `/api/packs` now carries only the person's own packs and the address `/api/index/<build>`. - That address names the build, so it is served with `Cache-Control: public, max-age=31536000, immutable`, and the browser downloads it once per build. An old build's address redirects to the current one. - **Search across all packs:** typing searches every tab, the open one first, each sticker once. - *Recent* repeats stickers of the packs, so a sticker found in both is shown once. - *Recent* also keeps the preview and whether the sticker is animated. ## Tests - **On a real Nextcloud 35** (`nextcloud-app-server`, the extended `tests/server/check.sh`): - the catalogue names the index, and the index comes with `public, max-age=31536000, immutable`; - `1f600.thumb.webp` is served as `image/webp`, 3,544 bytes (its original is 25 KB); - the image, the sent sticker's link and the page for phones still work. - **PHPUnit:** 24 tests. - `ThumbnailTest` and `ThumbnailsForOldBuildsTest` run with Imagick, in Nextcloud 35's image, and are skipped in CI's PHP image. - `ThumbnailsForOldBuildsTest` checks that an old build gets its previews once and that small and SVG stickers get none. - `IndexTest` checks the index's caching, its redirect and the 404 before a build. - `composer cs:check`, Psalm, `node --check`, `tests/l10n.js` (no new strings), markdownlint. ## Cost - **Storage:** some 70 MB more in app data, for about 18,000 previews of 3–5 KB. - **CPU:** about half an hour of one CPU once (the job, or in each new build). - **Then:** far less traffic and decoding on every picker opening, and far fewer image requests through PHP and S3.
feat(picker): small previews, a search across all packs and an index the browser keeps
Some checks failed
CI / php (dev-master) (pull_request) Successful in 1m31s
CI / php (dev-stable35) (pull_request) Successful in 1m25s
CI / javascript (pull_request) Successful in 47s
CI / standards (pull_request) Successful in 1m34s
CI / server (32) (pull_request) Failing after 2m18s
CI / php (dev-stable32) (pull_request) Successful in 1m31s
CI / php (dev-stable34) (pull_request) Successful in 1m25s
CI / php (dev-stable33) (pull_request) Successful in 1m26s
CI / server (35) (pull_request) Failing after 2m36s
f7153591d1
dawid merged commit a9152c9183 into main 2026-11-28 20:33:22 +00:00
dawid deleted branch perf-usability 2026-11-28 20:33:23 +00:00

Tests of CI / php (dev-master): passed

21 passed, 0 failed, 3 skipped (24 tests, 0.0 s)

Of f7153591d1, the run, updated by every run.

<!-- ci-report tests: CI-php-dev-master- --> ### Tests of CI / php (dev-master): passed **21 passed, 0 failed, 3 skipped** (24 tests, 0.0 s) <sub>Of f7153591d1, [the run](https://git.ciepiela.org/dawid/nextcloud-talk-stickers/actions/runs/117), updated by every run.</sub>

Tests of CI / php (dev-stable32): passed

21 passed, 0 failed, 3 skipped (24 tests, 0.1 s)

Of f7153591d1, the run, updated by every run.

<!-- ci-report tests: CI-php-dev-stable32- --> ### Tests of CI / php (dev-stable32): passed **21 passed, 0 failed, 3 skipped** (24 tests, 0.1 s) <sub>Of f7153591d1, [the run](https://git.ciepiela.org/dawid/nextcloud-talk-stickers/actions/runs/117), updated by every run.</sub>

Tests of CI / php (dev-stable33): passed

21 passed, 0 failed, 3 skipped (24 tests, 0.1 s)

Of f7153591d1, the run, updated by every run.

<!-- ci-report tests: CI-php-dev-stable33- --> ### Tests of CI / php (dev-stable33): passed **21 passed, 0 failed, 3 skipped** (24 tests, 0.1 s) <sub>Of f7153591d1, [the run](https://git.ciepiela.org/dawid/nextcloud-talk-stickers/actions/runs/117), updated by every run.</sub>

Tests of CI / php (dev-stable34): passed

21 passed, 0 failed, 3 skipped (24 tests, 0.0 s)

Of f7153591d1, the run, updated by every run.

<!-- ci-report tests: CI-php-dev-stable34- --> ### Tests of CI / php (dev-stable34): passed **21 passed, 0 failed, 3 skipped** (24 tests, 0.0 s) <sub>Of f7153591d1, [the run](https://git.ciepiela.org/dawid/nextcloud-talk-stickers/actions/runs/117), updated by every run.</sub>

Tests of CI / php (dev-stable35): passed

21 passed, 0 failed, 3 skipped (24 tests, 0.0 s)

Of f7153591d1, the run, updated by every run.

<!-- ci-report tests: CI-php-dev-stable35- --> ### Tests of CI / php (dev-stable35): passed **21 passed, 0 failed, 3 skipped** (24 tests, 0.0 s) <sub>Of f7153591d1, [the run](https://git.ciepiela.org/dawid/nextcloud-talk-stickers/actions/runs/117), updated by every run.</sub>
Sign in to join this conversation.
No description provided.