[electron]Webgl在linux下不可用?

2024-05-11 240 views
3

使用http://html5test.com/

普通 Chrome 浏览器:您的浏览器得分 518 分(满分 555 分)(WebGL 3D 图形是)

atom-shell:您的浏览器得分为 497 分(满分 555 分)(WebGL 3D 图形否)

两者上:“您正在 Linux 上使用 Chrome 41”。

原子外壳:v0.22.1 fedora linux

如何启用 webgl?

回答

3

顺便说一句,我们(c/sh)应该在文档中包含这些标志的默认值......

0

您的卡可能已被列入黑名单,或者您可能没有正确的驱动程序。 Webgl 在 Linux 上运行良好 2015 年 3 月 21 日下午 4:35,“Benjamin Winkler”notifications@github.com 写道:

RTFM - 在此存储库中搜索“webgl”(通过 markdown 过滤以获取文档)时,您将找到 BrowserWindow 构造函数的文档。

https://github.com/atom/atom-shell/blob/master/docs/api/browser-window.md#new-browserwindowoptions web-preferences 中有一个标志 webgl 。 (但我不知道它是否适用于此标志。)

— 直接回复此电子邮件或在 GitHub 上查看 https://github.com/atom/atom-shell/issues/1277#issuecomment-84463560

9
var app = require('app'); // Module to control application life.
var BrowserWindow = require('browser-window'); // Module to create native browser window.

// Report crashes to our server.
require('crash-reporter').start();

var mainWindow = null;

app.on('window-all-closed', function() {
    if (process.platform != 'darwin')
        app.quit();
});

app.on('ready', function() {
    mainWindow = new BrowserWindow({
        "width": 1024,
        "height": 768,
        'web-preferences': {
            'web-security': false,
            "webgl": true
        }
    });
    mainWindow.loadUrl('http://html5test.com/');
    mainWindow.on('closed', function() {
        mainWindow = null;
    });
});

没有不同。我认为它在早期提交中默认启用

5

@m1ga 好吧,我从来没有使用过它,只是为你搜索文档。

您的卡可能已被列入黑名单,或者您可能没有正确的驱动程序。

当它在 Chrome 中适用时,这种情况不太可能发生。

0

@bwin NVIDIA Corporation GT216GLM [Quadro FX 880M](rev a2),带 Nouveau 驱动程序。但就像你说的,chrome 工作正常只是atom-shell 说它不能使用 webgl

1

抱歉,我只能在 Ubuntu 上进行测试,但这可能无关紧要,因为 mcdermed 已经确认它可以在 Linux 上(对他来说)工作......

5
"experimental-features":true,
"experimental-canvas-features":true

在 html5 测试中给了我 505 分,但仍然没有 webgl。也许是新司机。我会看看是否可以安装它们来检查

0

@m1ga 顺便说一句,对“RTFM web-preferences”建议感到抱歉。我搜索过,这个问题出现了,你没有提到它,案件已结(我想)。

9

完全没问题!没有尝试过所以值得一试。仍在尝试让 nvidia 驱动程序运行...

2

好吧,nouveau 驱动程序有问题!专有的 nvidia 驱动程序正在工作!它受 chrome 支持,但不受 chromium 支持。

0

感谢您的回复。如果其他人可以确认它(如果它不是由您系统上的某些特殊情况引起的),则应该在文档中提及。

2

我将在接下来的几天内尝试确认。

1

@m1ga--ignore-gpu-blacklist在命令行中添加对您有用吗?

8

除非提供更多信息,否则我将关闭此内容。

0

抱歉,目前无法返回 nouveau。

9

@zcbenz 是否可以创建ignore-cpu-blacklist默认启用的二进制文件?对我来说这主要是一个linux问题,我想默认启用它。

1

您可以尝试使用app.commandLine.appendSwitch附加它。

此外,黑名单的存在是有原因的,强制忽略它会导致渲染问题甚至崩溃。

7

我在 Virtual Box - Ubuntu (14.04) 和最新的 chromium 中面临同样的问题。有什么解决办法吗?

0

@yagamiram 在我的案例中,app.commandLine.appendSwitch('ignore-gpu-blacklist', 'true')直接require('electron')main.js帮助后进行设置,但是您可以测试各种其他设置:

app.commandLine.appendSwitch('enable-gpu-rasterization', 'true')
app.commandLine.appendSwitch('enable-zero-copy', 'true')
app.commandLine.appendSwitch('disable-software-rasterizer', 'true')
app.commandLine.appendSwitch('enable-native-gpu-memory-buffers', 'true')

Chromium 命令行开关的概述:http://peter.sh/experiments/chromium-command-line-switches/

当然,如上所述,将实验功能添加到您作为参数提供的选项对象中以创建浏览器窗口。

options = {
    webgl: true,
    experimentalFeatures: true,
    experimentalCanvasFeatures: true,
    offscreen: true,
})
const mainWindow = new electron.BrowserWindow(options)

您还可以将 Electron 指向加载chrome://gpu/以查看启用的内容和未启用的内容。