Repository navigation
fix(core): load the motion path plugin only for a page that tweens along a path - #8449
Conversation
terencecho
left a comment
There was a problem hiding this comment.
[P2] Preserve MotionPath for compositions whose tween lives in an external script (packages/core/src/runtime/editing/softReload.ts:467). The gate only inspects inline script text. In a Chromium probe using the preview bundle, real GSAP, and a sealed editing port, the same external tween moved the element 50 px on the previous version and 0 px here. The new preview made no plugin request and GSAP reported a missing plugin. Account for known MotionPath usage in external composition scripts while keeping the no-motion preview free of plugin requests.
The shared text check also misses a quoted "motionPath" property. A small direct probe reproduced that. Update the same-origin preload comment to reflect that a first path introduced by editing may now wait for the plugin.
All 28 focused tests passed. The local Chromium probe also confirmed that a plain tween makes no plugin request, an inline path still plays, and an offline load started by editing returns cannot-soft-reload without the generic fallback report. I did not run a full Studio editing session.
— tai (automated review)
Edit accuracy: accurate 271 (base branch 271), smooth 86 of thoseThe gate passes. Quarantined, measured but not gated (0) |
…en Studio connects
|
Thanks. All three at b3a2845:
One thing I could not reproduce: in Studio's Chrome harness the external tween stays at x 0 after a seek to its end even with the plugin loaded at connect, since the runtime renders it before the plugin lands. So the test pins the plugin request, not the 50 px. If your probe loaded the page differently (connect before the first render?), I'd like to match it. |
terencecho
left a comment
There was a problem hiding this comment.
[P2] Preserve path tweens created after preview connect (packages/core/src/runtime/editing/softReload.ts:475). The added scan sees tweens already registered at the moment Studio connects. It misses an external script that creates its first path tween later during normal playback, with no script edit to trigger soft reload. In a fresh sealed Chromium probe with real GSAP, that tween moved 50 px with the main runtime and 0 px with this head. Main requested the plugin once. The new head made no request and GSAP reported a missing plugin. The new eager external-script test creates its tween before connect and asserts the script loads. In my probe that eager case loaded the plugin but moved 0 px on both runtimes. Please add a playback assertion for the late case and keep the plain-preview no-fetch assertion.
Required captures. The latest “Studio and player captures” job failed because Before and After sections are missing. Include captures of the changed preview behavior.
The core build and 119 focused Studio tests passed. The playback comparison used a local Chromium fixture, without a live CDN outage.
— tai (automated review)
…e motion path plugin
|
Right, the timeline scan only saw tweens that existed at connect. At 7bbb2c0 the rule is the other way round: the preview skips the plugin only when it knows no script can build a path tween (every inline script read clean, and every external script is the HyperFrames runtime or a GSAP library file). An author's external script, which a sealed frame cannot read, keeps the preload, as on main.
|
terencecho
left a comment
There was a problem hiding this comment.
[P2] Identify known library scripts by their source. In packages/core/src/runtime/editing/softReload.ts:464, any external file named gsap.js or gsap.min.js is treated as the GSAP library. A composition’s own animation bootstrap can have either name. In the sealed Chromium fixture, the late external tween now moves 50 px when its script is named external-tween.js. Serving the exact same authored script at /authored/gsap.js makes the head skip the plugin and leaves the element at 0 px. The main runtime requests the plugin and moves 50 px in that case. Use known library URLs or provenance from the preview builder, and keep the conservative preload for unrecognized sources.
Review gate. Keep a dedicated fails without the fix: line in the PR body. The current entries put the round in parentheses before the colon, so none has the required prefix. The latest required capture check passed with the new Before and After evidence.
Core built successfully. All 283 focused Studio and preview-route tests passed. The additional local Chromium probe reproduced the filename collision. The plain preview made zero plugin requests.
— tai (automated review)
terencecho
left a comment
There was a problem hiding this comment.
[P2] Keep optional script classification from failing the preview (packages/studio-server/src/routes/preview.ts:207). A project script source can exist but still be unreadable or be something other than a regular file. The new synchronous read throws in that case, including in the saved-file fallback that calls the same augmentation. In a benign local fixture, a script URL pointing at an existing directory throws EISDIR instead of leaving the page unmarked. Treat failed inspection as unknown. Use the project asset boundary for inspection and restrict it to bounded reads of regular files. The current root check is lexical and does not establish confinement for the resolved file.
Review gate. The body still has fails without the fix (last commit): and similar entries. Put the commit qualifiers after the literal fails without the fix: prefix.
The original authored gsap.js case now moves 50 px in sealed Chromium and the capture check passed. The core build and 166 focused preview-route tests passed. The additional route fixture reproduced the thrown read.
— tai (automated review)
|
Fixed at c2e76ec. The builder's script read can no longer fail the preview: a project script is resolved with |
terencecho
left a comment
There was a problem hiding this comment.
P2 — The new preview scan blocks the build’s sync-filesystem gate. packages/studio-server/src/routes/preview.ts:208 adds synchronous stat and read calls on the preview route. node scripts/check-studio-server-sync-fs.mjs reports 9 synchronous calls against 7 allowed, matching the failed Build step on this head. Please move script inspection into the bounded asynchronous preview build and keep falling back to preload when the scan cannot complete.
The two targeted preview suites passed (168 tests). The PR body names the failing-before tests.
— tai (automated review)
…oop, within a time budget
|
Fixed at a331121. The scan now runs in the async build, before the page's synchronous augmentation, on the main, sub-composition and saved-file fallback paths, and passes its answer in. It reads with |
terencecho
left a comment
There was a problem hiding this comment.
P2 — The script scan still resolves paths synchronously on the server thread. In routes/preview.ts:219, resolveWithinProject runs before the first await. Its containment and private-path checks call synchronous realpath through helpers/safePath.ts and core’s safePath.ts. Each script begins that work during the map at line 253, before the one-second timer starts. A slow or stalled volume can therefore still delay the whole server despite the async stat and file read. The sync-fs gate passes because it counts direct calls in the route, and the timeout test delays the read only after resolution has already finished.
Please move the entire scan into the preview worker or use a bounded asynchronous path resolver, retaining both containment and private-path checks. Extend the timeout test to cover a delayed resolution as well as a delayed read. The sync-fs gate and both focused suites passed locally (169 tests).
— tai (automated review)
|
Fixed at e7f08a6. Script paths now resolve off the event loop with the same rules as Tests: "resolves project scripts without a synchronous realpath" counts |
terencecho
left a comment
There was a problem hiding this comment.
P2 — The optional script scan can outrun the preview request’s deadline. The async resolver fixes the synchronous filesystem issue. The sub-composition route at routes/preview.ts:847 still awaits provesNoPathTween on a fresh one-second timer after the route has already started its absolute deadline. During that await, nothing enforces the request’s earlier deadline.
I warmed the build worker and called the real sub-composition route with a 200 ms deadline. With a local script lookup held in the async resolver, the route returned 200 after 1,007 ms. The optional proof should use the remaining request budget, with the ordinary preview taking precedence. Please add a route-level test with a shorter request budget than the scan’s own budget. The resolver tests and sync-fs gate pass.
— tai (automated review)
…e request's deadline
|
Fixed at eef5e70. The scan now gets the preview request's own deadline (the root build's, or the sub-composition's) and uses at most half of the time left, capped at 1 s, so the preview keeps the rest. With no time left it doesn't scan, and the page preloads. The saved-file fallback has no request deadline and keeps the 1 s cap.
|
terencecho
left a comment
There was a problem hiding this comment.
The optional MotionPath scan now takes at most half the remaining root or sub-composition deadline. A stalled lookup leaves the normal preload in place. The held-lookup route regression, the preview suites, the sync-fs gate, and the required CI checks passed.
— tai (automated review)
|
Thanks. One fix after the approval, at e32dbd8: core's Windows tests failed at eef5e70 because the async path check threw for a path that does not resolve ( |
terencecho
left a comment
There was a problem hiding this comment.
The async resolver now returns null when either path cannot resolve and still rejects a resolved path outside the project. The test now uses an existing sibling fixture and includes a missing-file case that reproduces ENOENT with the previous implementation. All 378 focused tests, the sync-fs gate, the Windows core job and the required checks passed.
— tai (automated review)
What
A preview no longer loads GSAP's MotionPath plugin for a page that provably cannot tween along a path. The preview builder (studio-server) reads the page and each project script it loads, and marks the page only when none names
motionPath(quoted or not) and every other script is GSAP on its CDN. Any page it cannot prove, including one with a script from another host or a project script that tweens along a path, still preloads the plugin as before. When the preview's own plugin load fails, the page's GSAP fallback no longer loads it again from the CDN or reports "GSAP could not load ... so this preview's animations will not play".Why
Since v0.9.80 (#8320) every sealed preview loads the plugin as soon as Studio connects its editing port, whether or not the film uses it. The plugin URL follows the film's GSAP version, so a film on a version the host does not bundle loads it from cdn.jsdelivr.net. Offline, or where the CDN is blocked, that load fails; the page's GSAP fallback takes it for one of the film's own GSAP scripts, tries the CDN again, and reports that the preview's animations will not play, while the film plays normally.
Repro: open a film whose GSAP is 3.12.5 and that has no
motionPathin Studio's sealed preview with cdn.jsdelivr.net unreachable: Studio shows the error below. On v0.9.79 it loads nothing.Related work
Refs #8320.
How
preview.tsprovesNoPathTween: false when the page's text namesmotionPath, loads a child composition at run time, or has a base other than the project's preview base; then every<script>must be the HyperFrames runtime, GSAP athttps://cdn.jsdelivr.net/npm/gsap@<version>/dist/<file>.js, or a project file whose text names nomotionPath. A project file is resolved off the event loop with the same containment and private-file rules asresolveWithinProject: coreresolveExistingWithinProjectOff(realpathOffon both sides, thenrealPathWithin, the comparisonisSafePathnow shares) and studio-serverresolveExistingProjectFileOff(plusisPrivateProjectFileOff), so a link out of the project is not read. It must be a regular file of at most 4 MB, and any failed read counts as unknown. A module script, another host, a root path, a folder or a missing file makes it false, and inspection never fails the preview. Resolution, stat and read all run inside one budget, all scripts at once, with no synchronous fs call: at most 1 s and at most half of the time left before the preview request's own deadline (the root build's and a sub-composition's), so the preview keeps the rest. A scan that does not finish counts as unknown; with no time left there is no scan. The build runs the scan (provesNoPathTween) before the page's synchronous augmentation, on the main, sub-composition and saved-file fallback paths, and passes the answer in. A file's name is never trusted: an author'sgsap.jsis read like any other script.injectStudioPreviewAugmentationsadds<meta name="hf-no-path-tween">(NO_PATH_TWEEN_METAin coregsapCdn.ts) when the scan proved it and Studio motion adds no script.preloadMotionPath(coreruntime/editing/softReload.ts), which both the sealed editing port and Studio's same-origin preview call, skips the plugin only when that meta is present. A page without it, from any other host too, preloads as main does, which covers a path tween an external script builds after connect.namesMotionPath(coregsapCdn.ts) is the one text check, quoted keys included: the re-run, studio-server's plugin injection (htmlUsesMotionPath) and the builder's mark all use it.<script>carriesdata-hf-gsap-plugin(GSAP_PLUGIN_LOAD_ATTR). The preview's GSAP fallback (studio-serverpreview.ts) skips a script with it: the plugin's own loader already handles its failure (the re-run falls back to a reload).Before
Studio (dev host, sealed preview) at this branch's merge-base, opening a plain GSAP 3.12.5 film with cdn.jsdelivr.net unresolvable: the plugin is requested from the CDN twice and the console-errors list shows the report.
After
The same film at this branch (2d2449c): the builder marks the page, so no plugin request and no error.
Test plan
packages/studio/src/utils/gsapSoftReloadWait.browser.test.ts"a path tween an external script builds after connect plays" with the script served asauthored/gsap.js, sealed and unsealed (real Chrome; the tween is built after Studio connects, the test seeks to its end and expects x 50), fails with core's preload rule at 7bbb2c0 (a file namedgsap.jscounted as GSAP) and passes here. The same test with the script atpath-tween.jspasses on both.packages/studio-server/src/routes/preview.noPathTween.test.ts"holds for a page whose scripts are read and name no path" fails before the builder's proof existed, so every preview loaded the plugin; the file's other cases pin what is not proved: an authoredgsap.jsthat tweens along a path, another host, a missing file, a module script, a quoted"motionPath"in the page.preview.noPathTween.test.ts"fails for a script it cannot read: ... a folder" and "fails for a script that links out of the project" pin both.node scripts/check-studio-server-sync-fs.mjscounted 9 synchronous fs calls inroutes/preview.tsat c2e76ec, over its 7; it passes here at 7. "fails when resolving its path / reading it does not answer within the budget" pin the time budget.preview.scanDeadline.test.tsserves a sub-composition with a 200 ms request deadline whose script lookup never answers: at e7f08a6 the route answered after 1,010 ms (the scan's own 1 s); here it answers 200 within 500 ms (about 105 ms).preview.noPathTween.test.ts"resolves project scripts without a synchronous realpath" counts calls tofs.realpathSync.nativeduring a scan: 4 with the scan at a331121, 0 here.packages/studio-server/src/routes/preview.test.ts"leaves the preview's own plugin load to its loader: no fallback load, no report" fails with main'spreview.ts.gsapSoftReload.test.tspins the mark both ways and that the plugin script carriesdata-hf-gsap-plugin.safePath.test.tsincluded) 3 runs each, the covering tests, tsc in core, studio and studio-server, the Fallow audit and the pre-push hook pass.import-bare-folderopens (its owngsap.min.jsbeside an inline timeline) meets the rule, so it gets the mark.