是否可以在 Mac Pro 上构建 Electron 应用程序?由于奇怪的 GPU 问题,它看起来不像 [英] Is it possible to build Electron Apps on Mac Pro? Doesn't seem like it due to Bizarre GPU issue

查看:14
本文介绍了是否可以在 Mac Pro 上构建 Electron 应用程序?由于奇怪的 GPU 问题,它看起来不像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试拉取并尝试为 Electron 应用构建两个不同的引导存储库:

I tried to pull and tried to build two different bootstrap repos for Electron apps:

按照说明使用 npm start

AVDCreateGPUAccelerator: Error loading GPU renderer

我使用的是装有 macOS Mojave 10.14.5 的 Mac Pro.从我读到的:Mac Pros(2013 年型号)的 GPU 架构绊倒了 Electron/Chromium [出于我以外的原因].我确实在那台机器上运行了像 Slack 和 Atom 这样的 Electron 应用程序而没有问题,但由于某种原因,在 Mac Pro 上构建 Electron 应用程序似乎是不可能的.我觉得这很奇怪.

I am using a Mac Pro with macOS Mojave 10.14.5. From what I read: Mac Pros (2013 model)'s GPU architecture stumbles Electron/Chromium [for reasons beyond me]. I do have Electron apps like Slack and Atom running on that machine without problems, but for some reason, it would appear building Electron apps is impossible on Mac Pro. I find that very odd.

我可以做些什么来在 Mac Pro 上开发/构建 Electron 应用程序,还是 Electron 平台的官方立场是不能在 Mac Pros 上进行开发?

Is there anything I can do to be able to develop/build Electron apps on a Mac Pro or is it the official stance of the Electron platform that no development can be done on Mac Pros?

推荐答案

Electron 上的 GPU 加速和渲染问题可能会出现错误配置的系统或驱动程序问题.在其他情况下也会出现这些或类似问题,例如通过远程系统、X11 转发或远程桌面执行 Electron 时.在所有这些情况下,您都会遇到某种 GPU 初始化错误.

Problems with the GPU acceleration and rendering can occur on Electron with misconfigured systems or driver issues. There are also other instances where these or similar issues occur, such as when executing Electron via a remote system, X11 forwarding or a remote desktop. In all these instances you will get some kind of GPU initialization error.

对于您遇到的错误,实际上已经在 Stack Overflow 上简要介绍过(但它们没有涵盖解决方案);

For the error you are experiencing, it is actually already covered briefly here on Stack Overflow (however they don't cover a solution);

电子错误 AVDCreateGPUAccelerator:加载 GPU 渲染器时出错

在我的 Electron 应用程序中,我总是在应用程序执行的一开始就有以下代码;

In my Electron applications I always have the following piece of code at the very begining of the application execution;

import { app } from "electron";

if (app.getGPUFeatureStatus().gpu_compositing.includes("disabled")) {
    app.disableHardwareAcceleration();
}

这将检查 GPU 是否支持硬件加速,如果不支持则禁用它.此检查非常重要,但由于某些莫名其妙的原因在 Electron 中默认不执行 - 这会导致 Electron 在加速中断或不支持的系统上无法启动(或者更确切地说打开任何窗口).

This will check if the GPU supports hardware acceleration and disable it if this is not the case. This check is very important but is not executed by default in Electron for some inexplicable reason - which results in Electron failing to start (or rather open any window) on systems where acceleration is broken or unsupported.

如果这对您不起作用,只需调用(不检查)

If that doesn't work for you, simply calling (without the check)

import { app } from "electron";

app.disableHardwareAcceleration();

应该可以解决问题 - 但显然您应该只在开发过程中暂时这样做,并且只有在您确实需要时才这样做.第一段代码是首选方法.

should do the trick - but you should obviously only do it temporarily during development and only if you really need to. The first block of code is the prefered method.

这篇关于是否可以在 Mac Pro 上构建 Electron 应用程序?由于奇怪的 GPU 问题,它看起来不像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆