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.

Merge branch 'main' into fix/canvas-large-map-inpaint

Josh Corbett8d724ad861cd
diff --cc invokeai/frontend/webv2/src/workbench/canvas-engine/ARCHITECTURE.md
index ca05ebf096,8804b1ff51..421359fdb8
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/ARCHITECTURE.md
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/ARCHITECTURE.md
@@@ -99,11 -99,13 +99,15 @@@ Snapshots create a deliberate transacti
2. After successful invocation detachment, ordinary editing may continue. Composite, upload, graph compilation, queue submission read only frozen contract and detached surfaces.
3. Wholesale canvas replacement stays a separate session, identified by `documentRevision`; completed results from an older session are dropped.
-Canvas invocation first crosses paint-flush barrier, then captures post-flush document, plans every raster/control/regional composite, and detaches exactly the contributing layers. Composite dedupe writes stage in transaction-local maps. They publish to persistent per-engine dedupe cache only after all frozen compositing, uploads, compilation, and queue dispatch complete; stale or failed captures leave no persistent dedupe entries.
+Canvas invocation first crosses paint-flush barrier, then captures post-flush document, plans every raster/control/regional composite, and detaches exactly the contributing layers. It passes the generation bbox as the capture's optional document-space `region`. For unrotated layers at native resolution (signed unit scales, including reflections), capture copies only intersecting source pixels plus one pixel of sampling margin, rounded outward on the source's pixel grid. Translation and paint offsets remain layer-local. The snapshot keeps each layer's actual whole-source `sourceRect` for content bounds and mode detection; its `rect` places the detached pixels. Disjoint sources keep a transparent one-pixel surface and an empty detached rect. Reservations estimate these bounded copies and top up actual extents before allocation, so a small frame on a resident large map does not require a second map-sized surface.
+
+Rotation or rescaling retains whole-source capture: changing a Canvas2D source's origin can change transformed sampling, so these paths preserve the original source grid exactly. Spatial layer stacks and all members of a spatial raster group also retain whole sources because their adjustments depend on that context. Callers omitting `region` (including PSD) retain whole-layer capture. This bounds detached generation inputs, not initial source rasterization: an uncached large source, a transformed layer, or spatial adjustment work can still exceed the unchanged 512 MiB budget. Composite dedupe writes stage in transaction-local maps. They publish to persistent per-engine dedupe cache only after all frozen compositing, uploads, compilation, and queue dispatch complete; stale or failed captures leave no persistent dedupe entries.
- `submitCanvasInvocationSnapshot` carries exact cloned canvas state used for compilation. `enqueueCompiledSnapshot` extracts its bounding box, dimensions, document revision instead of reading live project canvas. Generated candidates are placed from `queueItem.snapshot.canvas.document.bbox`, so later bbox edits do not move result. `documentRevision` still keeps results from a replaced canvas session out of current staging.
+ `submitCanvasInvocationSnapshot` carries exact cloned canvas state used for compilation. `enqueueCompiledSnapshot` extracts its bounding box, dimensions, document revision instead of reading live project canvas. Generated candidates are placed from `queueItem.snapshot.canvas.document.bbox`, so later bbox edits do not move result. Progress frames land at the same rect: a placeholder slot carries the submitted bbox origin and the result's size there (`src/workbench/canvasStagingView.ts`), and `StagedPreviewInput` always carries an absolute placement, so neither a candidate nor a progress frame follows the live bbox, and a bbox change repaints only the overlay. `documentRevision` still keeps results from a replaced canvas session out of current staging.
+
+ ### Editing during generation
+
+ Nothing in the document freezes while a generation runs or its results wait for review: tools, Properties, layer menus, canvas keys and history stay live. Only each result's landing rect is fixed: a candidate's `placement`, or the submitted bbox for a result still generating. Moving or resizing the bbox mid-batch changes the next Invoke only. Painting under a staged area is allowed; the shown preview draws above the raster and control stacks, and the staging bar's eye hides it. Deleting, reordering or adding layers leaves staging alone, and accept inserts a new raster layer at the top of the raster stack at accept time. Undo past the submission is allowed and never re-stages or moves a result. What keeps this safe: `documentRevision` fences staging (Clear canvas drops the replaced session's results and offers to stop its queued work; restoring a canvas point waits while the session has pending results, see "Restore points"); an offset `resizeCanvasDocument` is refused while the session has pending results (`hasPendingCanvasResults`), since it would move every leaf but not the pinned rects; acceptance stays engine-guarded (permit, gesture, a live float or open transform landed first, candidate fingerprint; see "Edit leases and staged-result acceptance"). A new Invoke no longer interrupts Filter or Select Object; their own lease and guards hold. The canvas widget outlines where each pending result lands (`previews.setStagedRegions`, see "Composition, damage and overlays") and the staging bar announces the pending count in a `role="status"` pill. From the canvas, Alt+[ and Alt+] step through staged results while more than one slot exists (a placeholder shows its progress frame); with one slot or none there is nothing to step to and they walk the layers. Bare arrows always nudge. With focus in the staging bar, its own key handler owns the arrows and Delete/Backspace and keeps them from the canvas: focus follows selection (focusing a thumbnail selects it, Left/Right move focus between thumbnails, or step the selection from the bar's other controls), Delete or Backspace discards the selected result and leaves focus on the next thumbnail, a step button or the bar, and nothing acts while one of the bar's menus is open.
## Frame demand before allocation