CreateUniform unexpected error

1. A concise explanation of the problem you’re experiencing.

I have an web site which uses Terrain and I recently switched over to using PickPosition from pickEllipsoid while I am in 3D mode.

I have noticed that intermittenly I get a black box with the following text.

An error occurred while rendering. Rendering has stopped

TypeError: Cannot read property ‘_target’ of undefined

TypeError: Cannot read property ‘_target’ of undefined

at _.set(XXXXX/Cesium-1.54/Build/Cesium/Cesium.js:467:25518)

at d._setUniforms(XXXXX/Cesium-1.54/Build/Cesium/Cesium.js:468:6230)

at H(XXXXX/Cesium-1.54/Build/Cesium/Cesium.js:497:1822)

at z.draw(XXXXX/Cesium-1.54/Build/Cesium/Cesium.js:497:5817)

at n.execute(XXXXX/Cesium-1.54/Build/Cesium/Cesium.js:467:5406)

at Ue(XXXXX/Cesium-1.54/Build/Cesium/Cesium.js:520:27684)

at Ye(XXXXX/Cesium-1.54/Build/Cesium/Cesium.js:520:28667)

at Qe(XXXXX/Cesium-1.54/Build/Cesium/Cesium.js:521:753)

at rt(XXXXX/Cesium-1.54/Build/Cesium/Cesium.js:521:5871)

at et(XXXXX/Cesium-1.54/Build/Cesium/Cesium.js:521:3185)

I have noticed this occurs more often when I have Cesium Primitives with appearance:

feature = new Cesium.Primitive({

geometryInstances: primitive,

allowPicking: pickable,

interleave: true,

appearance: tmpAppearance


Looking at Cesium.js and the source code I think this must be coming from createUniform.js line 226: (gl.bindTexture(v._target, v._texture);

or createUniformArray.js line 304: gl.bindTexture(v._target, v._texture);

Is there a way this this code could be more defensive?

Thanks in advance

Jerrold Stoy

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

4. The Cesium version you’re using, your operating system and browser.

Cesium1.54, Windows 10, Chrome version 71+

Thanks for reporting this Jerrold! When you say it occurs more often with primitives, how often would you say that is? And I’m guessing it mostly occurs on click, right?

Ideally we’d have an example that reproduces it and we can open a GitHub issue to track/fix it.

If you can get the stack trace in the unminified Cesium that could also be the next best thing. Although, on second thought, it looks like the error is thrown in a draw command with an undefined texture, and what we really want to find out here is what generated an invalid draw command in the first place.

Omar, I captured the exception in Chrome. It looks like this.value is not set.

Hope this helps

Jerrold Stoy


Spent I mapped the obfuscated minified stack trace back to the source and this is what I believe is going on:

Scene.pickPosition calls

pickPositionWorldCoordinates at Scene.js at line 3667 calls

renderTranslucentDepthForPick at Scene.js at line 3587 calls

updateAndExecuteCommands at Scene.js at line 3532 calls

executeCommandsInViewPort at Scene.js at line 2586 calls

executeCommands at Scene.js at line 2793 calls

executeTranslucentCommands at Scene.js at line 2399 calls

executeTranslucentCommands can be either a executeTranslucentCommandsBackToFront at Scene.js line 2050 or executeTranslucentCommandsFrontToBack at Scene.js line 2065.

Regardless each executeTranslucentCommandsBackToFront and executeTranslucentCommandsFrontToBack call executeFunction, looking at the stack trace this is happening at Scene.js line 2061 or 2076.

executeFunction at Scene.hs line 1968 calls

command.execute at Scene.js line 2000 calls

execute at DrawCommand.js at line 564 calls

context.draw at Context.js line 1063 calls

continueDraw at line Context.js line 1077 calls

shaderProgram._setUniforms(uniformMap, context._us, context.validateShaderProgram); at Context.js line 1038 calls

ShaderProgram._setUniforms at line Context.js 1038 calls

uniforms[i].set(); at ShaderProgram line 501

Unfortunately after many hours I have not been able create a small test that replicates the issue.

I updated information on this post, hopefully it will help determine what is going on. Thanks in advance (Not a big Google Groups user).

Thanks for posting this update Jerrold. It looks like the issue is coming from the command generated from renderTranslucentDepthForPick. I can see from your screenshots that it looks like it’s the batchTexture that’s undefined here.

What I would do now is perhaps see if you can check for an undefined uniform value in continueDraw, before the call to _setUniforms. You can perhaps iterate over the uniformMap, see if anything is undefined. And when that happens, print the drawCommand.

The draw command holds all the information, and will give us a clue as to what part of the program is generating this invalid command. My guess would be somewhere in the updateBatchTexture in Cesium3dTIleBatchTable, it’s for some reason destroying/deleting this texture (but this could only be if you have 3D Tiles in your application).

How easily are you able to get this to happen in your application? Is it just a few seconds of clicking, or a few minutes etc.?