0
点赞
收藏
分享

微信扫一扫

Electron在win7上加载plotyjs失败的解决方法

腾讯优测 2022-03-30 阅读 57

Electron在win7上加载plotyjs失败的解决方法

错误详情

程序中使用plotjs,经过electron打包之后,在win10电脑上运行正常,在win7电脑上没有办法加载plotjs的画面,错误信息如下:
在这里插入图片描述
错误代码:

Error while plotting: n {shortMessage: "Error linking program: ", longMessage: "", rawError: "", message: "gl-shader: Error linking program: ", stack: "Error"}

看上面的错误详情,这是glError错误

解决方法

经过测试发现,原来是win7加载plotyjs绘制的程序,然后自己启动了gpu加速,导致画面无法加载出来。所以解决方法也很简单,只要要electron的main.js文件中,在窗口ready之前添加如下代码禁用gpu加速即可:

// 防止在部分的win7电脑上,自动开启GPU加速导致六足程序没有办法渲染
app.disableHardwareAcceleration()
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(() => {
    createWindow()

    app.on('activate', function () {
        // On macOS it's common to re-create a window in the app when the
        // dock icon is clicked and there are no other windows open.
        if (BrowserWindow.getAllWindows().length === 0) createWindow()
    })
})
举报

相关推荐

0 条评论