Google Chrome v31 breaks cocos2d-html5

This morning there was a new chrome update 31.0.1650.48 after which none of my programs are working. It is logging some warnings in the console like

WebGL: INVALID_VALUE: getUniformLocation: no object or object deleted 
cocos2d: ERROR: Failed to link program: [object WebGLProgram] 
WebGL: INVALID_OPERATION: drawArrays: attribs not setup correctly

Anyone else facing these issues? I am checking this on Mac. Is it working for anyone with chrome v31 either mac or windows?

Thanks
Shuja

Hi Shuja,

These issues are still produce on windows chrome. I will find the reason and fix them soon.

Thanks for your feedback.
David

I found the reason that “Uniforms with the same name but different type/precision”

The problem is been caused by this code in shaders/CCGLProgram.js:
var preStr = (type == this._glContext.VERTEX_SHADER) ? “precision highp float;” : “precision mediump float;”;

We can be modify “mediump” to “highp”, then it can work.

Dingping Lv wrote:

I found the reason that “Uniforms with the same name but different type/precision”
>
The problem is been caused by this code in shaders/CCGLProgram.js:
var preStr = (type == this._glContext.VERTEX_SHADER) ? “precision highp float;
” : “precision mediump float;
”;
>
We can be modify “mediump” to “highp”, then it can work.

Thanks David, it works after changing to highp.

1 Like

Thank you, this worked for me! Was this caused by cocos2dx or chrome? And with this question what I really mean is, should I be worried by another future Chrome update?

Hi Christian,

This problem is caused by chrome 31, chrome 31 changes its precision checking. Its error information is “Uniforms with the same name but different type/precision”,

We set the float’s precision to “highp” in vertex shader, because of high precision on position, while set the float’s precision to “mediump” in fragment shader, because of better performance. This setup works well on OpenGL , other browser and chrome before v31.

I don’t know what reason this changing is.