-
-
Notifications
You must be signed in to change notification settings - Fork 399
fix(core): disable cache for SceneLoader to avoid loadScene self-destroy #2993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev/2.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { AssetType, ResourceManager } from "@galacean/engine-core"; | ||
| import "@galacean/engine-loader"; | ||
| import { WebGLEngine } from "@galacean/engine"; | ||
| import { describe, beforeAll, expect, it } from "vitest"; | ||
|
|
||
| describe("SceneLoader cache policy", () => { | ||
| let engine: WebGLEngine; | ||
|
|
||
| beforeAll(async () => { | ||
| engine = await WebGLEngine.create({ canvas: document.createElement("canvas") }); | ||
| }); | ||
|
Comment on lines
+9
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add teardown for
🤖 Prompt for AI Agents |
||
|
|
||
| it("SceneLoader should have useCache disabled", () => { | ||
| const sceneLoader = ResourceManager._loaders[AssetType.Scene]; | ||
| expect(sceneLoader).to.not.be.undefined; | ||
| expect(sceneLoader.useCache).to.eq(false); | ||
| }); | ||
|
|
||
| it("PrimitiveMeshLoader should also have useCache disabled (existing convention)", () => { | ||
| const loader = ResourceManager._loaders[AssetType.PrimitiveMesh]; | ||
| expect(loader).to.not.be.undefined; | ||
| expect(loader.useCache).to.eq(false); | ||
| }); | ||
|
|
||
| it("Texture2D loader should still have useCache enabled (immutable asset)", () => { | ||
| const loader = ResourceManager._loaders[AssetType.Texture2D] || ResourceManager._loaders[AssetType.Texture]; | ||
| expect(loader).to.not.be.undefined; | ||
| expect(loader.useCache).to.eq(true); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: galacean/engine
Length of output: 50371
The cache behavior change is global and affects additive scene loads unintentionally.
Setting
useCache: falseon the Scene loader registration at line 170 disables caching for allSceneManager.loadScene()calls, regardless of thedestroyOldSceneparameter. TheresourceLoaderdecorator passesuseCacheto the loader constructor at registration time, not per-load call, so additive scene loads (destroyOldScene = false) will also bypass the cache. The PR objective specifies targeted cache eviction only when destroying old scenes, but this implementation affects both destructive and additive loads equally.🤖 Prompt for AI Agents