无法使用 Xvfb 在 Electron 中呈现 WebGL
Unable to render WebGL in Electron with Xvfb
我正在尝试在我的 Linux PC 上呈现我的应用程序,该应用程序在 Electron 中具有 WebGL 依赖性,但页面上没有呈现任何内容,除了 CSS 背景颜色。当我删除 WebGL 依赖项(即 MapboxGL)时,一切都会正常呈现。
我正在使用 X 虚拟帧缓冲区,这对于 Linux 环境来说似乎是必需的,如下所述:https://electronjs.org/docs/tutorial/testing-on-headless-ci
我是 运行 Xvfb 使用这个命令:
Xvfb :99 -screen 0 1024x768x24 > xvfblog.txt 2>&1 &
然后我使用前缀启动我的应用程序:
DISPLAY=:99
以便应用程序连接到 X 虚拟帧缓冲区显示器。
我不确定这是否相关,但 Xvfb 启动时显示以下消息:
The XKEYBOARD keymap compiler (xkbcomp) reports:
> Warning: Unsupported high keycode 372 for name ignored
> X11 cannot support keycodes above 255.
> This warning only shows for the first high keycode.
> Internal error: Could not resolve keysym XF86WWAN
> Internal error: Could not resolve keysym XF86RFKill
> Internal error: Could not resolve keysym XF86Keyboard
Errors from xkbcomp are not fatal to the X server
我还注意到,当我在 Macbook 上使用 Electron 测试我的应用程序时,不需要 Xvfb,而且我的 WebGL 应用程序呈现得很好。
我在这里有点难过。关于可能出现的问题或我可以调查的问题是否有任何建议?
我能够通过如下配置 Xvfb 与 WebGL 一起工作来解决这个问题:
Xvfb :99 -screen 0 1024x768x24 +extension GLX +render > xvfblog.txt 2>&1 &
我在其中添加了 +extension GLX +render
标志。
我还必须使用 ignore-gpu-blacklist
标志启动 electron。我发现这篇文章对此很有帮助:https://medium.com/social-tables-tech/how-we-test-webgl-on-continuous-integration-37a1ead55fd7
另请注意,我使用的是 "electron" npm 包,我必须将以下标志添加到我的 BrowserWindow
对象中:
const win = new BrowserWindow({
show: false,
webPreferences: {
webgl: true,
webSecurity: false,
experimentalFeatures: true,
experimentalCanvasFeatures: true,
offscreen: true
}
})
我希望这对某人有所帮助。
我正在尝试在我的 Linux PC 上呈现我的应用程序,该应用程序在 Electron 中具有 WebGL 依赖性,但页面上没有呈现任何内容,除了 CSS 背景颜色。当我删除 WebGL 依赖项(即 MapboxGL)时,一切都会正常呈现。
我正在使用 X 虚拟帧缓冲区,这对于 Linux 环境来说似乎是必需的,如下所述:https://electronjs.org/docs/tutorial/testing-on-headless-ci
我是 运行 Xvfb 使用这个命令:
Xvfb :99 -screen 0 1024x768x24 > xvfblog.txt 2>&1 &
然后我使用前缀启动我的应用程序:
DISPLAY=:99
以便应用程序连接到 X 虚拟帧缓冲区显示器。
我不确定这是否相关,但 Xvfb 启动时显示以下消息:
The XKEYBOARD keymap compiler (xkbcomp) reports:
> Warning: Unsupported high keycode 372 for name ignored
> X11 cannot support keycodes above 255.
> This warning only shows for the first high keycode.
> Internal error: Could not resolve keysym XF86WWAN
> Internal error: Could not resolve keysym XF86RFKill
> Internal error: Could not resolve keysym XF86Keyboard
Errors from xkbcomp are not fatal to the X server
我还注意到,当我在 Macbook 上使用 Electron 测试我的应用程序时,不需要 Xvfb,而且我的 WebGL 应用程序呈现得很好。
我在这里有点难过。关于可能出现的问题或我可以调查的问题是否有任何建议?
我能够通过如下配置 Xvfb 与 WebGL 一起工作来解决这个问题:
Xvfb :99 -screen 0 1024x768x24 +extension GLX +render > xvfblog.txt 2>&1 &
我在其中添加了 +extension GLX +render
标志。
我还必须使用 ignore-gpu-blacklist
标志启动 electron。我发现这篇文章对此很有帮助:https://medium.com/social-tables-tech/how-we-test-webgl-on-continuous-integration-37a1ead55fd7
另请注意,我使用的是 "electron" npm 包,我必须将以下标志添加到我的 BrowserWindow
对象中:
const win = new BrowserWindow({
show: false,
webPreferences: {
webgl: true,
webSecurity: false,
experimentalFeatures: true,
experimentalCanvasFeatures: true,
offscreen: true
}
})
我希望这对某人有所帮助。