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

问题描述

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

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

  • https://github.com/pastahito/electron-react-webpack
  • https://github.com/duskload/react-electron-webpack

仅按照说明进行操作,以便在使用npm start

Followed the instructions only to be getting this error while starting the app using npm start

AVDCreateGPUAccelerator: Error loading GPU renderer

我正在将Mac Pro 与macOS Mojave 10.14.5配合使用.根据我的阅读: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 Pro上无法进行开发?

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 Apps?由于怪异的GPU问题,看起来不像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 22:47