@glittering0717/ai-browser 2.1.16 → 2.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/main/index.js +40 -6
- package/src/main/ws_server.js +3 -0
- package/src/shared/version.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glittering0717/ai-browser",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.17",
|
|
4
4
|
"description": "AI-native browser — renders pixels for humans, structured semantic-tree API for agents. No screenshots, no OCR, no coordinate guessing.",
|
|
5
5
|
"main": "src/main/index.js",
|
|
6
6
|
"bin": {
|
package/src/main/index.js
CHANGED
|
@@ -257,14 +257,44 @@ app.on('child-process-gone', (_event, details) => {
|
|
|
257
257
|
exit_code: details && details.exitCode,
|
|
258
258
|
service: details && details.serviceName,
|
|
259
259
|
});
|
|
260
|
+
// GPU 崩溃自动降级(见下面 disableHardwareAcceleration 的说明)。
|
|
261
|
+
// 只在"开着硬件加速"时计数;已经降级过就不再折腾。
|
|
262
|
+
const type = details && details.type;
|
|
263
|
+
const reason = details && details.reason;
|
|
264
|
+
if (!gpuDisabled && type === 'GPU' && reason && reason !== 'clean-exit') {
|
|
265
|
+
const now = Date.now();
|
|
266
|
+
gpuCrashes = gpuCrashes.filter((t) => now - t < 120000).concat(now);
|
|
267
|
+
if (gpuCrashes.length >= 2) {
|
|
268
|
+
try { fs.writeFileSync(gpuOffMarker, new Date().toISOString() + ' gpu crash fallback\n'); } catch (e) {}
|
|
269
|
+
recordError('gpu_fallback', { crashes: gpuCrashes.length, reason });
|
|
270
|
+
try { app.relaunch(); } catch (e) {}
|
|
271
|
+
try { app.exit(0); } catch (e) {}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
260
274
|
});
|
|
275
|
+
let gpuCrashes = [];
|
|
261
276
|
|
|
262
|
-
//
|
|
263
|
-
//
|
|
264
|
-
//
|
|
265
|
-
//
|
|
266
|
-
//
|
|
267
|
-
|
|
277
|
+
// === 硬件加速:默认开,GPU 连续崩溃自动退回软件合成 ===
|
|
278
|
+
//
|
|
279
|
+
// 历史:2026-10 为了让某些机器上的 GPU 崩溃(exit_code=6)别把整个 app 拖死,
|
|
280
|
+
// 这里无条件 disableHardwareAcceleration()。代价是**所有页面都走软件合成**,
|
|
281
|
+
// 而"整窗内容被缩放一帧""刷新时先缩成一小块再恢复""内容缩在左上角"这类绘制异常
|
|
282
|
+
// 几乎都长在软件合成上 —— 合成器手里的 surface 尺寸和图层几何脱节时,软件路径会
|
|
283
|
+
// 把那张图**缩放**着贴出来,GPU 路径则按图层几何重新栅格化。
|
|
284
|
+
//
|
|
285
|
+
// 现在的策略:
|
|
286
|
+
// - 默认开硬件加速(Apple Silicon 上更快,也不出这类缩放异常)
|
|
287
|
+
// - 连续两次 GPU 进程崩溃(2 分钟内)→ 写标记 + 自动重启到软件合成,
|
|
288
|
+
// 之后一直用软的(删掉 ~/.ai-browser/.gpu-off 可恢复)。绝不因为一次偶发崩溃
|
|
289
|
+
// 就把所有人降级到软件渲染。
|
|
290
|
+
// - AI_BROWSER_GPU=on|off 可强制;off 等价于旧行为。
|
|
291
|
+
const gpuOffMarker = path.join(config.userDataDir, '.gpu-off');
|
|
292
|
+
const gpuPref = String(process.env.AI_BROWSER_GPU || 'auto').toLowerCase();
|
|
293
|
+
let gpuDisabled = gpuPref === 'off';
|
|
294
|
+
if (!gpuDisabled && gpuPref !== 'on') {
|
|
295
|
+
try { gpuDisabled = fs.existsSync(gpuOffMarker); } catch (e) { gpuDisabled = false; }
|
|
296
|
+
}
|
|
297
|
+
if (gpuDisabled) app.disableHardwareAcceleration();
|
|
268
298
|
|
|
269
299
|
// Disable Chromium sandbox — required when launched from restricted
|
|
270
300
|
// environments (e.g. TRAE IDE shell) where the sandbox helper cannot
|
|
@@ -398,6 +428,10 @@ function createWindow() {
|
|
|
398
428
|
|
|
399
429
|
// Init PageManager
|
|
400
430
|
pageManager = PageManager.getInstance(mainWindow);
|
|
431
|
+
// 渲染路径是"硬件合成"还是"软件合成",直接决定绘制异常的面貌(见
|
|
432
|
+
// disableHardwareAcceleration 一段)。让外部能查到这一位:ui.server_info 会带出来,
|
|
433
|
+
// 否则"页面上这一帧的问题"和"这条路的问题"永远分不开。
|
|
434
|
+
pageManager.renderPath = { gpu: !gpuDisabled, reason: gpuPref === 'off' ? 'env' : (gpuDisabled ? 'fallback' : 'default') };
|
|
401
435
|
pageManager._preloadPath = path.join(__dirname, '../preload/bridge.cjs');
|
|
402
436
|
|
|
403
437
|
// Create first tab.
|
package/src/main/ws_server.js
CHANGED
|
@@ -317,6 +317,9 @@ export function startWSServer(pageManager, port = config.wsPort, onQuit = null)
|
|
|
317
317
|
started_at: serverStartedAt,
|
|
318
318
|
ws_port: port,
|
|
319
319
|
platform: process.platform,
|
|
320
|
+
// 渲染路径:{gpu:true|false, reason:'default'|'env'|'fallback'}。
|
|
321
|
+
// 白屏/缩放类缺陷的复现与"这条路有没有关系"都要靠它。
|
|
322
|
+
...(pageManager.renderPath ? { render_path: pageManager.renderPath } : {}),
|
|
320
323
|
},
|
|
321
324
|
});
|
|
322
325
|
break;
|
package/src/shared/version.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// Kept in JS (not imported from package.json) to avoid Node import-attribute
|
|
3
3
|
// (JSON module) compatibility issues inside Electron. package.json "version"
|
|
4
4
|
// is manually synced to this value; tests assert they match.
|
|
5
|
-
export const VERSION = '2.1.
|
|
5
|
+
export const VERSION = '2.1.17';
|