Electron 麒麟 Linux 系统 root 账户报错

使用Electron打包成客户端在麒麟Linux 操作系统上运行,普通用户启动程序正常

使用root用户出现各种问题。总结问题如下:

1. Running as root without --no-sandbox is not supported。

解决方案:

在启动命令后面加入 --no-sandbox

sudo ./xxxx-client --no-sandbox

 2. linux-unpacked/libGLESv2.so: 无法打开共享对象文件: 权限不够

即使使用 chmod -R 777  linux-unpacked 和 chown -root 也没用,依旧提示这个问题,这是因为当前 当前打包的文件在 当前用户的目录,root 对应 当前普通用户是无权限,虽然对当前文件夹是有前端。

3.将文件移动到root用户可访问权限,依然出错:

ERROR:gpu_init.cc(521)] Passthrough is not supported, GL is disabled, ANGLE is

[9033:1208/223621.958382:ERROR:bus.cc(399)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[9033:1208/223621.958468:ERROR:bus.cc(399)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
No protocol specified
No protocol specified
No protocol specified
No protocol specified
[9060:1208/223621.977332:ERROR:angle_platform_impl.cc(43)] DisplayVkXcb.cpp:59 (initialize): xcb_connect() failed, error 1
ERR: DisplayVkXcb.cpp:59 (initialize): xcb_connect() failed, error 1
[9060:1208/223621.986702:ERROR:angle_platform_impl.cc(43)] Display.cpp:997 (initialize): ANGLE Display::initialize error 12289: Not initialized.
ERR: Display.cpp:997 (initialize): ANGLE Display::initialize error 12289: Not initialized.
[9060:1208/223621.987595:ERROR:gl_display.cc(508)] EGL Driver message (Critical) eglInitialize: Not initialized.
[9060:1208/223621.988041:ERROR:gl_display.cc(920)] eglInitialize SwANGLE failed with error EGL_NOT_INITIALIZED
[9060:1208/223621.988148:ERROR:gl_ozone_egl.cc(23)] GLDisplayEGL::Initialize failed.
[9033:1208/223621.989891:ERROR:bus.cc(399)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[9060:1208/223621.991533:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization
[9033:1208/223622.018512:ERROR:bus.cc(399)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
No protocol specified
No protocol specified
No protocol specified
No protocol specified
[9102:1208/223622.065007:ERROR:angle_platform_impl.cc(43)] DisplayVkXcb.cpp:59 (initialize): xcb_connect() failed, error 1
ERR: DisplayVkXcb.cpp:59 (initialize): xcb_connect() failed, error 1
[9102:1208/223622.065302:ERROR:angle_platform_impl.cc(43)] Display.cpp:997 (initialize): ANGLE Display::initialize error 12289: Not initialized.
ERR: Display.cpp:997 (initialize): ANGLE Display::initialize error 12289: Not initialized.
[9102:1208/223622.065574:ERROR:gl_display.cc(508)] EGL Driver message (Critical) eglInitialize: Not initialized.
[9102:1208/223622.067751:ERROR:gl_display.cc(920)] eglInitialize SwANGLE failed with error EGL_NOT_INITIALIZED
[9102:1208/223622.068074:ERROR:gl_ozone_egl.cc(23)] GLDisplayEGL::Initialize failed.
[9102:1208/223622.070425:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization
No protocol specified
No protocol specified
No protocol specified
No protocol specified
[9121:1208/223622.087280:ERROR:angle_platform_impl.cc(43)] DisplayVkXcb.cpp:59 (initialize): xcb_connect() failed, error 1
ERR: DisplayVkXcb.cpp:59 (initialize): xcb_connect() failed, error 1
[9121:1208/223622.087462:ERROR:angle_platform_impl.cc(43)] Display.cpp:997 (initialize): ANGLE Display::initialize error 12289: Not initialized.
ERR: Display.cpp:997 (initialize): ANGLE Display::initialize error 12289: Not initialized.
[9121:1208/223622.087569:ERROR:gl_display.cc(508)] EGL Driver message (Critical) eglInitialize: Not initialized.
[9121:1208/223622.087659:ERROR:gl_display.cc(920)] eglInitialize SwANGLE failed with error EGL_NOT_INITIALIZED
[9121:1208/223622.087756:ERROR:gl_ozone_egl.cc(23)] GLDisplayEGL::Initialize failed.
[9121:1208/223622.089572:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization
No protocol specified
No protocol specified
[9129:1208/223622.099118:ERROR:gpu_init.cc(521)] Passthrough is not supported, GL is disabled, ANGLE is 
[9129:1208/223622.101894:ERROR:x11_software_bitmap_presenter.cc(142)] XGetWindowAttributes failed for window 132120579


 出现此问题是由于 electron的版本过高,导致麒麟系统访问的chromdriver出现的bug,
出现
[9129:1208/223622.099118:ERROR:gpu_init.cc(521)] Passthrough is not supported, GL is disabled, ANGLE is 错误,找到一篇解决访问博客是因为版本chrome内核版本过高,

python - Passthrough is not supported, GL is disabled - Stack Overflowhttps://stackoverflow.com/questions/67501093/passthrough-is-not-supported-gl-is-disabled

因此查找对应关系如图

此处我使用的版本是  "electron": "^21.3.0",chrome 对应的版本如图

图片来自 入坑摸鱼

根据博客解决方案为切换到89版本一下不在出现

 因此将electron版本下降到v12.2.3以下版本解决问题。

Electron 项目中,打包速度慢和打包过程中出现错误可能是由多种原因导致的。以下是一些常见的问题及其解决方案: 1. **包体积过大**: - 依赖过多:检查是否有不必要的依赖被打包,考虑使用 `npm prune` 或 `yarn clean --all` 清除未使用的依赖。 - 打包配置:检查 `package.json` 中的 `asar`(应用程序资源包装)选项,适当优化资源压缩,或仅打包必需文件。 2. **构建过程中的性能瓶颈**: - 编译时间长:可能是因为代码中有复杂的操作或大的库,尝试使用 Webpack 或 Rollup 等工具的性能优化设置。 - 第三方库更新:某些库可能存在构建效率低下的版本,更新到最新稳定版或寻找优化过的替代库。 3. **操作系统或硬件限制**: - 缺乏硬件资源:如果机器性能较低,可能需要升级硬件或调整编译时的构建参数。 - 磁盘空间不足:清理一些临时文件,为打包提供足够的磁盘空间。 4. **错误和报错**: - 语法错误:检查源代码,确保没有语法错误。 - 版本不兼容:确保使用的 Electron 版本、Node.js 版本以及依赖的库版本都相互兼容。 - 打包工具错误:更新或重新安装打包工具,如 electron-builder 或 npm scripts。 相关问题-- 1. 如何检查 Electron 打包过程中的依赖管理? 2. 如何优化 Electron 应用的构建性能? 3. 如何解决 Electron 报出的与第三方库版本不兼容的错误? 请注意,具体问题可能需要根据错误日志和实际项目配置来进一步诊断。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值