简体   繁体   English

Pixi.js 有时会抛出错误:WebGL unsupported in this browser

[英]Pixi.js sometimes throws an error: WebGL unsupported in this browser

The site is constantly running on the terminal, and sometimes it gives the following error该站点在终端上不断运行,有时会出现以下错误

WebGL unsupported in this browser, use "pixi.js-legacy" for fallback canvas2d support.

But when loading the page, a message appears about the use of webgl2.但是在加载页面时,会出现一条关于使用 webgl2 的消息 I cannot catch a similar error, but users sometimes get it.我无法捕捉到类似的错误,但用户有时会得到它。

I have pixi.js 6.1.3 and hardware acceleration enabled我启用了 pixi.js 6.1.3 和硬件加速

What could be the problem?可能是什么问题呢?

PixiJS requires stencil buffer to initialize and stencil buffer is not always supported on devices with WebGL support. PixiJS 需要模板缓冲区来初始化,而支持 WebGL 的设备并不总是支持模板缓冲区。 See the source of the isWebGLSupported function in PixiJS source, specifically these lines:请参阅 PixiJS 源代码中isWebGLSupported function 的源代码,特别是以下几行:

const contextOptions = {
    stencil: true,
    failIfMajorPerformanceCaveat: settings.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT,
};

What you potentially could do to support devices with WebGL without stencil is to overwrite the PixiJS function that creates the Renderer instance and use stencil: false in contextOptions .为了支持没有模板的 WebGL 设备,您可能会做的是覆盖创建Renderer实例的 PixiJS function 并在contextOptions中使用stencil: false I'm talking about the Renderer.create() function.我说的是Renderer.create() function。

Note, that by disabling stencil buffer PixiJS might not work correctly or at all, depending how it's written.请注意,禁用模板缓冲区 PixiJS 可能无法正常工作或根本无法正常工作,具体取决于它的编写方式。 Stencil buffer is used in PixiJS for masking, so if you do not use masks, you might be fine.在 PixiJS 中使用模板缓冲区进行遮罩,因此如果您不使用遮罩,您可能会没事。

This PixiJS issue was already reported: https://github.com/pixijs/pixijs/issues/5902这个 PixiJS 问题已经被报告: https://github.com/pixijs/pixijs/issues/5902

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM