perf: trim session IPC hot paths and fix clear-effects idle render
Skip full project broadcast on graph/NPC position commits, send session.stateChanged only to consumer windows, and force one Pixi render before stopping the idle ticker so Clear effects actually clears the canvas. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -10,7 +10,7 @@ import { safeConsoleError } from '../safeConsole';
|
||||
import { getBootSplashWindow } from './bootWindow';
|
||||
import { loadBrandingWindowIcon } from './brandingIcon';
|
||||
|
||||
type WindowKind =
|
||||
export type WindowKind =
|
||||
| 'editor'
|
||||
| 'presentation'
|
||||
| 'control'
|
||||
@@ -19,6 +19,15 @@ type WindowKind =
|
||||
| 'npcsEditor'
|
||||
| 'npcs';
|
||||
|
||||
/** Окна, которые реально слушают session.stateChanged (редактор синхронизируется через invoke). */
|
||||
export const SESSION_STATE_WINDOW_KINDS: readonly WindowKind[] = [
|
||||
'presentation',
|
||||
'control',
|
||||
'materials',
|
||||
'npcs',
|
||||
'npcsEditor',
|
||||
] as const;
|
||||
|
||||
const windows = new Map<WindowKind, BrowserWindow>();
|
||||
|
||||
let appQuitting = false;
|
||||
@@ -63,6 +72,23 @@ export function markAppQuitting(): void {
|
||||
appQuitting = true;
|
||||
}
|
||||
|
||||
/** Точечная рассылка в известные окна приложения (без splash / чужих BrowserWindow). */
|
||||
export function sendToAppWindows(
|
||||
channel: string,
|
||||
payload: unknown,
|
||||
kinds: readonly WindowKind[] = SESSION_STATE_WINDOW_KINDS,
|
||||
): void {
|
||||
for (const kind of kinds) {
|
||||
const win = windows.get(kind);
|
||||
if (!win || win.isDestroyed() || win.webContents.isDestroyed()) continue;
|
||||
try {
|
||||
win.webContents.send(channel, payload);
|
||||
} catch {
|
||||
/* окно могло закрыться между проверкой и send */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function quitAppFromEditorClose(): void {
|
||||
markAppQuitting();
|
||||
app.quit();
|
||||
|
||||
Reference in New Issue
Block a user