Unity keeps crashing on scene change

I wrote a game that used to consist of a main menu scene and game scene. I’ve added additional scenes and I’m finding that moving between scenes results in crashing. Using 4.3.4f1 (free) because the newest version of Unity fudged the 2d physics. The new scenes are simple with the newest literally almost nothing more than new GUI elements.

example tracebacks:

(0x014FDB29) (Unity): (filename not available): fxShader_T2D_DOUBLEY_GH_SSE2 + 0xbc9
(0x014C22A1) (Unity): (filename not available): cpuShaderThreadKickPending + 0x2d1
(0x01504E2F) (Unity): (filename not available): algThreadJobQueueRun + 0x4f
(0x014C2190) (Unity): (filename not available): cpuShaderThreadKickPending + 0x1c0

(0x014E80B5) (Unity): (filename not available): CombineScissorAlpha1 + 0x1965
(0x014E85ED) (Unity): (filename not available): fxShader_MIX_ADD_CL_SSE2 + 0xad
(0x014C22A1) (Unity): (filename not available): cpuShaderThreadKickPending + 0x2d1
(0x01504E2F) (Unity): (filename not available): algThreadJobQueueRun + 0x4f
(0x014C2190) (Unity): (filename not available): cpuShaderThreadKickPending + 0x1c0

(0x014C62DA) (Unity): (filename not available): fxShader_VBLUR_GH_SSE2 + 0x16a
(0x014C22DD) (Unity): (filename not available): cpuShaderThreadKickPending + 0x30d
(0x01504E2F) (Unity): (filename not available): algThreadJobQueueRun + 0x4f
(0x014C2190) (Unity): (filename not available): cpuShaderThreadKickPending + 0x1c0

(0x014FE532) (Unity): (filename not available): fxShader_T2D_HALVE_GH_SSE2 + 0x142
(0x01504E2F) (Unity): (filename not available): algThreadJobQueueRun + 0x4f
(0x014C2190) (Unity): (filename not available): cpuShaderThreadKickPending + 0x1c0

Are there any known issues that may cause this? I get this on the web player build on my computer but rudamentary testing on an android version on my galaxy s3 also yields crashing by doing the same steps (which is basically just jumping from one scene to another and back…)

Also note that the crashing is semi-random. Like, maybe the first time you visit a scene it won’t crash but then the odds of it crashing goes up with each scene change…

Have you used the profiler to check memory usage?

It’s low. This is a mobile optimized game. I double checked using windows task manager anyways and it never climbs high.

Ok I figured it out. I had some procedural textures that are used in the main scene that I was background loading by assigning to some out of sight objects in the main menu and then assigning the textures to a static variable. My primary scene would block until they loaded, but my new ones didn’t use them so they did not block. When I would visit another scene, the objects were being destroyed probably before they were finished generating the textures. When I would revisited the main menu, it would recreate the objects and generate the textures all over again.

Fixed it by updating my code to the following:

  public int textureIndex;
  
   static bool [] doCreate = {true, true, true, true, true};
  
   // Use this for initialization
   void Start () {
     if (doCreate[textureIndex]) {
       DontDestroyOnLoad(this.gameObject);
       doCreate[textureIndex] = false;
     } else {
       DestroyImmediate(this.gameObject);
       return;
     }
     var substance = renderer.material as ProceduralMaterial;
     substance.SetProceduralFloat("$randomseed", Random.Range(0, 900000));
     substance.RebuildTextures();
     Asteroid.asteroidMaterials[textureIndex] = renderer.material;
   }

Hopefully this can be of help for anyone who stumbles upon it. I consider this a bug in Unity because of the ungraceful and cryptic failure.

Hey,

Could you send a bug report containing a small (or not so small) repro project? If you do so please post the bug number here (or in a PM to me)

Best wishes,
Ugnius
Unity QA Team