Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Improve config update throttling in Editor

Richie McIlroy86981ff72321
diff --git a/apps/desktop/src/routes/editor/Editor.tsx b/apps/desktop/src/routes/editor/Editor.tsx
index b02cd5567..f8d72653a 100644
--- a/apps/desktop/src/routes/editor/Editor.tsx
+++ b/apps/desktop/src/routes/editor/Editor.tsx
@@ -206,12 +206,18 @@ function Inner() {
}),
);
- const updateConfigAndRender = throttle(async (time: number) => {
+ const doConfigUpdate = async (time: number) => {
const config = serializeProjectConfiguration(project);
await commands.updateProjectConfigInMemory(config);
canvasControls()?.resetFrameState();
renderFrame(time);
- }, 1000 / FPS);
+ };
+ const throttledConfigUpdate = throttle(doConfigUpdate, 1000 / FPS);
+ const trailingConfigUpdate = debounce(doConfigUpdate, 1000 / FPS + 16);
+ const updateConfigAndRender = (time: number) => {
+ throttledConfigUpdate(time);
+ trailingConfigUpdate(time);
+ };
createEffect(
on(
() => trackDeep(project),