Vertex shader does not compile on Samsung Galaxy S10e

Hello, we are having issues with a vertex shader compiling on Samsung Galaxy S10e, here is error log:

2022-02-03 15:08:40.228 31775-31775/[redatced]/chromium:
[INFO:CONSOLE(6)] “Failed to compile vertex shader:
1: #version 300 es
2:
3:
4: #define attribute in
5: #define varying out
6: #define texture2D texture
7: #define GL2
8: #define VERTEXSHADER
9: varying vec4 vVertexColor;
10: varying vec3 vPositionW;
11: varying vec2 vUv0;
12: attribute vec3 vertex_position;
13: attribute vec3 vertex_normal;
14: attribute vec4 vertex_tangent;
15: attribute vec2 vertex_texCoord0;
16: attribute vec2 vertex_texCoord1;
17: attribute vec4 vertex_color;
18: uniform mat4 matrix_viewProjection;
19: uniform mat4 matrix_model;
20: uniform mat3 matrix_normal;
21: vec3 dPositionW;
22: mat4 dModelMatrix;
23: mat3 dNormalMatrix;
24: #ifdef NINESLICED
25: vec2 getUv0() {
26: vec2 uv = vertex_position.xz;
27: vec2 positiveUnitOffset = clamp(vertex_position.xz, vec2(0.0), vec2(1.0));
28: vec2 negativeUnitOffset = clamp(-vertex_position.xz, vec2(0.0), vec2(1.0));
29: uv += (-positiveUnitOffset * innerOffset.xy + negativeUnitOffset * innerOffset.zw) *
vertex_texCoord0.xy;
30: uv = uv * -0.5 + 0.5;
31: uv = uv * atlasRect.zw + atlasRect.xy;
32: vMask = vertex_texCoord0.xy;
33: return uv;
34: }
35: #else
36: vec2 getUv0() {
37: return vertex_texCoord0;
38: }
39: #endif
40: #define SCREENSPACE
41: #ifdef PIXELSNAP
42: uniform vec4 uScreenSize;
43: #endif
44: #ifdef MORPHING
45: uniform vec4 morph_weights_a;
46: uniform vec4 morph_weights_b;
47: #endif
48: #ifdef MORPHING_TEXTURE_BASED
49: uniform vec4 morph_tex_params;
50: vec2 getTextureMorphCoords() {
51: float vertexId = morph_vertex_id;
52: vec2 textureSize = morph_tex_params.xy;
53: vec2 invTextureSize = morph_tex_params.zw;
54: float morphGridV = floor(vertexId * invTextureSize.x);
55: float morphGridU = vertexId - (morphGridV * textureSize.x);
56: return (vec2(morphGridU, morphGridV) * invTextureSize) + (0.5 * invTextureSize);
57: }
58: #endif
59: #ifdef MORPHING_TEXTURE_BASED_POSITION
60: uniform highp sampler2D morphPositionTex;
61: #endif
62: mat4 getModelMatrix() {
63: #ifdef DYNAMICBATCH
64: return getBoneMatrix(vertex_boneIndices);
65: #elif defined(SKIN)
66: return matrix_model * getSkinMatrix(vertex_boneIndices, vertex_boneWeights);
67: #elif defined(INSTANCING)
68: return mat4(instance_line1, instance_line2, instance_line3, instance_line4);
69: #else
70: return matrix_model;
71: #endif
72: }
73: vec4 getPosition() {
74: dModelMatrix = getModelMatrix();
75: vec3 localPos = vertex_position;
76: #ifdef NINESLICED
77: localPos.xz *= outerScale;
78: vec2 positiveUnitOffset = clamp(vertex_position.xz, vec2(0.0), vec2(1.0));
79: vec2 negativeUnitOffset = clamp(-vertex_position.xz, vec2(0.0), vec2(1.0));
80: localPos.xz += (-positiveUnitOffset * innerOffset.xy + negativeUnitOffset * innerOffset.zw)
* vertex_texCoord0.xy;
81: vTiledUv = (localPos.xz - outerScale + innerOffset.xy) * -0.5 + 1.0;
82: localPos.xz *= -0.5;
83: localPos = localPos.xzy;
84: #endif
85: #ifdef MORPHING
86: #ifdef MORPHING_POS03
87: localPos.xyz += morph_weights_a[0] * morph_pos0;
88: localPos.xyz += morph_weights_a[1] * morph_pos1;
89: localPos.xyz += morph_weights_a[2] * morph_pos2;
90: localPos.xyz += morph_weights_a[3] * morph_pos3;
91: #endif
92: #ifdef MORPHING_POS47
93: localPos.xyz += morph_weights_b[0] * morph_pos4;
94: localPos.xyz += morph_weights_b[1] * morph_pos5;
95: localPos.xyz += morph_weights_b[2] * morph_pos6;
96: localPos.xyz += morph_weights_b[3] * morph_pos7;
97: #endif
98: #endif
99: #ifdef MORPHING_TEXTURE_BASED_POSITION
100: vec2 morphUV = getTextureMorphCoords();
101: vec3 morphPos = texture2D(morphPositionTex, morphUV).xyz;
102: localPos += morphPos;
103: #endif
104: vec4 posW = dModelMatrix * vec4(localPos, 1.0);
105: #ifdef SCREENSPACE
106: posW.zw = vec2(0.0, 1.0);
107: #endif
108: dPositionW = posW.xyz;
109: vec4 screenPos;
110: #ifdef UV1LAYOUT
111: screenPos = vec4(vertex_texCoord1.xy * 2.0 - 1.0, 0.5, 1);
112: #else
113: #ifdef SCREENSPACE
114: screenPos = posW;
115: #else
screenPos = matrix_viewProjection * posW;
117: #endif
118: #ifdef PIXELSNAP
119: screenPos.xy = (screenPos.xy * 0.5) + 0.5;
120: screenPos.xy *= uScreenSize.xy;
121: screenPos.xy = floor(screenPos.xy);
122: screenPos.xy *= uScreenSize.zw;
123: screenPos.xy = (screenPos.xy * 2.0) - 1.0;
124: #endif
125: #endif
126: return screenPos;
127: }
128: vec3 getWorldPosition() {
129: return dPositionW;
130: }
131:
132: void main(void) {
133: gl_Position = getPosition();
134: vPositionW = getWorldPosition();
135: vec2 uv0 = getUv0();
136: vUv0 = uv0;
137: vVertexColor = vertex_color;
138:
139: }
“, source: file:///data/user/0/[redacted]/games/32/185/playcanvas-stable.min.js (6)
2022-02-03 15:08:40.194 31775-32593/[redacted]/chromium:
[ERROR:gles2_cmd_decoder.cc(17520)] Offscreen context lost via ARB/EXT_robustness. Reset status
= GL_UNKNOWN_CONTEXT_RESET_KHR
2022-02-03 15:08:40.194 31775-32593/[redacted]/chromium:
[ERROR:gles2_cmd_decoder.cc(4924)] GLES2DecoderImpl: Context reset detected after
MakeCurrent.
2022-02-03 15:08:40.197 31775-32593/[redacted]/chromium:
[ERROR:shared_image_stub.cc(534)] SharedImageStub: context already lost

Hi @Isaiah_Smith,

It may be related to this issue:

If you are able post your findings there, and if it’s possible a sample project or build that reproduces the issue.

1 Like

Unfortunately I don’t have a 10e device to test it on so I will not be able to reproduce the issue with a new project, and we are unable to show our current project that’s getting this error /:
It does very much look like it is related to the issue you linked though. Seems like a new issue though, as it was posted only in the last 3 days? maybe reverting to a previous version of playcanvas could fix it?

It may be possible. If by any chance you can prepare test builds that possible reproduce this, feel free to share them either here or with a personal message.

I have a Samsung Galaxy S10 available and I can test.

You could try using engine 1.50.2 to see if that resolves the issue temporarily.

We are investigating but need to get the phone, update it etc

2 Likes

Reverting to the previous engine version [1.50.2] didn’t seem to fix it, I’ll try using webGL 1 and see if that does anything. otherwise I guess for now we’ll just wait and see

The Android 12 update doesn’t seem to have rolled out to all devices yet so we are looking at how to update to it :frowning:

Looks like its working on WebGL1, but it also considerably effects the game graphics, it appears the anti-aliasing is much lower quality. So I’d like to only use webgl1 conditionally if the shader fails to compile.

I tried modifying the code in __start__.js:

try {
        app = new pc.Application(canvas, {
            elementInput: devices.elementInput,
            keyboard: devices.keyboard,
            mouse: devices.mouse,
            gamepads: devices.gamepads,
            touch: devices.touch,
            graphicsDeviceOptions: window.CONTEXT_OPTIONS,
            assetPrefix: window.ASSET_PREFIX || "",
            scriptPrefix: window.SCRIPT_PREFIX || "",
            scriptsOrder: window.SCRIPTS || []
        });
    } catch (e) {
        arclib.logEvent("failed to initialize game", e);
        retry();
        return;
    }

but the pc.Application constructor doesn’t seem to throw an error, because that catch block never executes.

So it seems like the shader compile error is happening somewhere during runtime? Any ideas where it might be so I can catch it and reload the page with WebGL1?

something here fails https://github.com/playcanvas/engine/blob/dda9cf0c9a778f8a7588157eb22975793a41ecc2/src/graphics/graphics-device.js#L3424

but I’m not sure you can catch that one. Try?

Ah, okay thanks. I’ll give it a shot!