【electron】electron开发中的一些问题

1.win8电脑上无法启动,点击图标后主进程报错:gpu process launch failed: error_code=xx

修复:

app.commandLine.appendSwitch('no-sandbox');

app.commandLine.appendSwitch('disable-gpu');

app.commandLine.appendSwitch('disable-software-rasterizer');

app.commandLine.appendSwitch('disable-gpu-compositing');

app.commandLine.appendSwitch('disable-gpu-rasterization');

app.commandLine.appendSwitch('disable-gpu-sandbox');

app.commandLine.appendSwitch('--no-sandbox');

app.disableHardwareAcceleration();

相关问题:
[Bug]: App launch failed with error- "gpu process launch failed: error_code=40" · Issue #32074 · electron/electron · GitHub

2.自动播放音频页面闪退

修复:

主进程中添加:

app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');

依旧不行将

electron版本改为14.2.0,(多个版本都可以,此处只是修改成了原有版本最接近的版本)

相关问题:

[Bug]: Windows 7/8 and macOS 10.11/10.12 crash when playing media files · Issue #31762 · electron/electron · GitHub

3.electron从12升级到14后webview内node环境问题

 由于Electron 12 版本之后 contextIsolation:将被默认true,

在主进程配置中设置contextIsolation:false后 webview中依旧用不了node环境

修复:

webview标签中添加属性:

webpreferences="contextIsolation=no"


版权声明:本文为jingjingchen1014原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。