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.

fix(ui): tile concurrent session previews in the video viewer (multi-GPU)

Lincoln Stein19f5413230fb
diff --git a/invokeai/frontend/web/src/features/gallery/components/ImageViewer/CurrentVideoPreview.test.ts b/invokeai/frontend/web/src/features/gallery/components/ImageViewer/CurrentVideoPreview.test.ts
index cb9bd2c4f4..945fd1702c 100644
--- a/invokeai/frontend/web/src/features/gallery/components/ImageViewer/CurrentVideoPreview.test.ts
+++ b/invokeai/frontend/web/src/features/gallery/components/ImageViewer/CurrentVideoPreview.test.ts
@@ -27,6 +27,13 @@ describe('CurrentVideoPreview progress overlay', () => {
expect(source).toContain('lastRenderedItemNameRef.current = videoName');
});
+ it('tiles concurrent sessions instead of letting them overwrite each other (multi-GPU)', () => {
+ // CurrentImagePreview tiles per-session previews when several renders run at once; the video
+ // overlay must do the same or the sessions fight over the single full-size preview slot.
+ expect(source).toMatch(/withTiledProgress = withProgress && activeProgressData\.length > 1/);
+ expect(source).toContain('<ProgressImageTiles data={activeProgressData} />');
+ });
+
it('clears a pending post-render overlay when the video element errors', () => {
// onLoadedMetadata normally clears the resolve state; an errored element never fires it.
const errorHandler = source.slice(source.indexOf('const handleVideoError'), source.indexOf('const handlePlay'));
diff --git a/invokeai/frontend/web/src/features/gallery/components/ImageViewer/CurrentVideoPreview.tsx b/invokeai/frontend/web/src/features/gallery/components/ImageViewer/CurrentVideoPreview.tsx
index 893bdf69ce..35369b9161 100644
--- a/invokeai/frontend/web/src/features/gallery/components/ImageViewer/CurrentVideoPreview.tsx
+++ b/invokeai/frontend/web/src/features/gallery/components/ImageViewer/CurrentVideoPreview.tsx
@@ -33,6 +33,7 @@ import type { VideoDTO } from 'services/api/types';
import { SELECTED_ITEM_REVEAL_DURATION_MS, useImageViewerContext } from './context';
import { NoContentForViewer } from './NoContentForViewer';
import { ProgressImage } from './ProgressImage2';
+import { ProgressImageTiles } from './ProgressImageTiles';
import { ProgressIndicator } from './ProgressIndicator2';
import { VideoPlayButtonOverlay } from './VideoPlayButtonOverlay';
@@ -76,6 +77,7 @@ export const CurrentVideoPreview = memo(({ videoDTO }: Props) => {
const {
$progressEvent,
$progressImage,
+ $activeProgressData,
$isProgressImageResolving,
$isTemporarilyShowingSelectedImage,
lastRenderedItemNameRef,
@@ -83,6 +85,7 @@ export const CurrentVideoPreview = memo(({ videoDTO }: Props) => {
} = useImageViewerContext();
const progressEvent = useStore($progressEvent);
const progressImage = useStore($progressImage);
+ const activeProgressData = useStore($activeProgressData);
const isProgressImageResolving = useStore($isProgressImageResolving);
const isTemporarilyShowingSelectedImage = useStore($isTemporarilyShowingSelectedImage);
const hasProgressImage = progressImage !== null;
@@ -92,6 +95,9 @@ export const CurrentVideoPreview = memo(({ videoDTO }: Props) => {
// returns when the user closes the player.
const withProgress =
shouldShowProgressInViewer && hasProgressImage && !isTemporarilyShowingSelectedImage && !isPlaying;
+ // When more than one session is generating concurrently (multi-GPU), tile their previews instead
+ // of letting the sessions overwrite each other's full-size preview. Mirrors CurrentImagePreview.
+ const withTiledProgress = withProgress && activeProgressData.length > 1;
const { goToPreviousImage, goToNextImage, isFetching } = useNextPrevItemNavigation();
const selectedVideoRevealTimeoutId = useRef(0);
@@ -421,9 +427,15 @@ export const CurrentVideoPreview = memo(({ videoDTO }: Props) => {
)}
{withProgress && (
<Flex w="full" h="full" position="absolute" alignItems="center" justifyContent="center" bg="base.900">
- <ProgressImage progressImage={progressImage} />
- {progressEvent && (
- <ProgressIndicator progressEvent={progressEvent} position="absolute" top={6} right={6} size={8} />
+ {withTiledProgress ? (
+ <ProgressImageTiles data={activeProgressData} />
+ ) : (
+ <>
+ <ProgressImage progressImage={progressImage} />
+ {progressEvent && (
+ <ProgressIndicator progressEvent={progressEvent} position="absolute" top={6} right={6} size={8} />
+ )}
+ </>
)}
</Flex>
)}