Shaders not compiling

Lately we’ve been having problems with internal Unity shaders not compiling. Here’s the error we’re getting:

could this be an internal UCB bug? It seems to happen randomly…

I have the same problem with iOS cloud builds.

102: [Unity] Shader compiler: internal error compiling shader snippet type=0 platform=5: Protocol error - failed to read correct magic number
103: [Unity] Shader error in ‘Unlit/Color’: Internal error communicating with the shader compiler process

When I build for iOS from my desktop I don’t get any errors.

Any advice?

We have the same thing with a third party plugin shader. It worked 10 builds and suddenly this error came up:

152: [Unity] Shader compiler: internal error compiling shader snippet type=0 platform=5: Protocol error - failed to read correct magic number
153: [Unity] Shader error in ‘TMPro/Sprite’: Internal error communicating with the shader compiler process

iOS Cloud Build, using Unity 5.3.1p3
It happens randomly. I made a clean build and it worked. Then two fails afterwards. Now waiting for the next try…

Hey UCB guys, is this a known issue / is it being worked on? It’s only happening on Cloud Build for us, local builds with the same version of Unity work fine…

+1 from here. This happens consistently on one particular Android build target, but not the others, which is incredibly confusing.

Hello,

This is a known issue that’s currently being worked out internally. I will update the thread when I’ve confirmed that it has been resolved.

Phew! Glad I’m not alone in this. Got it at first in the procedural skybox shader, but then I switched all cameras to use color to clear, and made sure lighting was set not to use it, and then got the same “magic number” error on the first shader it tried to compile. Error log listed here.

41482: [Unity] Shader compiler: exception while compiling shader snippet. Thread=469241856 Type=0 platform=14. Source:
41483: [Unity] #line 22 ""
41484: [Unity] #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING
41485: [Unity] #endif
41486: [Unity] #include "HLSLSupport.cginc"
41487: [Unity] #include "UnityShaderVariables.cginc"
41488: [Unity] #line 22 ""
41489: [Unity] #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING
41490: [Unity] #endif
41491: [Unity] #pragma target 3.0
41492: [Unity] #pragma glsl_no_auto_normalization
41493: [Unity] #pragma vertex vert
41494: [Unity] #pragma fragment frag
41495: [Unity] #pragma fragmentoption ARB_precision_hint_fastest
41496: [Unity] #include "UnityCG.cginc"
41497: [Unity] #include "LineDrawing.cginc"
41498: [Unity] #include "LambertProjection.cginc"
41499: [Unity] #include "ColorPalette.cginc"
41500: [Unity] float _LineWidth;
41501: [Unity] float _LinePercent;
41502: [Unity] float _Gradient;
41503: [Unity] struct appdata {
41504: [Unity] float4 vertex : POSITION;
41505: [Unity] float3 normal : NORMAL;
41506: [Unity] float4 tangent : TANGENT;
41507: [Unity] float2 texcoord: TEXCOORD0;
41508: [Unity] };
41509: [Unity] struct v2f {
41510: [Unity] float4 pos : SV_POSITION;
41511: [Unity] float2 uv : TEXCOORD0;
41512: [Unity] float4 color : COLOR;
41513: [Unity] float3 normal : NORMAL;
41514: [Unity] };
41515: [Unity] v2f vert (appdata v)
41516: [Unity] {
41517: [Unity] v2f o;
41518: [Unity] float alpha;
41519: [Unity] //o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
41520: [Unity] v.tangent.w *= _LineWidth;
41521: [Unity] float4 tv = mul(_Object2World, v.vertex);
41522: [Unity] tv = LabertPos(tv, alpha);
41523: [Unity] tv = RibbonPosMitreNoVP(tv, v.normal, v.tangent);
41524: [Unity] o.normal = normalize(tv);
41525: [Unity] o.pos = mul(UNITY_MATRIX_VP, tv);
41526: [Unity] //since i know that this is on a sphere, the normal is just the normalized position.
41527: [Unity] //could optimize above
41528: [Unity] alpha = pow(alpha,0.8);
41529: [Unity] o.color = EncodeFloatRGBA(alpha);
41530: [Unity] //o.pos.xyz += o.normal*_LineWidth;
41531: [Unity] o.uv = MultiplyUV (UNITY_MATRIX_TEXTURE0, v.texcoord);
41532: [Unity] return o;
41533: [Unity] }
41534: [Unity] float4 frag (v2f i) : COLOR
41535: [Unity] {
41536: [Unity] float4 outColor = _ColorFound;
41537: [Unity] //(+ 0.25*_LineWidth)
41538: [Unity] float widthAlias = abs(i.uv.x - 0.5)* 2;
41539: [Unity] widthAlias = (1- widthAlias) ;
41540: [Unity] widthAlias *= 0.5 * _LineWidth;
41541: [Unity] widthAlias = saturate(widthAlias);
41542: [Unity] outColor.a = widthAlias;
41543: [Unity] float percent = saturate(i.uv.y - _LinePercent) * (1/_LinePercent);
41544: [Unity] percent *= _Gradient;//this should really be tied to "total length of line". hmmm.
41545: [Unity] percent = saturate(1-percent);
41546: [Unity] //float percent = 1.0f - saturate( (i.uv.y - _LinePercent) * _Gradient));
41547: [Unity] outColor.a *= percent;
41548: [Unity] //outColor.a *= i.uv.y;
41549: [Unity] outColor.a *= DecodeFloatRGBA(i.color);
41550: [Unity] //liney modulator
41551: [Unity] /* float liney = (abs((frac((_Time.x * -150) + (i.uv.y * 25)-0.5)) * 2)-0.5) * 2;
41552: [Unity] outColor.a *= liney;*/
41553: [Unity] return outColor ;//* i.color;
41554: [Unity] }
41555: [Unity] Shader compiler: internal error compiling shader snippet type=0 platform=14: Protocol error - failed to read correct magic number
41556: [Unity] Shader error in 'LineDrawer/LineProgess': Internal error communicating with the shader compiler process
41557: [Unity] (Filename: LineProgressBar Line: -1)

2685548–189876–LineProgressBar.shader (2.73 KB)

What’s the status on this? We’re still getting the error and it’s making UCB more or less unusable for us.

Hi there,

I’m currently targeting this issue for a fix, can you please direct message me links to builds in Cloud Build that are displaying these errors? Thanks.

When messaging me your link, please also mention which OS and Unity version you are using to build successfully on your local machine. Thanks!

Have other people had this issue resolved for them? I’m still getting it:

[Unity] Shader compiler: internal error compiling shader snippet type=0 platform=5: Protocol error - failed to read correct magic number
71: [Unity] Shader error in ‘Sprites/Default’: Internal error communicating with the shader compiler process

I also started having the same issue

7619: [Unity] Shader compiler: exception while compiling shader snippet. Thread=1946984448 Type=0 platform=5. Source:
7620: [Unity] #line 26 ""
7621: [Unity] #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING
7622: [Unity] #endif
7623: [Unity] #include "HLSLSupport.cginc"
7624: [Unity] #include "UnityShaderVariables.cginc"
7625: [Unity] #line 26 ""
7626: [Unity] #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING
7627: [Unity] #endif
7628: [Unity]             #pragma vertex vert
7629: [Unity]             #pragma fragment frag
7630: [Unity]             #pragma target 2.0
7631: [Unity]             #pragma multi_compile _ PIXELSNAP_ON
7632: [Unity]             #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
7633: [Unity]             #include "UnityCG.cginc"
7634: [Unity]             struct appdata_t
7635: [Unity]             {
7636: [Unity]                 float4 vertex   : POSITION;
7637: [Unity]                 float4 color    : COLOR;
7638: [Unity]                 float2 texcoord : TEXCOORD0;
7639: [Unity]             };
7640: [Unity]             struct v2f
7641: [Unity]             {
7642: [Unity]                 float4 vertex   : SV_POSITION;
7643: [Unity]                 fixed4 color    : COLOR;
7644: [Unity]                 float2 texcoord  : TEXCOORD0;
7645: [Unity]             };
7646: [Unity]             fixed4 _Color;
7647: [Unity]             v2f vert(appdata_t IN)
7648: [Unity]             {
7649: [Unity]                 v2f OUT;
7650: [Unity]                 OUT.vertex = UnityObjectToClipPos(IN.vertex);
7651: [Unity]                 OUT.texcoord = IN.texcoord;
7652: [Unity]                 OUT.color = IN.color * _Color;
7653: [Unity]                 #ifdef PIXELSNAP_ON
7654: [Unity]                 OUT.vertex = UnityPixelSnap (OUT.vertex);
7655: [Unity]                 #endif
7656: [Unity]                 return OUT;
7657: [Unity]             }
7658: [Unity]             sampler2D _MainTex;
7659: [Unity]             sampler2D _AlphaTex;
7660: [Unity]             fixed4 SampleSpriteTexture (float2 uv)
7661: [Unity]             {
7662: [Unity]                 fixed4 color = tex2D (_MainTex, uv);
7663: [Unity] #if ETC1_EXTERNAL_ALPHA
7664: [Unity]                 // get the color from an external texture (usecase: Alpha support for ETC1 on android)
7665: [Unity]                 color.a = tex2D (_AlphaTex, uv).r;
7666: [Unity] #endif //ETC1_EXTERNAL_ALPHA
7667: [Unity]                 return color;
7668: [Unity]             }
7669: [Unity]             fixed4 frag(v2f IN) : SV_Target
7670: [Unity]             {
7671: [Unity]                 fixed4 c = SampleSpriteTexture (IN.texcoord) * IN.color;
7672: [Unity]                 c.rgb *= c.a;
7673: [Unity]                 return c;
7674: [Unity]             }
7675: [Unity] Shader compiler: internal error compiling shader snippet type=0 platform=5: Protocol error - failed to read correct magic number
7676: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, BuildTarget, BuildOptions, Boolean)
7677: [Unity] UnityEditor.CloudBuild.Builder:Build()
7678: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.07 seconds
7679: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.11 seconds
7680: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.07 seconds
7681: [Unity] Shader compiler: UnityShaderCompiler compiler executable disappeared on thread 1946984448, restarting
7682: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.06 seconds
7683: [Unity] Compiled shader 'Sprites/Default' (total internal programs: 12, unique: 4) in 2.76s
7684: [Unity] Shader error in 'Sprites/Default': Internal error communicating with the shader compiler process
7685: [Unity] (Filename: Sprites-Default Line: -1)

6607: [Unity] Shader compiler: exception while compiling shader snippet. Thread=2094153728 Type=0 platform=5. Source:
6608: [Unity] #line 65 “”
6609: [Unity] #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING
6610: [Unity] #endif
6611: [Unity] #include “HLSLSupport.cginc”
6612: [Unity] #include “UnityShaderVariables.cginc”
6613: [Unity] #line 48
6614: [Unity] #define UNITY_SETUP_BRDF_INPUT SpecularSetup
6615: [Unity] #line 65 “”
6616: [Unity] #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING
6617: [Unity] #endif
6618: [Unity] #pragma target 3.0
6619: [Unity] #pragma shader_feature _NORMALMAP
6620: [Unity] #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
6621: [Unity] #pragma shader_feature _EMISSION
6622: [Unity] #pragma shader_feature _SPECGLOSSMAP
6623: [Unity] #pragma shader_feature ___ _DETAIL_MULX2
6624: [Unity] #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
6625: [Unity] #pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
6626: [Unity] #pragma shader_feature _ _GLOSSYREFLECTIONS_OFF
6627: [Unity] #pragma shader_feature _PARALLAXMAP
6628: [Unity] #pragma multi_compile_fwdbase
6629: [Unity] #pragma multi_compile_fog
6630: [Unity] #pragma vertex vertBase
6631: [Unity] #pragma fragment fragBase
6632: [Unity] #include “UnityStandardCoreForward.cginc”
6633: [Unity] Shader compiler: internal error compiling shader snippet type=0 platform=5: Protocol error - failed to read correct magic number
6634: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[ ], String, BuildTarget, BuildOptions, Boolean)
6635: [Unity] UnityEditor.CloudBuild.Builder:Build()
6636: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.07 seconds
6637: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.07 seconds
6638: [Unity] Shader compiler: UnityShaderCompiler compiler executable disappeared on thread 2094153728, restarting
6639: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.06 seconds
6640: [Unity] Compiled shader ‘Standard (Specular setup)’ (total internal programs: 612, unique: 284) in 58.26s
6641: [Unity] Shader error in ‘Standard (Specular setup)’: Internal error communicating with the shader compiler process

Getting this almost every day on two different projects. Also get ‘unable to clone remote repo’ and
ERROR: prebuildstatus failed!
ERROR: pre-build step failed to setup environment
Finished: FAILURE

All three errors have in common that if I have the patience for it, they will eventually succeed after I hit build 2-3 times.
Unity cloud build is so unstable at this point for us that it is virtually unusable. At least we didn’t pay for it - yet (free plan expires oct 28th)

Hi All,
I’m also getting this kind of error when using the cloud build for iOS. My Unity ver is 5.5:

Shader compiler: internal error compiling shader snippet type=0 platform=5: Protocol error - failed to read correct magic number
7257: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[ ], String, String, BuildTarget, BuildOptions, Boolean)
7258: [Unity] UnityEditor.CloudBuild.Builder:Build()
7259: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.08 seconds
7260: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.08 seconds
7261: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.09 seconds
7262: [Unity] Shader compiler: UnityShaderCompiler compiler executable disappeared on thread 2062610432, restarting
7263: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.06 seconds
7264: [Unity] Compiled shader ‘Sprites/Default’ in 1.58s
7265: [Unity] gles (total internal programs: 11, unique: 7)
7266: [Unity] metal (total internal programs: 12, unique: 11)
7267: [Unity] Shader error in ‘Sprites/Default’: Internal error communicating with the shader compiler process

Is there anything new with this issue?

So what’s the status on this @unitychrism ?

We get this when trying a cloud build for Android also:

493: [Unity] Shader compiler: internal error compiling shader snippet type=0 platform=5: Protocol error - failed to read correct magic number
494: [Unity] Shader error in ‘GoogleVR/UnlitTexture’: Internal error communicating with the shader compiler process

“Internal error communicating with the shader compiler process”

Same error here for both iOS & Android. I had to manually start building five times before having one that succeeded. It is quite annoying.

I am considering writing a script that searches through the build log if the build fails, looking for the shader compile error, and then re-launches the build until it succeeds.

I get this error when building on UCB. Is the solution to start the build again? There is no intent to resolve this old bug?

Just got this in a cloud build ourselves for Windows 64 platform using Unity v5.6. We’ll try AM-Dev’s suggestion of a clean build and see where that gets us. @unitychrism , are you still looking for build logs with this error?

Is there any solution as of yet?