Skip to content

🎥 Make videos programmatically with React

Revert "use normal map for gif cache"

Jonny Burgercae863e4bffe
diff --git a/packages/gif/package.json b/packages/gif/package.json
index 758ede5a8d..c87470d265 100644
--- a/packages/gif/package.json
+++ b/packages/gif/package.json
@@ -22,6 +22,7 @@
},
"dependencies": {
"js-binary-schema-parser": "^2.0.3",
+ "lru_map": "0.4.1",
"remotion": "3.3.37"
},
"devDependencies": {
diff --git a/packages/gif/src/GifForDevelopment.tsx b/packages/gif/src/GifForDevelopment.tsx
index a5e7802dc0..129065ee5c 100644
--- a/packages/gif/src/GifForDevelopment.tsx
+++ b/packages/gif/src/GifForDevelopment.tsx
@@ -85,8 +85,6 @@ export const GifForDevelopment = forwardRef<
cancel();
}
- gifCache.delete(resolvedSrc);
-
continueRender(newHandle);
};
}, [id, resolvedSrc]);
diff --git a/packages/gif/src/GifForRendering.tsx b/packages/gif/src/GifForRendering.tsx
index 8e26e12e71..0dc402f83a 100644
--- a/packages/gif/src/GifForRendering.tsx
+++ b/packages/gif/src/GifForRendering.tsx
@@ -84,7 +84,6 @@ export const GifForRendering = forwardRef<HTMLCanvasElement, RemotionGifProps>(
}
continueRender(newHandle);
- gifCache.delete(resolvedSrc);
};
}, [id, resolvedSrc]);
diff --git a/packages/gif/src/gif-cache.ts b/packages/gif/src/gif-cache.ts
index 46e216575d..b09dd461f6 100644
--- a/packages/gif/src/gif-cache.ts
+++ b/packages/gif/src/gif-cache.ts
@@ -1,3 +1,4 @@
+import {LRUMap} from 'lru_map';
import type {GifState} from './props';
-export const gifCache = new Map<string, GifState>();
+export const gifCache = new LRUMap<string, GifState>(30);
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 333204e031..f38df2f8db 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -543,6 +543,7 @@ importers:
esbuild: 0.16.12
eslint: 8.25.0
js-binary-schema-parser: ^2.0.3
+ lru_map: 0.4.1
prettier: 2.6.2
prettier-plugin-organize-imports: ^2.3.4
react: 18.0.0
@@ -552,6 +553,7 @@ importers:
webpack: 5.74.0
dependencies:
js-binary-schema-parser: 2.0.3
+ lru_map: 0.4.1
remotion: link:../core
devDependencies:
'@jonny/eslint-config': 3.0.266_t54va6jeo5lf3vtqih5uiyrm5e
@@ -15734,6 +15736,10 @@ packages:
dependencies:
yallist: 4.0.0
+ /lru_map/0.4.1:
+ resolution: {integrity: sha512-I+lBvqMMFfqaV8CJCISjI3wbjmwVu/VyOoU7+qtu9d7ioW5klMgsTTiUOUp+DJvfTTzKXoPbyC6YfgkNcyPSOg==}
+ dev: false
+
/lz-string/1.4.4:
resolution: {integrity: sha512-0ckx7ZHRPqb0oUm8zNr+90mtf9DQB60H1wMCjBtfi62Kl3a7JbHob6gA2bC+xRvZoOL+1hzUK8jeuEIQE8svEQ==}
hasBin: true