Skip to content

feat(sb3): runtime.lazyAssetInstall flag - open projects before non-current assets load - #1

Open
PYC5635 wants to merge 1 commit into
Bilup:developfrom
PYC5635:feature/lazy-asset-install
Open

PYC5635 wants to merge 1 commit into
Bilup:developfrom
PYC5635:feature/lazy-asset-install

Conversation

@PYC5635

@PYC5635 PYC5635 commented Nov 22, 2026

Copy link
Copy Markdown

背景

scratch-gui 侧 PR(Bilup/scratch-gui#3「加载作品时忽略造型」)需要 VM 支持:设置开启后,项目打开只等当前造型就绪,其余造型/声音后台装载。

实现

parseScratchObject 的 installWithCurrentCostume 快速路径(先装 sprite、素材 in-place 填充、完成后 updateAllDrawableProperties + requestTargetsUpdate)已存在于本仓库,但项目加载路径硬编码传 isSingleSprite,因此只有单 sprite 加载能享受到它。

本 PR 在项目加载路径增加一个 runtime 级开关:

parseScratchObject(target, runtime, extensions, zip, assets[index],
    isSingleSprite || runtime.lazyAssetInstall === true)

GUI 侧设置 vm.runtime.lazyAssetInstall = true 即启用(不设置时行为与现在完全一致,零默认行为变化)。

效果

  • 打开作品:从"等待全部素材解码完成"变为"只等当前造型就绪"(大作品提速显著,素材按注释所述是 2-5x 的等待差距)
  • 其余造型:后台解码,每个完成时经 requestTargetsUpdate() 刷新(setCostume 转发已有 skinId,renderer 跳过无 skin 的 drawable,无闪烁)
  • 声音:后台装载进 soundBank

配套

…current assets load

When gui sets runtime.lazyAssetInstall = true, the project load path passes
installWithCurrentCostume to parseScratchObject, so a project opens as soon
as its current costume is ready; remaining costumes/sounds keep loading in
the background and announce themselves via requestTargetsUpdate().

Co-authored-by: PYC5635 <3653161641@qq.com>

This branch has not been deployed

No deployments
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.

1 participant