Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

[めも]pixi.jsなどで、Error: WebGL: drawElements: This operation requires zeroing texture data. This is slow.が発生する場合

More than 3 years have passed since last update.

バグを拾ったようなので、暫定めも。
手元環境:
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.flushgl.drawElements()

再現用のコードは、[めも]pixi.jsなどで、Error: WebGL: texImage2D: Conversion requires pixel reformatting.が発生する場合[Firefoxのバグ]と同じです。

Firefox側のエラー表示部分

ZeroTextureData()

// 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のmIsDataInitializedfalseの場合に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.

toris-birds
Android用ゲームなどを作成しています。 作成したゲーム: テッポウウォーズ など https://play.google.com/store/apps/details?id=trident.miracle.games.archerfish.battle
http://tridentmiracles.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away