バグを拾ったようなので、暫定めも。
手元環境:
Firefox:52.0.1
PIXI.js:4.4.2
現象:drawElements()などが呼ばれると、Firefoxの場合は、"Error: WebGL: drawElements: This operation requires zeroing texture data. This is slow."が表示される
初期化関連の現象なので、初回のみ発生。
原因はFirefox側ではないと思われます。
発生個所
pixi.jsの、21784行目
SpriteRenderer.prototype.flush
のgl.drawElements()
再現用のコードは、[めも]pixi.jsなどで、Error: WebGL: texImage2D: Conversion requires pixel reformatting.が発生する場合[Firefoxのバグ]と同じです。
Firefox側のエラー表示部分
// This has two usecases:
// 1. Lazy zeroing of uninitialized textures:
// a. Before draw, when FakeBlack isn't viable. (TexStorage + Draw*)
// b. Before partial upload. (TexStorage + TexSubImage)
// 2. Zero subrects from out-of-bounds blits. (CopyTex(Sub)Image)
pixi.jsの場合は、drawElements()がDraw*の条件に該当するらしい。
(three.jsの例は、CopyTex(Sub)Image()の方。)
Firefox側の関連個所
dom\canvas\WebGLContextDraw.cpp
WebGLContext::DrawElements()
、DrawElementsInstanced()
、DrawArrays()
、DrawArraysInstanced()
=> ScopedResolveTexturesForDraw scopedResolve()
=> ScopedResolveTexturesForDraw::ScopedResolveTexturesForDraw()
dom\canvas\WebGLTexture.cpp
=> WebGLTexture::ResolveForDraw()
=> WebGLTexture::GetFakeBlackType()
=> WebGLTexture::IsComplete()
、IsMipmapComplete()
=> WebGLTexture::EnsureLevelInitialized()
=> WebGLTexture::EnsureImageDataInitialized()
=> WebGLTexture::InitializeImageData()
=> ZeroTextureData()
EnsureImageDataInitialized()
などで使っている、ImageInfoは、
dom\canvas\WebGLTexture.h にある。
エラーメッセージにある"zeroing"は、calloc()
のこと。
ImageInfoのmIsDataInitialized
がfalse
の場合にInitializeImageData()
が呼ばれる。
似たようなバグ
three.js - Lens Flares and Firefox 45 #8321 (対策済み)
Mugen87 commented on 17 Mar 2016
I'm still getting the error messages in FF45 and OS X 10.10.5. According to the source code zeroing texture data seems to be evil since FF45.Zero subrects from out-of-bounds blits. (CopyTex(Sub)Image)
Maybe the parameters of gl.copyTexImage2D in LensFlarePlugin are not 100% correct...
Mugen87 commented on 18 Mar 2016
copyTexImage2D copies pixels from the current Framebuffer to a texture. If the area of the copy is not defined correctly (e.g. outside of the viewport), FF will produce the mentioned messages.The LensFlarePlugin plugin in three.js had some out-of-bound copies. The upcoming PR will prevent this behavior.