We get this crash on the PC in the editor and not in the editor. It has appeared since we updated to 4.x. We would be glad to work directly with the Unity team on reproducing this.
-------------- More ---------------------
I greatly reduced this bug by fixing a mistake in our code. Don’t do this…
class Foo
{
public static Dictionary allFoos = new Dictionary();
public int uid;
public Foo( int uid )
{
this.uid = uid;
allFoo[uid] = this;
}
~Foo()
{
// DANGER - Because this Foo is in the list it will never get garbage collected
// so this never gets called and so garbage builds up forever.
allFoo.Remove(uid);
}
}
Our code has a static method to remove world objects and because the destructor never got called only partial cleanup was done. This later confused Unity GameObject and caused the culling algorithm to really get trashed. Instead all WorldObject subclasses have a virtual preDelete() method to do cleanup and list removal.
-------------- More ---------------------
I used Visual Studio to attach to the crashed game. The stack shows it died in scene culling, which I believe is completely new code in Unity 4.x
the stack is… ( Greater than and less than symbols changed to GT and LT so HTML is not trashed . )
Not Flagged 21856 0 Main Thread Main Thread Unity.exe!__crtMessageBoxW Normal
[External Code]
[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
Unity.exe!__crtMessageBoxW(const wchar_t * lpText, const wchar_t * lpCaption, unsigned int uType) Line 97
GameOverlayRenderer.dll!223918e9()
GameOverlayRenderer.dll!223918e9()
Unity.exe!__crtMessageBoxW(const wchar_t * lpText, const wchar_t * lpCaption, unsigned int uType) Line 158
Unity.exe!_NMSG_WRITE(int rterrnum) Line 290
Unity.exe!_purecall() Line 56
Unity.exe!CullAllPerObjectLights(const CullingDynamicArrayLTVisibleNodeGT & visibleNodes, const ActiveLights & lights, const int renderPath, CullingDynamicArray & forwardLightIndices, CullingDynamicArray LT unsigned int GT & forwardLightOffsets) Line 132
Unity.exe!CullLights(const SceneCullingParameters & cullingParameters, CullResults & results) Line 178
Unity.exe!CullScene(SceneCullingParameters & cullingParameters, CullResults & results) Line 233
Unity.exe!Camera::CustomCull(const CameraCullingParameters & parameters, CullResults & results) Line 993
Unity.exe!Camera::Cull(CullResults & results) Line 801
Unity.exe!RenderManager::RenderCameras() Line 89
Unity.exe!RenderGameViewCameras(const RectTLTfloatGT & guiRect, bool gizmos, bool gui) Line 178
Unity.exe!EditorGUIUtility_CUSTOM_INTERNAL_CALL_RenderGameViewCameras(const RectTLTfloatGT & cameraRect, short gizmos, short gui) Line 224
[External Code]
mono.dll!mono_jit_runtime_invoke(_MonoMethod * method, void * obj, void * * params, MonoObject * * exc) Line 4889
mono.dll!mono_runtime_invoke(_MonoMethod * method, void * obj, void * * params, MonoObject * * exc) Line 2618
mono.dll!mono_runtime_invoke_array(_MonoMethod * method, void * obj, MonoArray * params, MonoObject * * exc) Line 3822
mono.dll!ves_icall_InternalInvoke(_MonoReflectionMethod * method, MonoObject * this, MonoArray * params, _MonoException * * exc) Line 2856
[External Code]
mono.dll!mono_jit_runtime_invoke(_MonoMethod * method, void * obj, void * * params, MonoObject * * exc) Line 4889
mono.dll!mono_runtime_invoke(_MonoMethod * method, void * obj, void * * params, MonoObject * * exc) Line 2618
Unity.exe!scripting_method_invoke(ScriptingMethod * method, MonoObject * object, ScriptingArguments & arguments, MonoException * * exception) Line 183
Unity.exe!ScriptingInvocationNoArgs::Invoke(MonoException * * exception) Line 97
Unity.exe!MonoBehaviour::DoGUI(MonoBehaviour::GUILayoutType layoutType, int skin) Line 401
Unity.exe!GUIView::OnInputEvent(InputEvent & event) Line 1962
Unity.exe!GUIView::DoPaint() Line 1198
Unity.exe!GUIView::RepaintAll(bool performAutorepaint) Line 2233
Unity.exe!Application::UpdateScene(bool doRepaint) Line 2337
Unity.exe!Application::UpdateSceneIfNeeded() Line 2216
Unity.exe!Application::TickTimer() Line 1319
Unity.exe!MainMessageLoop() Line 336
Unity.exe!WinMain(HINSTANCE__ * hInst, HINSTANCE__ * hPrev, char * szCmdLine, int nCmdShow) Line 848
Unity.exe!__tmainCRTStartup() Line 275
[External Code]