I’ve had this problem since the introduction of 4.5 and it’s faster shader compilation/recompilation.
Run your scene
open a shader that is currently being utilized in the scene.
make some edits, and resave the shader
go back to your running scene… unity tries to recomile the shader but instantly crashes to the desktop.
sometimes it gives you the crash manager, and sometimes it just goes right to desktop without any notifications at all.
I thought this would have been fixed by now but I just downloaded 4.5.2 and it’s still happening. This of course makes it extremely tedious to work in 4.5, and yet for some of my projects I don’t have the choice of compiling and testing on an older version due to needed 4.5 shader/system updates. Is anyone else experiencing this problem? I can’t be the only one…
Windows Vista 64 bit, Unity 4.5, 4.5.1, and 4.5.2
edit: sometimes you can get around this by editing/recompiling the shader while the scene is not running, but sometimes it crashes to the desktop anyway. This isn’t really a work around though… play / check / stop / edit / save / play check… this is not an acceptable workflow for shader writing.
Maybe Windows Vista is your problem, I am actually quite surprised you use Vista! Anyway though, it works fine on my laptop running windows 7.
Maybe something in your project isn’t agreeing with unity? try posting your project, if that’s feasible, and I will get time this week to test it for you.
And actually, if it works fine on my system, try filing a bug report that vista is having problems with the new compiler.
Please file a bug report, if you haven’t done so already (please mention that it seems to be a regression in 4.5). If you have already filed a report, could you PM me the bug tracker number?
The shader compiler itself runs in a separate process so even if something goes real bad there, Unity should continue to run. Either way, definitely something that needs to be looked into.
Rene Damm - well I swear this has been dogging me for months, and today when I set up a new project to get a bug report package, it just wouldn’t happen O_o I’ll keep an eye out and submit a report next time it happens to me. (which will be soon, I’m sure! I haven’t been able to work in 4.5 because of this and now all of a sudden… I guess I shouldn’t complain).
Nope. Nothing has changed, and it only happens in 4.5+ I’ve been using older versions most of the time because of this error. I’ll try it again later today.
It really could be a problem that Unity has with Vista. I have Vista 64 bit too and tryed with 4.5.1f2 and 4.5.2f1 and both produce the same behaviour:
I change a shader in monodevelop and save it. Switching back to unity crashes the editor.
When i then restart the editor the shader works as intended after i manually reimport.
Another thing i noticed is that it only crashes when the shader is actually used in the scene.
OK I’ve not had much luck in reproducing this error now, which is strange to me bacuse I had it all throughout 4.5+. One change that may have made a difference is before, I had upgraded a 3.5.6 project directly to 4.5… this gave me the crashing behavior as noted above. When I took this project from 4.5 and upgraded it to 4.5.2 I still got the crashing issue.
However, what I did earlier this week was to upgrade my 3.5.6 project directly to 4.5.2. After doing this I’ve only experienced the crashing on a couple of occasions, and I’ve been working with shader updates extensively since then, so it seems to have been introduced in and then inherited from version 4.5
Well after almost a year of this not happening after I upgraded to Unity 5 and Windows 8.1, 2 days ago this crash bug has reemerged. To be clear , anytime I open, edit and save, a shader that is being utilized in the scene while it’s running, when Unity tries to recompile the shader it crashes to desktop. every. time.
The only solution is to stop the scene, edit and save the shader and have unity recompile it before playing the scene again. This works but is an extremely tedious way of working.
note that this only for shader files. updating other C# or javascript components works just fine during play.
Can’t think of any reason for this bug to show up again… nothing has changed on my system for months, not to even mention the last few days.
@chingwa : Pass me your shader code; I had an issue with “runtime error” showing on my machine once, and the issue turned out to be a syntax error that somehow compiled correctly… (Still have to put that bug in!)
Might also be a good idea to show me the editor log too; I might be able to find the issue there.
EDIT: Could also be windows 8.1… I have had some funny things happen to my machine after it got upgraded. (Wi-Fi sometimes doesn’t work at all unless I go into device manager and reset it! that’s only since 8.1) I think some of the weird stability issues I get is from the way 8.1 pre-hibernates all the drivers and other system components to make startup super-quick…
@FuzzyQuills Thank you very much for the offer of looking at these shaders! However I was finally able to narrow down the issue!
I’m using a second scene camera to capture a rendertexture of the sceneview and then applying other effects on top of it and merging it back into other shaders for some custom effects work. So this involves manually rendering the camera into the texture at certain intervals.
The problem seemed to be that whenever Unity was performing a shader recompile while the scene was playing the saved rendertexture reference was being lost, thus the manual camera render erred out and Unity crashed. Simply wrapping these functions with a “if (renderTex != null)” check solves the issue, and I can now open-edit-save shaders during play as normal.
It took me a while to figure out what was going on here, because I simply assumed the problem was with a shader file instruction somewhere in my scene. I didn’t realize the recompile was temporarily losing other object references internally.
OK Edit… the above was only part of the problem. The other aspect was that the camera I was rendering had it’s rendering queue set to “nothing” because I only wanted it to render the back skybox. However this constantly caused crashing issues with shaders as noted above. I was forced to select an unused (at least in my scene) rendering layer such as “Transparent FX” and now everything works. Unity seems to have a bug with Render-to-texture when “nothing” is selected as the rendering layer.