From 4f1b8d95416db615aecc88c7cb65572641e8f345 Mon Sep 17 00:00:00 2001 From: benjcooley Date: Sun, 13 Sep 2026 10:24:17 -0700 Subject: [PATCH 1/9] test(website): reproduce catalogue download and offscreen video overhead --- apps/website/e2e/models-performance.spec.ts | 79 +++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 apps/website/e2e/models-performance.spec.ts diff --git a/apps/website/e2e/models-performance.spec.ts b/apps/website/e2e/models-performance.spec.ts new file mode 100644 index 00000000000..9e53e15193f --- /dev/null +++ b/apps/website/e2e/models-performance.spec.ts @@ -0,0 +1,79 @@ +import { expect } from '@playwright/test' + +import { test } from './fixtures/modelsAccount' + +test('catalogue browsing stays within its JavaScript budget', async ({ + page +}) => { + await page.goto('/models/') + await page.getByTestId('workshop-search').fill('kling') + await page.getByRole('heading', { level: 1 }).click() + await expect( + page + .getByTestId('workshop-models-grid') + .getByTestId('workshop-model-card') + .first() + ).toContainText('Kling') + const bytes = await page.evaluate(() => + performance.getEntriesByType('resource').reduce((total, entry) => { + if (!(entry instanceof PerformanceResourceTiming)) return total + const url = new URL(entry.name) + return url.origin === location.origin && url.pathname.endsWith('.js') + ? total + entry.decodedBodySize + : total + }, 0) + ) + expect(bytes).toBeGreaterThan(0) + expect(bytes).toBeLessThan(1_800_000) +}) + +test('video cards load on screen and stop playing when scrolled away', async ({ + page +}) => { + await page.goto('/models/') + await page.getByTestId('workshop-filter').click() + const videos = page.getByTestId('section-generate-videos').locator('video') + await expect.poll(() => videos.count()).toBeGreaterThan(0) + expect( + await videos.evaluateAll((elements) => + elements.every( + (video) => + video instanceof HTMLVideoElement && + video.currentSrc === '' && + video.paused + ) + ) + ).toBe(true) + + const first = videos.first() + await first.scrollIntoViewIfNeeded() + await expect + .poll(() => + first.evaluate( + (video) => + video instanceof HTMLVideoElement && + video.readyState >= 2 && + !video.paused + ) + ) + .toBe(true) + await page.getByRole('heading', { level: 1 }).scrollIntoViewIfNeeded() + await expect + .poll(() => + videos.evaluateAll((elements) => + elements.every( + (video) => video instanceof HTMLVideoElement && video.paused + ) + ) + ) + .toBe(true) + await page.emulateMedia({ reducedMotion: 'reduce' }) + await first.scrollIntoViewIfNeeded() + await expect + .poll(() => + first.evaluate( + (video) => video instanceof HTMLVideoElement && video.paused + ) + ) + .toBe(true) +}) From 0d3dc5d5051596ab5118e7028bb38a3d5af0a68a Mon Sep 17 00:00:00 2001 From: benjcooley Date: Sun, 13 Sep 2026 10:34:50 -0700 Subject: [PATCH 2/9] fix(website): bound model preview work and keep catalogue joins out of browser --- .fallowrc.jsonc | 2 + .../reviews/2026-09-13-models-performance.md | 43 ++++++++++ .../generate-template-model-join.test.ts | 2 +- .../scripts/generate-template-model-join.ts | 6 +- .../scripts/generate-workshop-versions.ts | 2 +- apps/website/scripts/test-router-models.ts | 6 +- apps/website/src/components/hub/HubBrowse.vue | 4 +- .../workshop/FeaturedBanner.test.ts | 25 ++++++ .../components/workshop/FeaturedBanner.vue | 21 ++++- .../workshop/WorkshopModelCard.test.ts | 85 ++----------------- .../components/workshop/WorkshopModelCard.vue | 19 ++--- .../src/composables/usePreviewVideo.ts | 35 ++++++++ .../src/config/model-release-links.test.ts | 2 +- .../website/src/config/model-release-links.ts | 2 +- .../src/config/models-catalogue.test.ts | 5 +- apps/website/src/config/models-catalogue.ts | 11 --- .../src/config/router-default-inputs.test.ts | 4 +- .../config/workshop-browse-content.test.ts | 12 ++- .../src/config/workshop-browse-content.ts | 9 +- .../config/workshop-content-inputs.test.ts | 8 +- .../src/config/workshop-contract.test.ts | 3 +- .../config/workshop-creator-request.test.ts | 12 +-- .../config/workshop-example-values.test.ts | 7 +- .../config/workshop-router-content.test.ts | 10 +-- .../src/config/workshop-router-content.ts | 4 +- .../config/workshop-router-identity.test.ts | 7 +- .../src/config/workshop-router-index.test.ts | 2 +- .../config/workshop-thumbnail-labels.test.ts | 4 +- .../content/workshop-display.content.test.ts | 4 +- apps/website/src/data/modelDiscovery.test.ts | 2 +- apps/website/src/data/modelDiscovery.ts | 2 +- .../src/lib/hub/template-use-case.test.ts | 2 +- apps/website/src/routes/models/index.astro | 2 +- .../src/routes/models/model-page.test.ts | 11 +-- apps/website/src/routes/models/model-page.ts | 4 +- 35 files changed, 199 insertions(+), 180 deletions(-) create mode 100644 apps/website/reviews/2026-09-13-models-performance.md create mode 100644 apps/website/src/composables/usePreviewVideo.ts diff --git a/.fallowrc.jsonc b/.fallowrc.jsonc index 2204f907406..38cc97a14d7 100644 --- a/.fallowrc.jsonc +++ b/.fallowrc.jsonc @@ -8,6 +8,8 @@ "index.html", "scripts/**/*.{js,ts}", "apps/website/src/scripts/**/*.ts", + // Astro injects these routes when WORKSHOP_IN_BUILD is enabled. + "apps/website/src/routes/models/*.astro", "**/.storybook/{main,preview}.ts", "packages/ingest-types/openapi-ts.config.ts" ], diff --git a/apps/website/reviews/2026-09-13-models-performance.md b/apps/website/reviews/2026-09-13-models-performance.md new file mode 100644 index 00000000000..f81e7e413eb --- /dev/null +++ b/apps/website/reviews/2026-09-13-models-performance.md @@ -0,0 +1,43 @@ +# Models performance follow-up + +Christian's report prompted an audit of data loading, video previews, and background animation on the live Models routes. The related SDK examples and sign-in recovery are separate changes. + +## Findings and changes + +- The catalogue imported the same module that joins and validates the source catalogues at build time. Importing its filter helpers caused that work and its source data to ship to the browser, even though Astro already supplies the prepared cards. Data ownership now stays in `workshop-browse-content`; filtering helpers have no catalogue-data dependency. Model pages and aliases still resolve from the same approved manifest. +- Model-card videos loaded metadata and started playback throughout the page, including horizontal overflow and rows below the viewport. Preview videos now attach their source only while visible in a visible tab, pause and release the source when hidden, and respect reduced motion. Unmount releases the media resource. The same lifecycle covers the featured video. +- The featured carousel's animation loop continued while offscreen. Rotation now stops offscreen and in hidden tabs, retaining hover, keyboard-focus and reduced-motion behavior. + +## Controlled browser measurements + +Baseline: `fab94df2fb` with the same production build configuration as the TEST preview. Chrome 149.0.7827.55, macOS 25.5.0, Apple M5 Pro, 48 GiB RAM, 1440×900 at 1×. Each sample used a fresh browser context, fixed local media fixtures, blocked external APIs, and an uncompressed local static server. No paid generations ran. + +Two warmups per arm, then ABBA/BAAB (four recorded samples per arm). Build processes were stopped before sampling. Times and heap below are medians at hydration; bytes are decoded JavaScript actually requested through the catalogue search or detail API-tab interaction. + +| Catalogue measurement | Before | After | Change | +| --------------------- | -----------: | -----------: | -----: | +| Requested JavaScript | 2,450,151 B | 1,395,168 B | −43% | +| Script duration | 36.4 ms | 20.9 ms | −43% | +| Used JS heap | 19,088,326 B | 12,851,676 B | −33% | +| Hydration reached | 176.5 ms | 154.2 ms | −13% | + +The Seedream 4.5 detail page was effectively unchanged: 1.67 MB JavaScript and approximately 111 ms to hydration. Its emitted 3.8 MB complete-contract chunk was **not requested**; emitted bundle size alone was not treated as a page-load regression. No long tasks occurred on this fast machine. These results do not measure provider latency, real media decoding costs, mobile performance, or Core Web Vitals in production. The final featured-carousel lifecycle change followed the table's measurement run; it is covered by behavior tests. + +## Regression checks + +`e2e/models-performance.spec.ts` exercises working catalogue search with a 1.8 MB decoded-JavaScript budget and actual browser video readiness/playback before and after scrolling, including reduced motion. Both tests fail against the baseline (2.66 MB with the full account fixture, and offscreen videos already loaded), and pass with the fixes. `FeaturedBanner.test.ts` checks that rotation freezes offscreen and in a hidden tab, then resumes. + +Run against a TEST-enabled build: + +```sh +NODE_ENV=production WORKSHOP_IN_BUILD=1 PUBLIC_WORKSHOP_ROUTER_RUN=1 PUBLIC_WORKSHOP_CLOUD_ENV=test WEBSITE_GITHUB_STARS_OVERRIDE=110000 PUBLIC_CUSTOMERIO_WRITE_KEY=test-e2e-write-key pnpm --filter @comfyorg/website build +pnpm --filter @comfyorg/website exec playwright test e2e/models-performance.spec.ts --project desktop --workers 1 +``` + +These are website checks. The canvas-specific performance CI does not establish a website timing baseline. The byte budget is deterministic; timings are supporting local evidence, not a CI performance guarantee. + +## Reviewer criteria and remaining boundaries + +[Alex's review of the account integration](https://github.com/Comfy-Org/ComfyUI_frontend/pull/17283#pullrequestreview-5172958399) emphasizes single ownership and explicit lifecycle boundaries. [Christian's follow-up](https://github.com/Comfy-Org/ComfyUI_frontend/pull/17283#issuecomment-5627167630) accepts a narrow unblock when architectural follow-ups have explicit owners. This change keeps catalogue data with its existing owner and uses one shared preview lifecycle rather than independent playback rules. + +The existing all-locale translation payload (~546 KB) and shared analytics remain material page costs. They span the website and need their own measured optimization and localization/consent validation. The current MCP session exposes no website RUM application or Slack search, so no production percentile or claim about either reviewer's preferences beyond their recorded engineering feedback is inferred. diff --git a/apps/website/scripts/generate-template-model-join.test.ts b/apps/website/scripts/generate-template-model-join.test.ts index 55355f4c2fb..1859c893632 100644 --- a/apps/website/scripts/generate-template-model-join.test.ts +++ b/apps/website/scripts/generate-template-model-join.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' import type { WorkshopModel } from '../src/config/models-catalogue' -import { workshopModels } from '../src/config/models-catalogue' +import { workshopModels } from '../src/config/workshop-browse-content' import hubTemplates from '../src/data/hubTemplates.json' import templateModelJoin from '../src/data/templateModelJoin.json' import { diff --git a/apps/website/scripts/generate-template-model-join.ts b/apps/website/scripts/generate-template-model-join.ts index 7777666c699..7ac2c462a1f 100644 --- a/apps/website/scripts/generate-template-model-join.ts +++ b/apps/website/scripts/generate-template-model-join.ts @@ -13,9 +13,11 @@ import { readFileSync, writeFileSync } from 'node:fs' import { join } from 'node:path' -import { workshopModels } from '../src/config/models-catalogue' +import { + workshopModels, + routerModelSlugAliases +} from '../src/config/workshop-browse-content' import type { WorkshopModel } from '../src/config/models-catalogue' -import { routerModelSlugAliases } from '../src/config/workshop-browse-content' import { hubTemplatesSchema } from '../src/lib/hub/types' import { modelNamedBy, partnerModelFor } from '../src/lib/hub/template-use-case' import { API_PROVIDER_MAP } from './generate-models' diff --git a/apps/website/scripts/generate-workshop-versions.ts b/apps/website/scripts/generate-workshop-versions.ts index 9bfc970a5cc..7678a48f631 100644 --- a/apps/website/scripts/generate-workshop-versions.ts +++ b/apps/website/scripts/generate-workshop-versions.ts @@ -10,7 +10,7 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs' import { join } from 'node:path' -import { workshopModels } from '../src/config/models-catalogue' +import { workshopModels } from '../src/config/workshop-browse-content' import type { WorkshopModel } from '../src/config/models-catalogue' import type { HubTemplate } from '../src/lib/hub/types' import { API_PROVIDER_MAP } from './generate-models' diff --git a/apps/website/scripts/test-router-models.ts b/apps/website/scripts/test-router-models.ts index f2602615e72..d0ec17b1477 100644 --- a/apps/website/scripts/test-router-models.ts +++ b/apps/website/scripts/test-router-models.ts @@ -6,7 +6,7 @@ import { join, resolve } from 'node:path' import { fileURLToPath } from 'node:url' import { parseArgs } from 'node:util' -import { routerWorkshopModels } from '../src/config/workshop-browse-content' +import { workshopModels } from '../src/config/workshop-browse-content' import { resolveWorkshopCloudEnv } from '../src/config/workshop-cloud-env' import { WORKSHOP_ROUTER_BASE_URL } from '../src/config/workshop-env' import { releaseRouterOutputs } from '../src/config/workshop-response' @@ -123,7 +123,7 @@ async function main() { : fileURLToPath( new URL(`../../../temp/router-model-tests/${runId}/`, import.meta.url) ) - const models = routerWorkshopModels.filter( + const models = workshopModels.filter( (model) => isMediaKind(model.modality) && (!values.modality || model.modality === values.modality) @@ -163,7 +163,7 @@ async function main() { } const report = openRouterModelReport({ jsonPath, markdownPath }) try { - for (const model of routerWorkshopModels) { + for (const model of workshopModels) { report.update({ slug: model.slug, routerId: model.routerId, diff --git a/apps/website/src/components/hub/HubBrowse.vue b/apps/website/src/components/hub/HubBrowse.vue index c18ddde2fe2..65829d89556 100644 --- a/apps/website/src/components/hub/HubBrowse.vue +++ b/apps/website/src/components/hub/HubBrowse.vue @@ -9,9 +9,9 @@ import type { UseCase, WorkshopModel } from '../../config/models-catalogue' import { USE_CASES, sortWorkshopModels, - useCaseFor, - workshopModels + useCaseFor } from '../../config/models-catalogue' +import { workshopModels } from '../../config/workshop-browse-content' import { groupModels } from '../../config/model-family' import hubTemplates from '../../data/hubTemplates.json' import { hubWorkflowPath } from '../../lib/hub/workflow-detail' diff --git a/apps/website/src/components/workshop/FeaturedBanner.test.ts b/apps/website/src/components/workshop/FeaturedBanner.test.ts index 089fd6f00ae..0db4d667d73 100644 --- a/apps/website/src/components/workshop/FeaturedBanner.test.ts +++ b/apps/website/src/components/workshop/FeaturedBanner.test.ts @@ -6,6 +6,10 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import type { WorkshopModel } from '../../config/models-catalogue' import FeaturedBanner from './FeaturedBanner.vue' +import { + setAllIntersecting, + stubIntersectionObserver +} from '../../test/fakeIntersectionObserver' const motion = vi.hoisted(() => ({ reduced: false })) @@ -40,6 +44,7 @@ const kling: WorkshopModel = { } async function advanceAutoplay(ms = AUTOPLAY_MS + RAF_MARGIN_MS) { + await setAllIntersecting(true) await vi.advanceTimersByTimeAsync(ms) await nextTick() } @@ -53,6 +58,7 @@ function setupAutoplayUser() { describe('FeaturedBanner', () => { beforeEach(() => { motion.reduced = false + stubIntersectionObserver() }) it('leads with the first model and links the whole slide to its page', () => { @@ -100,6 +106,7 @@ describe('FeaturedBanner', () => { ] } }) + await setAllIntersecting(true) expect(screen.getByTestId('featured-video').getAttribute('src')).toBe( '/video.mp4' ) @@ -153,4 +160,22 @@ describe('FeaturedBanner', () => { expect(screen.getByRole('heading', { level: 2 }).textContent).toBe('Flux') }) + + it('freezes rotation offscreen and in a hidden tab, then resumes where it stopped', async () => { + vi.useFakeTimers({ shouldAdvanceTime: false }) + render(FeaturedBanner, { props: { models: [base, kling] } }) + await setAllIntersecting(false) + await vi.advanceTimersByTimeAsync(AUTOPLAY_MS) + expect(screen.getByRole('heading', { level: 2 }).textContent).toBe('Flux') + await setAllIntersecting(true) + vi.spyOn(document, 'visibilityState', 'get').mockReturnValue('hidden') + document.dispatchEvent(new Event('visibilitychange')) + await nextTick() + await vi.advanceTimersByTimeAsync(AUTOPLAY_MS) + expect(screen.getByRole('heading', { level: 2 }).textContent).toBe('Flux') + vi.spyOn(document, 'visibilityState', 'get').mockReturnValue('visible') + document.dispatchEvent(new Event('visibilitychange')) + await advanceAutoplay() + expect(screen.getByRole('heading', { level: 2 }).textContent).toBe('Kling') + }) }) diff --git a/apps/website/src/components/workshop/FeaturedBanner.vue b/apps/website/src/components/workshop/FeaturedBanner.vue index 5fe5adfa8b5..2a34f47dfae 100644 --- a/apps/website/src/components/workshop/FeaturedBanner.vue +++ b/apps/website/src/components/workshop/FeaturedBanner.vue @@ -1,9 +1,16 @@