Unity crashes when GUI becomes too complex

Hi,

We are experiencing serious problems and crashes when our GUI becomes too complex, both in the editor and the webplayer build.
For our ingame GUI, we use a modified GUIX version. This framework basically wraps UnityGui calls in classes that can be instanciated (like a button, a label, etc.).
All images and skins that are used in our GUI are stored in the Resources folder and loaded via “Resources.Load”, styles for elements are set via “Skin.FindStyle”.

Until recently, everything worked fine, except for the known GC performance spikes that come with Unity’s OnGui() calls.
But now one of our dialogs (a character dialog with inventory, multiple tabs for various attributes, etc.) became slightly more complex, and we are experiencing weird error logs and Unity crashes as soon as this dialog is instanciated.
Sometimes we get one or more of the following error log messages in the editor console:

  • srcData == NULL
  • failed to create 2D texture
  • !texture.texture

All of those come without any more details and a callstack that starts somewhere in our GUI code, the last line is always “UnityEngine.Resources:Load(String)”
When this happens, the memory goes from 250MB to >1GB and instantly back to ~300MB, and Unity crashes afterwards. Sometimes an editor window pops up with an “Out of memory!” message (again in “UnityEngine.Resources:Load(String)”). Sometimes Unity just quits without any error message, then the following output can be found in the editor log:

Crash!!!

========== Outputing stack ==================

(endless list of dll and drv files, starting with Unity.exe)

(the following a few times:)

’ (Address: 00966FFC)
00966FFC (Unity): (filename not available): (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.

========== End of Outputing stack ===========

When we remove a few GUI elements from the complex dialog, this problem vanishes. Oddly, it suffices to remove SOME elements, not specific ones. It is even enough to delete a few elements that contain very small images just 2kb large. Then, at the moment the dialog is instanciated, the memory goes up to 1300MB from 250MB for a few moments, drops back to 300MB, and everything works fine afterwards.

We have tried to following attempts to solve this problem or find the root of it:

  • Adding GC.Collect() Calls after instanciating each dialog (or even inside longer initializations) makes no difference
  • Upgrading our project to Unity 3.4 does not help
  • This problem does not (yet?) occur in the editor in Win7 64bit (only in 32bit), but the webplayer build crashes both in 32 and 64bit systems
  • Reducing the number of Resource.Load() calls does somewhat defer these problems, but they reoccur at a later time, when more dialogs are instanciated.
  • Similar “out of memory” problems in other forum threads all describe problems when importing large assets into the project (not loading assets at runtime) or using memory >2.5GB for assets. But in our case we use only 350MB, with the memory peaking at 1.3GB for a few moments when all textures and skins are loaded?

Is it possible that loading the same texture multiple times with Resources.Load() results in huge memory usage, and this again causes these crashes? I was under the impression that Resources.Load() caches previously loaded assets, so it is not necessary to cache them myself when multiple elements use the same texture.

I am looking forward to any solution or clue, this is a very grave problem for us. We have just implemented a part of the GUI that we are planning to have, and it seems that we already hit some internal unity limit that prevents us from creating more GUI elements.

Best Regards,
Johannes

it’s a shame that U not got an answer yet. When u make such a detailed bug report, you should at least get an answer from the Unity staff…