e4e9eb0928becfa4e48484dde85ef5032671d582
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5a0e0378c0 |
plugins: Discover draws only the cards near the view in a long list
The owner, 11-13: "这个页面有点卡,记得做列表虚拟化" (Plugins › Discover with Subscriptions picked, 369 cards). Every redraw of Discover's body (npm's numbers coming in, a count changing) made all of them again. A grid of 48 cards or more (a kind picked, a search that matches hundreds, npm's hits) now draws only its rows near the view, 700px past each edge, and keeps the whole list's height in its padding above and below. The rows follow the scroll and the width (a ResizeObserver on the page): columns are read from the grid's own computed columns, so narrow widths and every language lay out as before. Row heights are measured as they are drawn. A card with focus stays in the page, held where it would be, so keys go on from it. Cards are made once per list and kept, so a click lands on the same node. A list shorter than 48 is drawn whole, as before. The code is in plugingrid.js, imported when Plugins first draws, so the core doesn't grow: TestCoreScriptBudget was 3,299 bytes over with it in plugins.js. Until the import lands, a long list is drawn whole, and the body is drawn again once it has. Measured with plugin-discover-virtual.test.cjs's PERF=1 on mote (load ~25 to 55, so the times are high). The time is from the Subscriptions click to the cards drawn, with a market of 503 plugins (370 subscriptions). - Before (origin/main): chromium 69.0ms at 1180px and 56.5ms at 420px, webkit 77ms and 74ms. 370 cards and 9,312 nodes in #view-plugins. - After: chromium 6.2 to 9.7ms, webkit 10 to 13ms. 30 cards and 810 nodes at 1180px, 10 cards and 312 nodes at 420px (de: 9 and 285). Guard: plugin-discover-virtual.test.cjs (new), in chromium and webkit, in en, zh, zh-TW, ja and de, at 1180px and 420px. It checks: - at most 72 cards are drawn, and the list keeps its whole height; - wheeling to the middle never shows an empty stretch, and the focused card is kept; - at the bottom pv-369 is in view and its Install posts its spec; - "pv-12" lists all 11 matches, and "pv" draws at most 72; - nothing scrolls sideways, and there are no page errors. Broken by hand: VMIN at 1e9 (every list drawn whole) turned it 22 of 22 red. Run on mote at this tree, before the rebase (mote-run): - go test ./internal/gui: ok (the budget too). gofmt -l: nothing. - plugin-discover-virtual: 22 of 22. - Every GUI file that draws plugin cards or Plugins (the 54 that grep finds pm-card, view=plugins or pluginAgentsTo), with i18n-keys and i18n-en-no-cjk: all pass, except the reds below. Reds, the same at origin/main |