Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Shaders not compiling

Discussion in 'Unity Cloud Build' started by mihakinova, May 31, 2016.

  1. mihakinova

    mihakinova

    Joined:
    Jan 6, 2015
    Posts:
    85
    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...
     
  2. andreasdkt

    andreasdkt

    Joined:
    Aug 31, 2013
    Posts:
    9
    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?
     
  3. AM-Dev

    AM-Dev

    Joined:
    Aug 5, 2015
    Posts:
    30
    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...
     
  4. mihakinova

    mihakinova

    Joined:
    Jan 6, 2015
    Posts:
    85
    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...
     
  5. jacobarchiact

    jacobarchiact

    Joined:
    May 10, 2016
    Posts:
    1
    +1 from here. This happens consistently on one particular Android build target, but not the others, which is incredibly confusing.
     
  6. unitychrism

    unitychrism

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    122
    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.
     
  7. Bezzy

    Bezzy

    Joined:
    Apr 1, 2009
    Posts:
    75
    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.

    Code (csharp):
    1.  
    2. 41482: [Unity] Shader compiler: exception while compiling shader snippet. Thread=469241856 Type=0 platform=14. Source:
    3. 41483: [Unity] #line 22 ""
    4. 41484: [Unity] #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING
    5. 41485: [Unity] #endif
    6. 41486: [Unity] #include "HLSLSupport.cginc"
    7. 41487: [Unity] #include "UnityShaderVariables.cginc"
    8. 41488: [Unity] #line 22 ""
    9. 41489: [Unity] #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING
    10. 41490: [Unity] #endif
    11. 41491: [Unity] #pragma target 3.0
    12. 41492: [Unity] #pragma glsl_no_auto_normalization
    13. 41493: [Unity] #pragma vertex vert
    14. 41494: [Unity] #pragma fragment frag
    15. 41495: [Unity] #pragma fragmentoption ARB_precision_hint_fastest
    16. 41496: [Unity] #include "UnityCG.cginc"
    17. 41497: [Unity] #include "LineDrawing.cginc"
    18. 41498: [Unity] #include "LambertProjection.cginc"
    19. 41499: [Unity] #include "ColorPalette.cginc"
    20. 41500: [Unity] float _LineWidth;
    21. 41501: [Unity] float _LinePercent;
    22. 41502: [Unity] float _Gradient;
    23. 41503: [Unity] struct appdata {
    24. 41504: [Unity] float4 vertex : POSITION;
    25. 41505: [Unity] float3 normal : NORMAL;
    26. 41506: [Unity] float4 tangent : TANGENT;
    27. 41507: [Unity] float2 texcoord: TEXCOORD0;
    28. 41508: [Unity] };
    29. 41509: [Unity] struct v2f {
    30. 41510: [Unity] float4 pos : SV_POSITION;
    31. 41511: [Unity] float2 uv : TEXCOORD0;
    32. 41512: [Unity] float4 color : COLOR;
    33. 41513: [Unity] float3 normal : NORMAL;
    34. 41514: [Unity] };
    35. 41515: [Unity] v2f vert (appdata v)
    36. 41516: [Unity] {
    37. 41517: [Unity] v2f o;
    38. 41518: [Unity] float alpha;
    39. 41519: [Unity] //o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    40. 41520: [Unity] v.tangent.w *= _LineWidth;
    41. 41521: [Unity] float4 tv = mul(_Object2World, v.vertex);
    42. 41522: [Unity] tv = LabertPos(tv, alpha);
    43. 41523: [Unity] tv = RibbonPosMitreNoVP(tv, v.normal, v.tangent);
    44. 41524: [Unity] o.normal = normalize(tv);
    45. 41525: [Unity] o.pos = mul(UNITY_MATRIX_VP, tv);
    46. 41526: [Unity] //since i know that this is on a sphere, the normal is just the normalized position.
    47. 41527: [Unity] //could optimize above
    48. 41528: [Unity] alpha = pow(alpha,0.8);
    49. 41529: [Unity] o.color = EncodeFloatRGBA(alpha);
    50. 41530: [Unity] //o.pos.xyz += o.normal*_LineWidth;
    51. 41531: [Unity] o.uv = MultiplyUV (UNITY_MATRIX_TEXTURE0, v.texcoord);
    52. 41532: [Unity] return o;
    53. 41533: [Unity] }
    54. 41534: [Unity] float4 frag (v2f i) : COLOR
    55. 41535: [Unity] {
    56. 41536: [Unity] float4 outColor = _ColorFound;
    57. 41537: [Unity] //(+ 0.25*_LineWidth)
    58. 41538: [Unity] float widthAlias = abs(i.uv.x - 0.5)* 2;
    59. 41539: [Unity] widthAlias = (1- widthAlias) ;
    60. 41540: [Unity] widthAlias *= 0.5 * _LineWidth;
    61. 41541: [Unity] widthAlias = saturate(widthAlias);
    62. 41542: [Unity] outColor.a = widthAlias;
    63. 41543: [Unity] float percent = saturate(i.uv.y - _LinePercent) * (1/_LinePercent);
    64. 41544: [Unity] percent *= _Gradient;//this should really be tied to "total length of line". hmmm.
    65. 41545: [Unity] percent = saturate(1-percent);
    66. 41546: [Unity] //float percent = 1.0f - saturate( (i.uv.y - _LinePercent) * _Gradient));
    67. 41547: [Unity] outColor.a *= percent;
    68. 41548: [Unity] //outColor.a *= i.uv.y;
    69. 41549: [Unity] outColor.a *= DecodeFloatRGBA(i.color);
    70. 41550: [Unity] //liney modulator
    71. 41551: [Unity] /* float liney = (abs((frac((_Time.x * -150) + (i.uv.y * 25)-0.5)) * 2)-0.5) * 2;
    72. 41552: [Unity] outColor.a *= liney;*/
    73. 41553: [Unity] return outColor ;//* i.color;
    74. 41554: [Unity] }
    75. 41555: [Unity] Shader compiler: internal error compiling shader snippet type=0 platform=14: Protocol error - failed to read correct magic number
    76. 41556: [Unity] Shader error in 'LineDrawer/LineProgess': Internal error communicating with the shader compiler process
    77. 41557: [Unity] (Filename: LineProgressBar Line: -1)
    78.  
     

    Attached Files:

  8. mihakinova

    mihakinova

    Joined:
    Jan 6, 2015
    Posts:
    85
    What's the status on this? We're still getting the error and it's making UCB more or less unusable for us.
     
  9. unitychrism

    unitychrism

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    122
    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.
     
  10. unitychrism

    unitychrism

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    122
    When messaging me your link, please also mention which OS and Unity version you are using to build successfully on your local machine. Thanks!
     
  11. JACKARY

    JACKARY

    Joined:
    Nov 18, 2014
    Posts:
    4
    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
     
  12. moonabook

    moonabook

    Joined:
    Dec 4, 2014
    Posts:
    4
    I also started having the same issue
    Code (CSharp):
    1. 7619: [Unity] Shader compiler: exception while compiling shader snippet. Thread=1946984448 Type=0 platform=5. Source:
    2. 7620: [Unity] #line 26 ""
    3. 7621: [Unity] #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING
    4. 7622: [Unity] #endif
    5. 7623: [Unity] #include "HLSLSupport.cginc"
    6. 7624: [Unity] #include "UnityShaderVariables.cginc"
    7. 7625: [Unity] #line 26 ""
    8. 7626: [Unity] #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING
    9. 7627: [Unity] #endif
    10. 7628: [Unity]             #pragma vertex vert
    11. 7629: [Unity]             #pragma fragment frag
    12. 7630: [Unity]             #pragma target 2.0
    13. 7631: [Unity]             #pragma multi_compile _ PIXELSNAP_ON
    14. 7632: [Unity]             #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
    15. 7633: [Unity]             #include "UnityCG.cginc"
    16. 7634: [Unity]             struct appdata_t
    17. 7635: [Unity]             {
    18. 7636: [Unity]                 float4 vertex   : POSITION;
    19. 7637: [Unity]                 float4 color    : COLOR;
    20. 7638: [Unity]                 float2 texcoord : TEXCOORD0;
    21. 7639: [Unity]             };
    22. 7640: [Unity]             struct v2f
    23. 7641: [Unity]             {
    24. 7642: [Unity]                 float4 vertex   : SV_POSITION;
    25. 7643: [Unity]                 fixed4 color    : COLOR;
    26. 7644: [Unity]                 float2 texcoord  : TEXCOORD0;
    27. 7645: [Unity]             };
    28. 7646: [Unity]             fixed4 _Color;
    29. 7647: [Unity]             v2f vert(appdata_t IN)
    30. 7648: [Unity]             {
    31. 7649: [Unity]                 v2f OUT;
    32. 7650: [Unity]                 OUT.vertex = UnityObjectToClipPos(IN.vertex);
    33. 7651: [Unity]                 OUT.texcoord = IN.texcoord;
    34. 7652: [Unity]                 OUT.color = IN.color * _Color;
    35. 7653: [Unity]                 #ifdef PIXELSNAP_ON
    36. 7654: [Unity]                 OUT.vertex = UnityPixelSnap (OUT.vertex);
    37. 7655: [Unity]                 #endif
    38. 7656: [Unity]                 return OUT;
    39. 7657: [Unity]             }
    40. 7658: [Unity]             sampler2D _MainTex;
    41. 7659: [Unity]             sampler2D _AlphaTex;
    42. 7660: [Unity]             fixed4 SampleSpriteTexture (float2 uv)
    43. 7661: [Unity]             {
    44. 7662: [Unity]                 fixed4 color = tex2D (_MainTex, uv);
    45. 7663: [Unity] #if ETC1_EXTERNAL_ALPHA
    46. 7664: [Unity]                 // get the color from an external texture (usecase: Alpha support for ETC1 on android)
    47. 7665: [Unity]                 color.a = tex2D (_AlphaTex, uv).r;
    48. 7666: [Unity] #endif //ETC1_EXTERNAL_ALPHA
    49. 7667: [Unity]                 return color;
    50. 7668: [Unity]             }
    51. 7669: [Unity]             fixed4 frag(v2f IN) : SV_Target
    52. 7670: [Unity]             {
    53. 7671: [Unity]                 fixed4 c = SampleSpriteTexture (IN.texcoord) * IN.color;
    54. 7672: [Unity]                 c.rgb *= c.a;
    55. 7673: [Unity]                 return c;
    56. 7674: [Unity]             }
    57. 7675: [Unity] Shader compiler: internal error compiling shader snippet type=0 platform=5: Protocol error - failed to read correct magic number
    58. 7676: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, BuildTarget, BuildOptions, Boolean)
    59. 7677: [Unity] UnityEditor.CloudBuild.Builder:Build()
    60. 7678: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.07 seconds
    61. 7679: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.11 seconds
    62. 7680: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.07 seconds
    63. 7681: [Unity] Shader compiler: UnityShaderCompiler compiler executable disappeared on thread 1946984448, restarting
    64. 7682: [Unity] Launched and connected shader compiler UnityShaderCompiler after 0.06 seconds
    65. 7683: [Unity] Compiled shader 'Sprites/Default' (total internal programs: 12, unique: 4) in 2.76s
    66. 7684: [Unity] Shader error in 'Sprites/Default': Internal error communicating with the shader compiler process
    67. 7685: [Unity] (Filename: Sprites-Default Line: -1)
     
  13. fsekking

    fsekking

    Joined:
    Apr 30, 2015
    Posts:
    2
    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
     
  14. andersemil

    andersemil

    Joined:
    Feb 2, 2015
    Posts:
    53
    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)
     
  15. Bruder

    Bruder

    Joined:
    Aug 9, 2014
    Posts:
    52
    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?
     
  16. GuyTidhar

    GuyTidhar

    Joined:
    Jun 24, 2009
    Posts:
    320
    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
     
  17. FaetterJens

    FaetterJens

    Joined:
    Aug 18, 2015
    Posts:
    10
    "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.
     
  18. bjornrun

    bjornrun

    Joined:
    Oct 29, 2013
    Posts:
    87
    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?
     
  19. ttrage

    ttrage

    Joined:
    Jun 12, 2017
    Posts:
    1
    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?
     
  20. AmbroseNilam

    AmbroseNilam

    Joined:
    Jun 27, 2017
    Posts:
    2
    Is there any solution as of yet?

     
  21. SamuelGoldenbaum

    SamuelGoldenbaum

    Joined:
    May 21, 2017
    Posts:
    30
    any progress here. we dead in the water
     
  22. PhilMcJ

    PhilMcJ

    Unity Technologies

    Joined:
    May 29, 2014
    Posts:
    187
    There are a couple of threads on this issue in the forum. For a quick summary in this thread: there's a known shader instability (crash) that can happen in Unity, which Cloud Build seems particularly prone to experience. It's rare overall even still in Cloud Build, but what we've observed is that when a particular project runs into this error, it tends to happen to that project repeatedly.

    The good news is that a cause of that crash has been spotted, and a fix is making its way into the Unity source trunk and is being backported to other versions now. We'll post an update to the forums very soon when we know exactly which releases will include the fix. (We can't guarantee that will be a complete fix for all cases of the issue, due to the crazy nature of this crash, but in testing here it's made a dramatic difference.) In the meantime, in the team's experience, rebuilding a project with the library cache enabled will eventually make it past that error, although for some shaders/projects it can take repeated rebuild attempts. (We are very, very eager for this fix to be released accordingly!)
     
  23. EgoAnt

    EgoAnt

    Joined:
    Dec 13, 2014
    Posts:
    19
    Thanks, I'll keep trying. Hopefully the fix comes soon!
     
  24. chriszul

    chriszul

    Joined:
    Feb 13, 2018
    Posts:
    21
    Could this problem still be an issue in a more specific case? I have a cloud build which is generating an android app which is running, but the textures are not rendering properly on the device. They're showing up purple. Adb log shows shader compilation errors on the device. This only happens with etc1 textures, which are in texture atlases. I switch to etc2 and its fine. Is there any shader options I need to set in cloud build to make sure the right shaders are built into my apk?