Late in my game, when a lots is happening and many objects are created, the WebPlayer exits with the following error. I could probably work around the problem (limiting whatever it is that is running out), if only I knew what it meant. Is there even any way to find this sort of thing out (I assume none of this code is visible to us)?
Failed to create context; context number limit exceeded?
UnityEngine.Object:INTERNAL_CALL_Internal_InstantiateSingle(Object, Vector3, Quaternion)
UnityEngine.Object:Internal_InstantiateSingle(Object, Vector3, Quaternion)
UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
MonsterType:Generate(Vector3, RandomStream, Boolean)
... (long stack trace in my code elided)
Player:FixedUpdate()
[..\..\Framework\src\PxScene.cpp line 146]
(Filename: ..\..\Framework\src\PxScene.cpp Line: 146)
Unable to create scene.
UnityEngine.Object:INTERNAL_CALL_Internal_InstantiateSingle(Object, Vector3, Quaternion)
UnityEngine.Object:Internal_InstantiateSingle(Object, Vector3, Quaternion)
UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
MonsterType:Generate(Vector3, RandomStream, Boolean)
...
Player:FixedUpdate()
[..\..\Physics\src\NpPhysicsSDK.cpp line 619]
(Filename: ..\..\Physics\src\NpPhysicsSDK.cpp Line: 619)
120201 09:37:48 Setting error display: 'The content was stopped because a fatal
content error has been detected.', details: '', link: 0
web: shutdown player
I’ve been getting this too, though in a multiplayer standalone game (Windows) using Photon for networking. Did you ever figure out what the cause of this was? Or does anybody have any more information?
In rooms with 10+ people and a lot of instantiations going on, the game is pretty much guaranteed to crash in 10-20 minutes with this error. However if you’re the master client of the room, it seems to take a bit longer, but it’s still a major problem.
Worth mentioning the game was built with version 4.6.1f1.
Update on this: It’s apparently caused by cloth physics (the cloth component itself). At this point I’m still not 100% sure of the cause of the crash, but it seems to be related to the process of disabling or destroying cloths (loading a scene destroys them properly however). Repeatedly instantiating and destroying prefabs with cloths on them causes the game to crash in a matter of seconds, same with toggling component.enabled (cloth component only, not the renderer, gameObject.SetActive() causes the crash as well).
To fix it, I wrote a pooling system that instantiates cloths, never destroying or disabling the cloth component/GameObject. When a cloth is no longer needed, the SkinnedMeshRenderer component is disabled instead. That means as more cloths are needed in one multiplayer match, the pool of active cloths grows bigger, but with the renderer disabled it doesn’t seem like the cloths are still simulating (can’t notice a performance impact). Either way, it’s better than the game crashing consistently.
Cloth in 4.x is utterly broken, so I simply disabled it in my game, probably why this bug faded away for me (one guess how I feel about being forced to pay for and port to U5 to get the fixes…).