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 |