iPhone 4s and 3Gs crash with GLSL error!

Once xcode is ready to run the game on iPhone 4s or 3Gs and the application becomes active, it throws the following lines and the game quits. However, it runs just fine with iPad 4G and iPhone 5.

Any idea ?

GLSL source: 
#define SHADER_API_GLES 1
#define tex2D texture2D
#define gl_ModelViewProjectionMatrix glstate_matrix_mvp
uniform mat4 glstate_matrix_mvp;
#define SHADER_API_GLES 1
#define SHADER_API_MOBILE 1
#define gl_Vertex _glesVertex
attribute vec4 _glesVertex;
#define gl_Normal (normalize(_glesNormal))
attribute vec3 _glesNormal;
#define gl_MultiTexCoord0 _glesMultiTexCoord0
attribute vec4 _glesMultiTexCoord0;
#define TANGENT vec4(normalize(_glesTANGENT.xyz), _glesTANGENT.w)
attribute vec4 _glesTANGENT;
mat2 xll_transpose(mat2 m) {
  return mat2( m[0][0], m[1][0], m[0][1], m[1][1]);
}
mat3 xll_transpose(mat3 m) {
  return mat3( m[0][0], m[1][0], m[2][0],
               m[0][1], m[1][1], m[2][1],
               m[0][2], m[1][2], m[2][2]);
}
mat4 xll_transpose(mat4 m) {
  return mat4( m[0][0], m[1][0], m[2][0], m[3][0],
               m[0][1], m[1][1], m[2][1], m[3][1],
               m[0][2], m[1][2], m[2][2], m[3][2],
               m[0][3], m[1][3], m[2][3], m[3][3]);
}
mat3 xll_constructMat3( mat4 m) {
  return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2]));
}
vec2 xll_matrixindex (mat2 m, int i) { vec2 v; v.x=m[0]_; v.y=m[1]*; return v; }*_

vec3 xll_matrixindex (mat3 m, int i) { vec3 v; v.x=m[0]; v.y=m[1]; v.z=m[2]; return v; }
vec4 xll_matrixindex (mat4 m, int i) { vec4 v; v.x=m[0]; v.y=m[1]; v.z=m[2]; v.w=m[3]; return v; }
#line 150
struct v2f_vertex_lit {
highp vec2 uv;
lowp vec4 diff;
lowp vec4 spec;
};
#line 186
struct v2f_img {
highp vec4 pos;
mediump vec2 uv;
};
#line 180
struct appdata_img {
highp vec4 vertex;
mediump vec2 texcoord;
};
#line 306
struct v2f {
highp vec4 pos;
highp vec2 uv[2];
highp vec3 viewDirT;
highp vec3 I;
highp vec3 TtoW0;
highp vec3 TtoW1;
highp vec3 TtoW2;
};
#line 58
struct appdata_tan {
highp vec4 vertex;
highp vec4 tangent;
highp vec3 normal;
highp vec4 texcoord;
};
uniform highp vec4 _MainTex_ST;
uniform highp mat4 _Object2World;
uniform highp vec4 _SparkleTex_ST;
uniform highp mat4 _World2Object;
uniform highp vec3 _WorldSpaceCameraPos;
uniform highp vec4 unity_Scale;
highp vec3 ObjSpaceViewDir( in highp vec4 v );
v2f vert( in appdata_tan v );
#line 90
highp vec3 ObjSpaceViewDir( in highp vec4 v ) {
highp vec3 objSpaceCameraPos;
objSpaceCameraPos = ((World2Object * vec4( WorldSpaceCameraPos.xyz, 1.0)).xyz * unity_Scale.w);
return (objSpaceCameraPos - v.xyz);

}
#line 321
v2f vert( in appdata_tan v ) {
v2f o;
highp vec3 objViewDir;
highp vec3 binormal;
highp mat3 rotation;
o.pos = (gl_ModelViewProjectionMatrix * v.vertex);
#line 325
o.uv[0] = ((v.texcoord.xy * MainTex_ST.xy) + MainTex_ST.zw);
o.uv[1] = ((v.texcoord.xy * SparkleTex_ST.xy) + SparkleTex_ST.zw);
objViewDir = ObjSpaceViewDir( v.vertex);

o.I = (xll_constructMat3( Object2World) * (-objViewDir));
#line 329

binormal = (cross( v.normal, v.tangent.xyz) * v.tangent.w);
rotation = xll_transpose(mat3( v.tangent.xyz, binormal, v.normal));
o.viewDirT = (rotation * objViewDir);
o.TtoW0 = (rotation * xll_matrixindex (Object2World, 0).xyz);
#line 333

o.TtoW1 = (rotation * xll_matrixindex (Object2World, 1).xyz);
o.TtoW2 = (rotation * xll_matrixindex (Object2World, 2).xyz);
return o;

}
varying highp vec2 xlv_;
varying highp vec2 xlv__1;
varying highp vec3 xlv_;
varying highp vec3 xlv_;
varying highp vec3 xlv_;
varying highp vec3 xlv_;
varying highp vec3 xlv_;
void main() {
v2f xl_retval;
appdata_tan xlt_v;
xlt_v.vertex = vec4( gl_Vertex);
xlt_v.tangent = vec4( TANGENT);
xlt_v.normal = vec3( gl_Normal);
xlt_v.texcoord = vec4( gl_MultiTexCoord0);
xl_retval = vert( xlt_v);
gl_Position = vec4( xl_retval.pos);
xlv_ = vec2( xl_retval.uv[0]);
xlv__1 = vec2( xl_retval.uv[1]);
xlv_ = vec3( xl_retval.viewDirT);
xlv_ = vec3( xl_retval.I);
xlv_ = vec3( xl_retval.TtoW0);
xlv_ = vec3( xl_retval.TtoW1);
xlv_ = vec3( xl_retval.TtoW2);
}
/* NOTE: GLSL optimization failed
0:340(26): error: identifier xlv__1' uses reserved __’ string
0:0(0): error: xlv_' redeclared*</em></em></em></em></em></em></em></em> <em><em><em><em><em><em><em><em>*0:0(0): error: xlv_’ redeclared
0:0(0): error: xlv_' redeclared*</em></em></em></em></em></em></em></em> <em><em><em><em><em><em><em><em>*0:0(0): error: xlv_’ redeclared
0:0(0): error: `xlv_’ redeclared
0:357(7): error: type mismatch
0:358(7): error: type mismatch
0:359(7): error: type mismatch
0:360(7): error: type mismatch
0:361(7): error: type mismatch
*/
-------- GLSL error: ERROR: 0:341: Type (vec3) of redeclaration of ‘xlv_’ is incompatible with type (vec2) of previous declaration
ERROR: 0:342: Type (vec3) of redeclaration of ‘xlv_’ is incompatible with type (vec2) of previous declaration
ERROR: 0:343: Type (vec3) of redeclaration of ‘xlv_’ is incompatible with type (vec2) of previous declaration
ERROR: 0:344: Type (vec3) of redeclaration of ‘xlv_’ is incompatible with type (vec2) of previous declaration
ERROR: 0:345: Type (vec3) of redeclaration of ‘xlv_’ is incompatible with type (vec2) of previous declaration
ERROR: 0:357: Incompatible types (vec2 and vec3) in assignment (and no available implicit conversion)
ERROR: 0:358: Incompatible types (vec2 and vec3) in assignment (and no available implicit conversion)
ERROR: 0:359: Incompatible types (vec2 and vec3) in assignment (and no available implicit conversion)
ERROR: 0:360: Incompatible types (vec2 and vec3) in assignment (and no available implicit conversion)
ERROR: 0:361: Incompatible types (vec2 and vec3) in assignment (and no available implicit conversion)

GLES20: failed to compile vertex shader:

#define SHADER_API_GLES 1
#define tex2D texture2D

#define gl_ModelViewProjectionMatrix glstate_matrix_mvp
uniform mat4 glstate_matrix_mvp;

#define SHADER_API_GLES 1
#define SHADER_API_MOBILE 1
#define gl_Vertex _glesVertex
attribute vec4 _glesVertex;
#define gl_Normal (normalize(_glesNormal))
attribute vec3 _glesNormal;
#define gl_MultiTexCoord0 _glesMultiTexCoord0
attribute vec4 _glesMultiTexCoord0;
#define TANGENT vec4(normalize(_glesTANGENT.xyz), _glesTANGENT.w)
attribute vec4 _glesTANGENT;
mat2 xll_transpose(mat2 m) {
return mat2( m[0][0], m[1][0], m[0][1], m[1][1]);
}
mat3 xll_transpose(mat3 m) {
return mat3( m[0][0], m[1][0], m[2][0],
m[0][1], m[1][1], m[2][1],
m[0][2], m[1][2], m[2][2]);
}
mat4 xll_transpose(mat4 m) {
return mat4( m[0][0], m[1][0], m[2][0], m[3][0],
m[0][1], m[1][1], m[2][1], m[3][1],
m[0][2], m[1][2], m[2][2], m[3][2],
m[0][3], m[1][3], m[2][3], m[3][3]);
}
mat3 xll_constructMat3( mat4 m) {
return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2]));
}
vec2 xll_matrixindex (mat2 m, int i) { vec2 v; v.x=m[0]; v.y=m[1]; return v; }
vec3 xll_matrixindex (mat3 m, int i) { vec3 v; v.x=m[0]; v.y=m[1]; v.z=m[2]; return v; }
vec4 xll_matrixindex (mat4 m, int i) { vec4 v; v.x=m[0]; v.y=m[1]; v.z=m[2]; v.w=m[3]; return v; }
#line 150
struct v2f_vertex_lit {
highp vec2 uv;
lowp vec4 diff;
lowp vec4 spec;
};
#line 186
struct v2f_img {
highp vec4 pos;
mediump vec2 uv;
};
#line 180
struct appdata_img {
highp vec4 vertex;
mediump vec2 texcoord;
};
#line 306
struct v2f {
highp vec4 pos;
highp vec2 uv[2];
highp vec3 viewDirT;
highp vec3 I;
highp vec3 TtoW0;
highp vec3 TtoW1;
highp vec3 TtoW2;
};
#line 58
struct appdata_tan {
highp vec4 vertex;
highp vec4 tangent;
highp vec3 normal;
highp vec4 texcoord;
};
uniform highp vec4 _MainTex_ST;
uniform highp mat4 _Object2World;
uniform highp vec4 _SparkleTex_ST;
uniform highp mat4 _World2Object;
uniform highp vec3 _WorldSpaceCameraPos;

uniform highp vec4 unity_Scale;
highp vec3 ObjSpaceViewDir( in highp vec4 v );
v2f vert( in appdata_tan v );
#line 90
highp vec3 ObjSpaceViewDir( in highp vec4 v ) {
highp vec3 objSpaceCameraPos;
objSpaceCameraPos = ((World2Object * vec4( WorldSpaceCameraPos.xyz, 1.0)).xyz * unity_Scale.w);
return (objSpaceCameraPos - v.xyz);

}
#line 321
v2f vert( in appdata_tan v ) {
v2f o;
highp vec3 objViewDir;
highp vec3 binormal;
highp mat3 rotation;
o.pos = (gl_ModelViewProjectionMatrix * v.vertex);
#line 325
o.uv[0] = ((v.texcoord.xy * MainTex_ST.xy) + MainTex_ST.zw);
o.uv[1] = ((v.texcoord.xy * SparkleTex_ST.xy) + SparkleTex_ST.zw);
objViewDir = ObjSpaceViewDir( v.vertex);

o.I = (xll_constructMat3( Object2World) * (-objViewDir));
#line 329

binormal = (cross( v.normal, v.tangent.xyz) * v.tangent.w);
rotation = xll_transpose(mat3( v.tangent.xyz, binormal, v.normal));
o.viewDirT = (rotation * objViewDir);
o.TtoW0 = (rotation * xll_matrixindex (Object2World, 0).xyz);
#line 333

o.TtoW1 = (rotation * xll_matrixindex (Object2World, 1).xyz);
o.TtoW2 = (rotation * xll_matrixindex (Object2World, 2).xyz);
return o;

}

varying highp vec2 xlv_;
varying highp vec2 xlv__1;
varying highp vec3 xlv_;
varying highp vec3 xlv_;
varying highp vec3 xlv_;
varying highp vec3 xlv_;
varying highp vec3 xlv_;
void main() {
v2f xl_retval;
appdata_tan xlt_v;
xlt_v.vertex = vec4( gl_Vertex);
xlt_v.tangent = vec4( TANGENT);
xlt_v.normal = vec3( gl_Normal);
xlt_v.texcoord = vec4( gl_MultiTexCoord0);
xl_retval = vert( xlt_v);
gl_Position = vec4( xl_retval.pos);
xlv_ = vec2( xl_retval.uv[0]);
xlv__1 = vec2( xl_retval.uv[1]);
xlv_ = vec3( xl_retval.viewDirT);
xlv_ = vec3( xl_retval.I);
xlv_ = vec3( xl_retval.TtoW0);
xlv_ = vec3( xl_retval.TtoW1);
xlv_ = vec3( xl_retval.TtoW2);
}
/* NOTE: GLSL optimization failed
0:340(26): error: identifier xlv__1' uses reserved __’ string
0:0(0): error: xlv_' redeclared*</em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em> <em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em>*0:0(0): error: xlv_’ redeclared
0:0(0): error: xlv_' redeclared*</em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em> <em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em>*0:0(0): error: xlv_’ redeclared
0:0(0): error: `xlv_’ redeclared
0:357(7): error: type mismatch
0:358(7): error: type mismatch
0:359(7): error: type mismatch
0:360(7): error: type mismatch
0:361(7): error: type mismatch
*/

The main problem is GLES20: failed to compile vertex shader. So I would suggest going to the build settings and making the OpenGL version lower. If that doesn’t work try higher.

I am getting the same problem. But open gles2.0 worked earlier so I won’t be switching to 1.x. And as I am developing for the iphone 4S I can’T use open gles 3.0. Any suggestions how to fix this?

I’ve found a solution to this here :

http://forum.unity3d.com/threads/glsl-optimization-failed-xlv_-redeclared.166629/#post-1140227

You need to specify the output semantics for all variables in your for anything other than normals, tangents, position and colour. You’ll need to use TEXCOORD0 through to TEXCOORD7.

This is only a problem on iOS for me. PC and Android both built without errors.