Skip to content
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

Fix: incorrect cache warning check #10430

Open
wants to merge 1 commit into
base: v7.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/assets/src/cache/Cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ class CacheClass

cacheKeys.forEach((key) =>
{
if (this._cache.has(key) && this._cache.get(key) !== value)
const val = cacheableAssets ? cacheableAssets[key] : value;

if (this._cache.has(key) && this._cache.get(key) !== val)
{
if (process.env.DEBUG)
{
Expand Down
38 changes: 38 additions & 0 deletions packages/assets/test/assets.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,44 @@ describe('Assets', () =>
spy.mockRestore();
});

it('should not show a cache warning if the same spritesheet asset is loaded twice', async () =>
{
jest.setTimeout(10000);
await Assets.init({
basePath,
});

const spy = jest.spyOn(console, 'warn');

await Promise.all([
Assets.load('spritesheet/spritesheet.json'),
Assets.load('spritesheet/spritesheet.json'),
]);

expect(spy).not.toHaveBeenCalled();

spy.mockRestore();
});

it('should show a cache warning if asset is different', async () =>
{
jest.setTimeout(10000);
await Assets.init({
basePath,
});

const spy = jest.spyOn(console, 'warn');

await Promise.all([
Assets.load({ alias: 'test', src: 'textures/bunny.png' }),
Assets.load({ alias: 'test', src: 'textures/bunny.1.png' }),
]);

expect(spy).toHaveBeenCalled();

spy.mockRestore();
});

it('should load font assets with space in URL', async () =>
{
await Assets.init({
Expand Down