Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(webv2): stabilize activation performance sampling
joshistoastd18325ce3a14
diff --git a/invokeai/frontend/webv2/scripts/measure-architecture-performance.mjs b/invokeai/frontend/webv2/scripts/measure-architecture-performance.mjsindex 7dc93e081c..b058c2f266 100644--- a/invokeai/frontend/webv2/scripts/measure-architecture-performance.mjs+++ b/invokeai/frontend/webv2/scripts/measure-architecture-performance.mjs@@ -13,6 +13,7 @@ import {validateBrowserBaseline,validateChunkSourceManifest,waitForRequiredRequests,+ waitForStableRequests,} from './performance-budgets.mjs';import { getWidgetId } from './widget-sources.mjs';@@ -314,6 +315,10 @@ const runSample = async (browser, fixture, sample) => {getRequested: () => getRequestedScriptLabels(scripts),requiredRequests: fixture.preActivationRequiredWidgetRequests ?? [],});+ await waitForStableRequests({+ context: `${fixture.id}/${fixture.stateProfile} before activation`,+ getRequested: () => scripts,+ });const activationTrigger = fixture.layoutPreset? page.getByRole('tab', { exact: true, name: fixture.layoutPreset }): page.getByRole('button', { name: /^Center view:/ });diff --git a/invokeai/frontend/webv2/scripts/performance-budgets.mjs b/invokeai/frontend/webv2/scripts/performance-budgets.mjsindex 9dcfcc97e1..e2a7a9db84 100644--- a/invokeai/frontend/webv2/scripts/performance-budgets.mjs+++ b/invokeai/frontend/webv2/scripts/performance-budgets.mjs@@ -53,6 +53,37 @@ export const waitForRequiredRequests = async ({throw new Error(`${context} did not request required widgets ${JSON.stringify([...required])}.`);};+export const waitForStableRequests = async ({+ context,+ getRequested,+ now = Date.now,+ pollIntervalMs = 25,+ stableForMs = 500,+ timeoutMs = 10_000,+ wait = (milliseconds) =>+ new Promise((resolveWait) => {+ setTimeout(resolveWait, milliseconds);+ }),+}) => {+ const deadline = now() + timeoutMs;+ let fingerprint;+ let stableSince = now();++ while (now() < deadline) {+ const currentFingerprint = JSON.stringify([...getRequested()].sort());+ if (currentFingerprint !== fingerprint) {+ fingerprint = currentFingerprint;+ stableSince = now();+ }+ if (now() - stableSince >= stableForMs) {+ return;+ }+ await wait(pollIntervalMs);+ }++ throw new Error(`${context} request set did not remain stable for ${String(stableForMs)}ms.`);+};+const isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);const assertPlainObject = (value, path) => {diff --git a/invokeai/frontend/webv2/scripts/performance-budgets.test.mjs b/invokeai/frontend/webv2/scripts/performance-budgets.test.mjsindex 80520446ef..fafbc4f472 100644--- a/invokeai/frontend/webv2/scripts/performance-budgets.test.mjs+++ b/invokeai/frontend/webv2/scripts/performance-budgets.test.mjs@@ -11,6 +11,7 @@ import {validateArchitectureBaseline,validateBrowserBaseline,waitForRequiredRequests,+ waitForStableRequests,} from './performance-budgets.mjs';const PROJECT_ROOT = '/repo/webv2';@@ -286,6 +287,31 @@ describe('browser performance sampling and policy', () => {assert.equal(resolved, true);});+ it('waits for cascading requests to settle before measuring activation', async () => {+ const requested = new Set(['GalleryImageActionsBridge']);+ let elapsedMs = 0;+ let polls = 0;++ await waitForStableRequests({+ context: 'editor-canvas/empty before activation',+ getRequested: () => requested,+ now: () => elapsedMs,+ pollIntervalMs: 10,+ stableForMs: 30,+ timeoutMs: 1_000,+ wait: (milliseconds) => {+ elapsedMs += milliseconds;+ polls += 1;+ if (polls === 2) {+ requested.add('GalleryImageActionsBridge dependency');+ }+ },+ });++ assert.equal(elapsedMs, 50);+ assert.deepEqual([...requested], ['GalleryImageActionsBridge', 'GalleryImageActionsBridge dependency']);+ });+it('keeps the trace sample disjoint from scored samples', () => {const plan = createBrowserSamplePlan({ scoredSamples: 3, traceSamples: 1, warmups: 2 });