// Disposable native-provider fixture, launched only on an isolated desktop. const { app, BrowserWindow, ipcMain } = require('electron') const fs = require('node:fs') const path = require('node:path') const dir = process.env.BENCH_STATE_DIR const instance = process.env.BENCH_INSTANCE process.on('uncaughtException', (error) => { console.error(error) app.exit(1) }) if (process.env.ORCA_COMPUTER_BENCH_ISOLATED !== '1') { process.exit(1) } app.whenReady().then(() => { const w = new BrowserWindow({ x: 60, y: 60, width: 760, height: 560, title: 'BenchElectron', webPreferences: { nodeIntegration: true, contextIsolation: false, backgroundThrottling: false } }) const nativeWindowId = process.platform === 'linux' ? w.getNativeWindowHandle().readUInt32LE() : null ipcMain.on('st', (_event, state) => { const data = JSON.stringify({ ...state, instance, activeForm: w.isFocused(), pid: process.pid, nativeWindowId }) try { fs.writeFileSync(path.join(dir, 'state.json.tmp'), data) fs.renameSync(path.join(dir, 'state.json.tmp'), path.join(dir, 'state.json')) } catch (error) { // Windows readers can briefly deny replacement; the next state tick retries. if (!['EACCES', 'EPERM', 'EBUSY'].includes(error.code)) { throw error } } }) w.loadURL( `data:text/html,${encodeURIComponent(`