add699a320
- Avoid per-render target.set dispatch that reset playback - Stop timer-based and per-frame React ticking while playing - Add regression tests for render-loop sources Made-with: Cursor
25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import test from 'node:test';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
|
|
|
|
void test('video playback: renderer hooks/components do not tick React each frame', () => {
|
|
const hookSrc = fs.readFileSync(
|
|
path.join(root, 'app', 'renderer', 'shared', 'video', 'useVideoPlaybackState.ts'),
|
|
'utf8',
|
|
);
|
|
// Регресс: раньше был setInterval(250ms) для clientNowMs, который заставлял перерисовываться окна.
|
|
assert.doesNotMatch(hookSrc, /\bsetInterval\s*\(/);
|
|
|
|
const previewSrc = fs.readFileSync(
|
|
path.join(root, 'app', 'renderer', 'control', 'ControlScenePreview.tsx'),
|
|
'utf8',
|
|
);
|
|
// Регресс: раньше был RAF loop с setState на каждом кадре.
|
|
assert.doesNotMatch(previewSrc, /\brequestAnimationFrame\s*\(\s*loop\s*\)/);
|
|
assert.doesNotMatch(previewSrc, /\brequestAnimationFrame\s*\(\s*loop\b/);
|
|
});
|