Performance & Troubleshooting
Performance optimization techniques and diagnostic guidance for Ever Gauzy plugins.
Performance Optimizationβ
Lazy Window Instantiationβ
Create plugin windows on demand within activate(), not during initialize(). Eager window creation imposes immediate memory cost regardless of user intent.
Debouncing and Throttlingβ
Apply debouncing or throttling to IPC handlers responding to rapidly emitted events:
import { debounce } from "lodash";
const debouncedSave = debounce(() => {
this.config.onSettingsChanged(this.config.settings);
}, 1000);
Resource Cleanupβ
All event listeners must be explicitly removed in dispose():
public dispose(): void {
this.timer?.stop();
ipcMain.removeAllListeners('my-plugin-event');
ipcMain.removeHandler('my-plugin-action');
if (this.window && !this.window.isDestroyed()) {
this.window.close();
}
this.window = null;
}
Failure to remove listeners causes memory leaks and incorrect behavior across activation cycles.
Web Workers for Computationβ
Offload computationally intensive operations (video processing, data analysis, encryption) to Web Workers in the renderer process.
Asynchronous Main Process Operationsβ
All blocking I/O and long-running computations within the main process should be executed asynchronously. Blocking the main process event loop degrades responsiveness across the entire application.
Troubleshootingβ
Plugin Fails to Loadβ
If a plugin doesn't appear after installation, check:
- Malformed or missing
manifest.json - Incorrect or absent
mainentry in the manifest - Runtime error during module loading (check application console)
# Validate manifest JSON structure
cat manifest.json | jq .
# Verify the compiled entry point exists
ls -la build/
# Confirm TypeScript compiles without errors
npx tsc --noEmit
IPC Communication Failuresβ
Checklist when renderer can't invoke an IPC handler:
- β
Preload script path in
BrowserWindowconfig is correct and file exists - β
Channel name in
ipcMain.handle()matchesipcRenderer.invoke() - β
API is exposed via
contextBridge.exposeInMainWorld() - β
contextIsolationis not disabled
Use webContents.openDevTools() in the renderer window for debugging.
Window Fails to Appearβ
Verify these conditions:
- Window is created before
show()is called show: falseoption is not being overridden- HTML file path resolves correctly relative to the compiled bundle
- No exceptions during window creation
Build Failuresβ
Common causes and solutions:
# Clean rebuild resolves most transient issues
rm -rf node_modules build
npm install
npm run build 2>&1 | tee build.log
Ensure tsconfig.json paths and outDir are consistent with the Webpack configuration.
Memory Leaksβ
Root causes of steadily increasing memory across activation cycles:
- Event listeners not removed in
dispose() - Timers not cleared
BrowserWindowinstances not closed- Circular references preventing garbage collection
Installation Source Failuresβ
| Source | Diagnostic Steps |
|---|---|
| CDN | Verify HTTPS URL is accessible, archive is a valid ZIP, no CSP blocks the download |
| npm | Confirm registry is reachable, auth token is valid, package name and version exist |
| Local | Confirm file is a valid ZIP archive with a valid manifest.json |