Shader Error in 'Skybox/Procedural': Internal error communicating with the shader compiler process

My PC specs:
Intel Xeon CPU E3-1230 V2 @ 3.30GHz 3.30GHz
16 GB RAM memory
64-bit Windows 7 Professional SP1
NVIDIA GeForce GTX 660 Ti
DirectX version 11.0

My PC runs fine on Unity 5.2.4 and previous versions.

The problem starts when installing Unity 5.3.0, 5.3.1, … , 5.4.0b2.

PROBLEM 1

After installing Unity 5.4.0b2 (same for up to 5.3.0), I start Unity with a new empty project. Unity starts super low, almost hangs there for 5 or 7 minutes. Also, Unity closes super low.


At first, it starts with some white areas.


Lots of spikes on CPU & Memory usage just to start the Unity & even close the Unity.

Unity often “Not Responding” so many times ><.

After 5 or 7 minutes, finally Unity opens with a pink Skybox issue. Here is the error messages:

Shader compiler: internal error initializing platforms: Protocol error - failed to read correct magic number
Shader compiler: internal error compiling shader snippet type=0 platform=4: Failed writing data to socket
Shader compiler: internal error compiling shader snippet type=1 platform=4: Failed writing data to socket
Shader error in ‘Skybox/Procedural’: Internal error communicating with the shader compiler process

Temporary disable Skybox display from Editor window, and set Camera Clear Flags to Solid Color, can hide the pink Skybox. But, the Skybox compiling issue makes the whole Unity engine too slow & often not responding.

I quickly scan through “Editor.log” & “Editor-prev.log”. It looks like there are some Shader compiler exceptions. But, I’m totally noob on shading languages to be able to fix it.

ANOTHER BUG
When I press Play, Unity often hangs. I need to end some “adb.exe * 32” processes in order for the Unity to be able to play the scene.

I try to explain as much info as possible. I hope you guys can help me to fix the annoying Shader Compiler exceptions.

2472208–170248–Editor.log.txt (92.1 KB)
2472208–170249–Editor-prev.log.txt (99.5 KB)

any Unity staff can help me. It’s pretty frustrated that I cannot use any version after 5.2.4.

Hi,

Same problem here :frowning: with unity 5.3.1f1 and shader compiler.

Hi there,

From the error messages you are getting, it seems that Unity is able to successfully open a socket to the shader compiler (using networking, but local to your PC and not visible to the internet) but seems to fail on every attempt to read or write with it.

Can you give more information about your environment? Do you have any anti-virus or firewall/internet security program running? This would include e.g. the default windows firewall. Make sure that any such program isn’t blocking either Unity.exe or UnityShaderCompiler.exe from network access.

Also can you create a new project to reproduce the problem, then attach the shader compiler logs in Library/ of the project, there should be at least a Library/shadercompiler-UnityShaderCompiler.exe0.log, but upload any others that are there.

Hi there,

Thanks for the help. I’m quite disappointed at Unity staff, since no reply anything from here. Unity Pro support seems not promised. Anyway, I do have the default Windows Firewall turn on, Microsoft Security Essentials and System Mechanic. Thanks for the hints, I will try and let you guys know soon.

@unity_baldurk : I followed your guide. Here are my steps:

  • Uninstall Unity 5.2.4f1, which for me, is the most stable version. Restart the computer.
  • Delete these folders, to ensure a clean install for Unity 5.3.1f1.
    C:\Users.…\AppData\Local\Unity
    C:\Users.…\AppData\LocalLow\Unity
    C:\Users.…\AppData\Roaming\Unity
    C:\Program Files\Unity
  • Install Unity 5.3.1f1 64-bit & create a new project. All the issues are the same as described above with Unity 5.4.0b2.

I got a new DockArea.OnGUI issuse, which I don’t have with Unity 5.4.0b2.

Shader compiler: internal error initializing platforms: Protocol error - failed to read correct magic number
UnityEditor.DockArea:OnGUI()
Shader compiler: internal error compiling shader snippet type=0 platform=4: Failed writing data to socket
UnityEditor.DockArea:OnGUI()
Shader compiler: internal error compiling shader snippet type=1 platform=4: Failed writing data to socket
UnityEditor.DockArea:OnGUI()
Shader error in ‘Skybox/Procedural’: Internal error communicating with the shader compiler process

The error messages are no longer displayed when I press Play button. The pink Skybox is still there. The weird slow performance of the Unity system is still there btw.

“shadercompiler-UnityShaderCompiler.exe0.log” is attached. I hope you can help me to figure out what is my problem. I’m planning to buy a new Graphic Card ( because I think my GTX 660 Ti conflicts with whatever Unity Shaders somehow).

2485055–171307–shadercompiler-UnityShaderCompiler.exe0.log.txt (47 Bytes)

Thanks. Unfortunately that log doesn’t shed any more light - just that network communication with the shader compiler failed pretty much immediately after it was launched. Something is going catastrophically wrong with the networking.

Just to be clear - have you tried temporarily disabling/turning off all features of Windows Firewall, Microsoft Security Essentials, and System Mechanic? If you want you can do this while disconnected from any network for safety and turn them on after. This way we can eliminate them as a possibility.

I don’t believe this error is in any way related to your graphics card - the failure is much earlier, in the communication with the shader compiler. The pre-compiled shaders used to render the editor interface are all working since they don’t have to communicate with the shader compiler to compile.

I’m looking to see if I can arrange getting a build to you with extra logging to try and find out where the error is, but there are a couple of advanced system monitoring tools you can use to monitor the network activity, which might shed some light.

The easiest one to try is Process Monitor from Microsoft. Download it from the link - it’s just a zip with a exe inside, you can extract it anywhere and run.

When you load the program after the license agreement popup, it will look something like this (the events will be different):

The first step is to filter all of these events down to just the ones we care about. Open the Filter menu and click Filter. Then you can choose ‘Process Name’ ‘contains’ ‘Unity’ and click Add, like this:

2485132--171318--procmon3.png

Finally click OK and go back to the main window, and you will see the events (this list will be empty if you don’t have Unity open). You can clear the list with the button highlighted in blue, and with the buttons in red you can further narrow down to only networking events - in this screenshot I have already deselected other event types:

With process monitor running with this filter, can you please start Unity from fresh and create a new project to repro the problem you are seeing. Then when you have all of the events in process monitor, you can go file → save and save the events displayed as PML file. If you upload that I can take a look and see if there’s any more information.

1 Like

I will try it tomorrow, and let you know soon. Thanks so much for the helps so far, really appreciated it :slight_smile:

@unity_baldurk is Unity staff :wink:

Aras: my bad, since his username does not have a Unity badge. I thought he is just a nice guy, trying to help.

@unity_baldurk : Here are my steps:

  • turn off Microsoft Security Essentials, Microsoft Firewalls, System Mechanics.
  • Install Unity 5.3.1f1.
  • run Process Monitor, filter Unity process only, Show Network Activity filter only ON, Clear the list before create a new project.
  • run Unity, create a new project, wait for 3 or 5 minutes until Unity finally starts with pink shader issues.
  • Save the events as PML file.

PML File link (I can’t upload it directly from Unity forum)

I think you may be interested in looking PML file of Unity 5.2, which has no errors.

Same problem here on Unity 5.3.1p3 and OS X 10.11.3:

Unhandled exception: Protocol error - failed to read correct magic number
Quitting shader compiler process

Thank you @ikemen_blueD . The logfile doesn’t have anything crucial in it but it does tell us that for some reason the network attempts aren’t even showing up as unsuccessful in the log, they are completely gone (I don’t know though exactly how they would show up).

I’m working on putting together a special build for you that will have more logging but I don’t want to waste your time going back and forth so I’m going to talk to networking people here to figure out what information we want to debug. That will be ready next week I hope.

In the meantime I have written a very simple winsock application from scratch that replicates most of the important parts of how the unity ↔ unityshadercompiler communication works. I’ve uploaded a zip here with two exes, named Unity.exe and UnityShaderCompiler.exe. You can run Unity.exe, and it will launch UnityShaderCompiler. Then you can type in the Unity window and the messages will be sent back and forth using the same network communication.

This exe has some more specific error message popups in it, but I’m mostly interested to see whether or not you get the problem reproducing at all on this small test case. Very unscientifically, for me and a few others here in the office it works fine without errors.

If you’re worried about running random exes, then you can compile it from source code yourself (I included the C++ source file, you can compile it and copy to both exe names).

@daisyDynamics that error message can happen if the shader compiler encounters a problem as well, which is most commonly due to a crash in the actual shader compiling step (especially if it only happens compiling one particular shader). @ikemen_blueD 's problem is unique in that the shader compiler always fails 100% of the time. If you don’t get this message:

Shader compiler: internal error initializing platforms: Protocol error - failed to read correct magic number

Then it is not the same problem. You should file a bug with your repro project separately though so we can fix it!

2487139–171527–localhost_sock_test.zip (25.1 KB)

1 Like

Thanks, that’s helpful information. I’m still investigating the issue and will submit a repro project if I can’t resolve it.

Hi,
Same problem as Ikemen here.

I install unity 5.3.2 If i open an old project or standard assets example shaders on existing material are good. If I create a new material in this project it’s pink by default.

If I create a new project , It’s pink by default.Screenshot - 6375d3ce25090fabae1fedf8aeca5794 - Gyazo

same problem with pink skybox in default project. just installed unity 5.3.2

Hello,

I’ve had the same problem in my custom shaders, but I believe it’s a shader compiler bug as it only appears on specific shaders but doesn’t when the same code is changed slightly. This is an older iteration of a shader I wrote that throws the error. It works perfectly in the Editor, but not in builds.

Shader "Sprites/MenuBackground"
{
    Properties
    {
        [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
        _Color ("Tint", Color) = (1,1,1,1)
        ColorBG ("Background Color", Color) = (0,0,0,1)
        ColorLines ("Line Color", Color) = (1,1,1,1)
        [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
        CenterX ("Center X", Float) = 0.5
        CenterY ("Center Y", Float) = 0.5
        AxisX ("Axis X", Float) = 1
        AxisY ("Axis Y", Float) = 0
        Divisions ("Divisions", Int) = 1
        Radius ("Radius", Float) = 0.1
        PixelScale ("PixelScale", Int) = 1
    }

    SubShader
    {
        Tags
        {
            "Queue"="Background"
            "IgnoreProjector"="True"
            "RenderType"="Opaque"
            "PreviewType"="Plane"
            "CanUseSpriteAtlas"="False"
        }

        Cull Off
        Lighting Off
        ZWrite Off
        Blend One OneMinusSrcAlpha

        Pass
        {
        CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile _ PIXELSNAP_ON
            #include "UnityCG.cginc"
       
            struct appdata_t
            {
                float4 vertex   : POSITION;
                float4 color    : COLOR;
                float2 texcoord : TEXCOORD0;
            };

            struct v2f
            {
                float4 vertex   : SV_POSITION;
                fixed4 color    : COLOR;
                half2 texcoord  : TEXCOORD0;
                half2 pixelAngle    : TEXCOORD1;
            };
       
            fixed4 _Color;
            fixed4 ColorBG; fixed4 ColorLines;
            half CenterX; half CenterY;
            half AxisX; half AxisY;
            int Divisions;
            float Radius;
            int PixelScale;

            v2f vert(appdata_t IN)
            {
                v2f OUT;
                OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);\
                OUT.color = IN.color * _Color;
                #ifdef PIXELSNAP_ON
                OUT.vertex = UnityPixelSnap (OUT.vertex);
                #endif

                half displace = max(0, _ScreenParams.x / _ScreenParams.y - 1) * 0.5f;

                half left = -displace * (1 - IN.texcoord.x);
                half right = IN.texcoord.x * displace;

                OUT.texcoord = half2(IN.texcoord.x + left + right, IN.texcoord.y);

                OUT.pixelAngle.x = _ScreenParams.y / PixelScale;
                OUT.pixelAngle.y = 6.28318530718 / Divisions;

                return OUT;
            }

            sampler2D _MainTex;

            fixed4 frag(v2f IN) : SV_Target
            {
                //Pixelize the position according to the pixel scale
                half2 pos = floor(IN.texcoord * IN.pixelAngle.x) / IN.pixelAngle.x;

                //The center of the circle
                half2 pivot = half2(CenterX, CenterY);

                float4 color;

                if (distance(pos, pivot) < Radius) {
                    color = ColorBG;
                } else {

                    half2 dir = normalize(pos - pivot);

                    half2 axis = half2(AxisX, AxisY);
                    //Whether or not the angle is negative or positive
                    half z = axis.x * dir.y - axis.y * dir.x;

                    half prod = dot(axis, dir);
                    //The actual angle formed between the fragment<->center and axis
                    half angle = acos(prod);

                    angle = fmod(angle, IN.pixelAngle.y);

                    if (angle < (IN.pixelAngle.y / 2)) {
                        if (z < 0) {
                            color = ColorBG;
                        } else {
                            color = ColorLines;
                        }
                    } else if (z < 0) {
                        color = ColorLines;
                    } else {
                        color = ColorBG;
                    }

                }
                return color * _Color;
            }
        ENDCG
        }
    }
}

Notice line #100: “if (distance(pos, pivot) < Radius) {”. If I change that to:

half dX = pos.x - pivot.x;
half dY = pos.y - pivot.y;

if (dX * dX + dY * dY < Radius * Radius) { ...

The shader now works! Note that it’s “Radius * Radius” that makes it work.

Another thing that makes it work is replacing the “color = …” with return statements (while keeping the original distance() < Radius line). Getting rid of the now-obsolete else keywords is not required for it to work.

I hope this will help you guys figure out what’s wrong!

1 Like

I’d like to avoid this thread becoming a meta-bug for different problems with similar symptoms, since that’s a good way to not solve anything :).

If you have a problem with one particular shader like @Zoodinger above, that’s not what the OP is experiencing. If you file a bug with the repro shader it can be investigated separately as it indicates a crash in the platform shader compiler.

The OP’s problem is that the shader compiler is running but no network communication is happening at all beyond the initial connection. If you are experiencing this problem you will see something like this in your Editor.log:

Shader compiler: internal error initializing platforms: Protocol error - failed to read correct magic number

Note in particular the bolded part. If you have this error about initializing platforms then that is a strong indication of the bug, as this means the network is failing when just querying what platforms the shader compiler supports before we even get to compiling shaders.

If you do get this error, please post the diagnostic information that @ikemen_blueD has:

  • Post your operating system, machine configuration and environment, the Editor.log and any Library/shadercompiler-UnityShaderCompiler.exe0.log in the new project.
  • Disable any antivirus or firewall or any programs that could affect network use, and try again to see if that makes any difference.
  • Take a process monitor capture with the steps I posted earlier in the thread and share the results. (If you are comfortable doing so, a wireshark capture would also be of great help).
  • Finally try running the pair of executables I posted above to see if you notice any problems there.

I am preparing a build of Unity with extra diagnostic and debugging log output, I will share it with anyone experiencing the problem to try and narrow down what is going wrong and find a fix.

Hi guys, for those who have similar issue like mine. Can you guys do the tests? Because I’m pretty busy for my lunar year holidays preparation, so I probably be late to provide unity_baldurk the test stats, so he and Unity staff can fix the issue. Many thanks! :slight_smile:

Right, I’m sorry, the error I’m getting is:
Shader compiler: internal error compiling shader snippet type=0 platform=9: Protocol error - failed to read correct magic number
which looks very similar, but I’m not getting "internal error initializing platforms". I’ll file a separate bug report for this.

@unity_baldurk sorry for my late reply. Here are my steps:

  • Turn off Microsoft Security Essentials, Microsoft Firewalls, System Mechanics.
  • Install Unity 5.3.1f1.
  • Run “Unity 5.3.2p1 Editor with extra Socket Logs”, that you sent me. Create a new project.

Here are the error messages:

Shader compiler: internal error initializing platforms: Protocol error - failed to read correct magic number
UnityEditor.DockArea:OnGUI()

Shader compiler: internal error compiling shader snippet type=0 platform=4: Failed writing data to socket
UnityEditor.DockArea:OnGUI()

Shader compiler: internal error compiling shader snippet type=1 platform=4: Failed writing data to socket
UnityEditor.DockArea:OnGUI()

Shader error in ‘Skybox/Procedural’: Internal error communicating with the shader compiler process

The “Editor.log”, “Editor-prev.log” from “C:\Users.…\AppData\Local\Unity\Editor” & the “shadercompiler-UnityShaderCompiler.exe0.log” from “C:.…\New Unity Project\Library” are attached.

I’m doing the same steps with Process Monitor. Here is my “Logfile.PML” download link

I hope these logs can help you to figure out the main culprit :slight_smile:

2493838–172109–Editor.log.txt (107 KB)
2493838–172110–Editor-prev.log.txt (253 KB)
2493838–172111–shadercompiler-UnityShaderCompiler.exe0.log.txt (2.38 KB)