Is it possible to build Electron Apps on Mac Pro? Doesn't seem like it due to Bizarre GPU issue

对着背影说爱祢 提交于 2019-12-05 05:03:24

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.

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

electron error AVDCreateGPUAccelerator: Error loading GPU renderer

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();
}

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!