Skip to content

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.

perf(webv2): warm adapter lazy boundaries

joshistoast10fc422a654c
diff --git a/invokeai/frontend/webv2/src/app/GalleryUiAdapter.tsx b/invokeai/frontend/webv2/src/app/GalleryUiAdapter.tsx
index 9ac49cabbe..459d9683da 100644
--- a/invokeai/frontend/webv2/src/app/GalleryUiAdapter.tsx
+++ b/invokeai/frontend/webv2/src/app/GalleryUiAdapter.tsx
@@ -3,6 +3,7 @@ import type { ReactNode } from 'react';
import { GalleryUiProvider } from '@features/gallery/react';
import { useActiveProgressTarget } from '@features/queue/react';
+import { useMountEffect } from '@platform/react/useMountEffect';
import { useExportLibraryProject } from '@workbench/projects/useProjectFileActions';
import { getProjectWidgetValues } from '@workbench/widgetState';
import {
@@ -38,6 +39,13 @@ export const GalleryUiAdapterProvider = ({ children }: { children: ReactNode })
const liveProgressTarget = useActiveProgressTarget();
const { account, gallery, notifications, widgets } = useWorkbenchCommands();
const exportProject = useExportLibraryProject();
+ // These are `lazy()` children of an adapter that only ever mounts in the
+ // editor, and the gallery widget needs them as soon as it renders a row.
+ // Left to Suspense they were fetched at ~476ms — a full round trip after the
+ // boot widget wave had already finished.
+ useMountEffect(() => {
+ void import('./GalleryImageActionsBridge');
+ });
const adapter = useMemo<GalleryUiAdapter>(
() => ({
account: {
diff --git a/invokeai/frontend/webv2/src/app/GenerationUiAdapter.tsx b/invokeai/frontend/webv2/src/app/GenerationUiAdapter.tsx
index b08f53b6ee..44cc374321 100644
--- a/invokeai/frontend/webv2/src/app/GenerationUiAdapter.tsx
+++ b/invokeai/frontend/webv2/src/app/GenerationUiAdapter.tsx
@@ -7,6 +7,7 @@ import { GenerationUiProvider } from '@features/generation/react';
import { normalizeRebalancePresets } from '@features/generation/settings';
import { useAuthSession, useCapabilities } from '@features/identity';
import { ensureModelsLoaded, getModelBaseColorPalette, getModelBaseLabel, useModelsSelector } from '@features/models';
+import { useMountEffect } from '@platform/react/useMountEffect';
import { useQueryClient } from '@tanstack/react-query';
import {
getWorkbenchPreferences,
@@ -32,6 +33,13 @@ const GenerateCanvasCompositingSection = lazy(() =>
* Workbench, Models, and Gallery state. No second adapter is expected.
*/
export const GenerationUiAdapterProvider = ({ children }: { children: ReactNode }) => {
+ // The generate widget needs its model picker as soon as it renders. Left to
+ // Suspense, `ModelSelect` was fetched in a second wave after the boot
+ // widget wave had already finished. `GenerateCanvasCompositingSection` is
+ // canvas-only and stays lazy — warming it would add bytes to every boot.
+ useMountEffect(() => {
+ void import('@features/models/react');
+ });
const projectState = useActiveProjectSelector((activeProject) => ({
activeProjectId: activeProject.id,
generateValues: getProjectWidgetValues(activeProject, 'generate'),