Skip to content

[feat] canvas: load node media independently by priority - #2

Closed
Redivesue wants to merge 3 commits into
feat/446-stage-1-structure-firstfrom
feat/446-stage-2-node-media
Closed

Redivesue wants to merge 3 commits into
feat/446-stage-1-structure-firstfrom
feat/446-stage-2-node-media

Conversation

@Redivesue

@Redivesue Redivesue commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Stage 2 of 2 for progressive canvas loading (ThinkFlowLab#446). This branch contains the stage 1 commit from #1. Review only the second commit, [feat] canvas: load node media independently by priority, until stage 1 merges; the diff then reduces to stage 2.

  • Media reads share one bounded priority queue with 3 concurrent reads. Explicit actions run ahead of display reads.
  • On-screen nodes start reading when they reach the viewport, through one shared IntersectionObserver. There is no off-screen preload.
  • A display read is cancelled once no on-screen consumer needs it. Actions are never cancelled by a display consumer leaving.
  • Repeated media reads reuse the validated project head instead of replaying history under the catalog lock for each asset. An unproven chain still runs full validation, so a damaged ancestor is rejected. An ancestor rewritten while the server is running is rejected only after a restart.

Linked issue

Labels

  • Labels applied. I cannot set labels on this repository. Intended: type:feat, area:canvas, area:performance.

Test plan

Local, on this commit (stage 2 on stage 1, rebased onto 8258d4b0):

  • tsc --noEmit, check:i18n, check:browser-locale, check:browser-manifest, generate_contracts.py --check and pre-commit run --from-ref main pass.
  • Frontend: 978 passed. Python (-m cpu): 2902 passed, 118 skipped (Windows-only).
  • Browser gate (scripts/run-browser-suite.mjs, Vite dev server and isolated API as in CI): 30 of 30, including canvas_progressive_load in both languages.
  • Packaged desktop app on an isolated data directory, measured before the rebase: image preview, video playback, audio, original download, image editor, timeline editor and same-asset paste.

Not run or not passing:

  • Desktop archive export and MP4 export were not exercised in the packaged app.
  • The packaged desktop smoke test fails with A dialog obscures the canvas. It fails the same way on main.

Left to CI: the repository's pull request checks.

Evidence that it works

  • Media attached, or N/A because:

Recording, browser runtime on a warm server, the same fixtures: left main (8258d4b0), right this branch (stage 1 and 2). The overlay, injected by the recording script, shows the time since the project click and when the canvas became usable: 9.26 s on main, 0.27 s here, with media filling in afterwards.

Node states on this branch, in English and Chinese:

Same benchmark as #1: fixtures A image-heavy (180 nodes, 0.67 GiB), B video-heavy (89 nodes, 2.05 GiB), C mixed with editors (116 nodes, 0.97 GiB). Apple M2, 16 GiB, macOS 26.5; Chrome 158 headless against the source server, and the packaged Electron 45 app. Per direction: 4 warm-up switches excluded, then 10 measured switches; median / P90 in ms, nearest-rank. "Usable" means the target title is shown, the workspace is not busy or inert, and every visible node is mounted. "Content" means every in-viewport image is decoded, video has readyState >= 2, audio >= 1, and text is rendered. The driver uses CDP without the Network domain.

Measured on 52102ed0 (base), 9b50c442 (stage 1) and 417582ca (stage 2), before the rebase. The rebase adds three upstream commits that do not touch canvas open or media reads.

Browser Usable, base Usable, stage 1 Usable, stage 2 Content, base Content, stage 1 Content, stage 2
A→B 18652 / 21725 238 / 295 246 / 256 18764 / 21841 5976 / 8143 5272 / 5989
B→A 9714 / 12286 298 / 336 292 / 308 11264 / 15870 6770 / 7160 4918 / 5351
C→B 19870 / 21496 249 / 265 236 / 254 20002 / 21620 10826 / 13078 6733 / 11040
B→C 8915 / 9912 306 / 365 277 / 297 9510 / 10375 5920 / 6713 3448 / 4974
A→C 7658 / 7839 285 / 1898 300 / 365 7979 / 8193 2878 / 4657 4330 / 5823
C→A 5034 / 5420 312 / 411 304 / 373 6342 / 6697 7554 / 8111 6384 / 7524
Desktop Usable, base Usable, stage 1 Usable, stage 2 Content, base Content, stage 1 Content, stage 2
A→B 5866 / 8623 266 / 277 282 / 304 6065 / 8805 2904 / 3138 4713 / 4975
B→A 8140 / 9365 376 / 498 386 / 508 9995 / 10909 8052 / 8308 7104 / 7257
C→B 3404 / 4507 239 / 257 ¹ 214 / 243 3566 / 4743 3024 / 5308 ¹ 3726 / 4539
B→C 3459 / 3688 256 / 261 ¹ 282 / 286 3863 / 4176 3510 / 3543 ¹ 2908 / 3039
A→C 5369 / 7974 622 / 1792 294 / 298 5790 / 8390 3280 / 4355 3033 / 3258
C→A 7863 / 8674 300 / 436 296 / 389 9324 / 10129 6565 / 7838 7018 / 7191

¹ The stage 1 desktop C↔B run stopped at switch 9 of 24 on a storage_busy lock timeout, so these rows have 3 and 2 samples. Stage 2 completed 24 of 24 in every run.

With stage 2, usable median is within 500 ms and usable P90 within 1000 ms in every direction (worst P90: 508 ms, desktop B→A). Click feedback P90 is at most 32 ms. Stage 2 logged no failed requests in any run; base logged 409s on assistant/draft and timed-out tool-tasks reads in every run.

Stage 2 is not uniformly faster than stage 1 to full content. Content median improves in 5 of 6 browser directions and 3 of 6 desktop directions. It regresses most on desktop A→B (2904 → 4713 ms), where B's large in-view videos now share 3 read slots, and on browser A→C (2878 → 4330 ms). This benchmark uses the fit-all view, which puts every node in the viewport, so it does not exercise viewport gating.

Cold open after a server restart, usable median, stage 1 → stage 2: browser A 2066 → 1812, B 1269 → 1363, C 1481 → 1753 ms; desktop A 1418 → 1384, B 719 → 701, C 878 → 900 ms (base: browser 15339 / 7289 / 4033, desktop 8250 / 3630 / 3487 ms).

Peak Blob storage per run: base 1.0–2.8 GiB, stage 1 0.7–1.4 GiB, stage 2 0.5–1.3 GiB.

Known limitations

  • Media reads do not retry a storage_busy lock timeout (see [feat] canvas: show project structure before node media #1). This stage shortens catalog lock holds, and no lock timeout occurred in its benchmark runs, but the retry gap remains. On a freshly restarted server, a media read on A did get storage_busy (see the next item).
  • Switching away while the current canvas is still loading media is not covered by the benchmark above. Measured separately, A→B 2 s after A became usable, with 47–94 of its 133 visible nodes still loading (browser runtime, 3 runs each, click to B usable): 0.75–0.98 s with this stage and 4.7–5.0 s with stage 1 alone, on a warm server. The first such switch after a server restart took 42.4 s here and 48.8 s with stage 1 alone, because the first history replay of A (301 commits) holds the catalog lock for longer than its 15 s timeout and other requests queue behind it. That lock contention exists on main too, where the workspace stays inert until every node's media has loaded.
  • While a canvas is open, its loaded media is held as Blobs, one copy per asset (about 177 MiB for A and 1.2 GiB for B in the packaged app). The copy is released when the canvas is closed or switched.
  • Video is still read as a whole file. Streaming and posters are outside this change.

Provider verification

  • No real-provider calls were made.

Bilingual UI

  • This stage adds no new user-facing keys. The loading, failed and retry copy from stage 1 is verified in both languages by canvas_progressive_load.

resilientRead(
async (signal) => {
const response = await fetch(
`/api${creationPath(this.id)}/assets/${assetId}/${representation}`,
resilientRead(
async (signal) => {
const response = await fetch(
`/api${creationPath(this.id)}/assets/${assetId}/thumbnail`,
@Redivesue
Redivesue force-pushed the feat/446-stage-1-structure-first branch from 9b50c44 to 68b0103 Compare November 24, 2026 04:53
@Redivesue
Redivesue force-pushed the feat/446-stage-2-node-media branch from 417582c to 3c95a2d Compare November 24, 2026 04:53
@Redivesue
Redivesue force-pushed the feat/446-stage-1-structure-first branch from 68b0103 to d369be5 Compare November 24, 2026 05:01
@Redivesue
Redivesue force-pushed the feat/446-stage-2-node-media branch from 3c95a2d to 3a9ee03 Compare November 24, 2026 05:01
FayeSpica and others added 3 commits November 24, 2026 15:21
)

* [feat] desktop: show install guidance in the macOS DMG

Signed-off-by: Weiming Liao <liaowm5@gmail.com>

* [chore] desktop: keep the install guide off the homepage

Signed-off-by: Weiming Liao <liaowm5@gmail.com>

* [bugfix] desktop: complete the welcome flow in release smoke

Signed-off-by: Weiming Liao <liaowm5@gmail.com>

---------

Signed-off-by: Weiming Liao <liaowm5@gmail.com>
Opening or switching a canvas waited for every node's media, including hidden
nodes, before the workspace became interactive.

Project the canvas from the opened snapshot and keep a stable asset source in
node media fields. Object URLs are resolved only where media is displayed or
read, so they no longer enter the document, undo history or save baseline.
Saving compares asset identity, so a late media read cannot change a binding.

Return text with open-canvas, show loading and failed states per node, and
check reference-catalog files against its one snapshot.

Refs ThinkFlowLab#446
Once the structure is interactive, every mounted node still started its media
read at once and waited behind the catalog lock.

Share a bounded priority queue across media reads, start on-screen nodes only
when they reach the viewport, and cancel a display read once no on-screen
consumer needs it. Explicit actions keep priority and are never cancelled by a
display consumer leaving.

Reuse the validated head for repeated media reads. An unproven chain still runs
the full validation first, so a damaged ancestor keeps being rejected.

Refs ThinkFlowLab#446
@Redivesue
Redivesue force-pushed the feat/446-stage-2-node-media branch from 3a9ee03 to 7f70818 Compare November 24, 2026 09:34
@Redivesue

Copy link
Copy Markdown
Owner Author

Superseded by ThinkFlowLab#485, which merged both stages.

@Redivesue Redivesue closed this Nov 24, 2026
@Redivesue
Redivesue deleted the feat/446-stage-2-node-media branch November 24, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants