Problem with object pool children in another object pool on Android. Any suggestions?

I’m developing a simple tank game for Android and I’m using object pool for better performance. Tanks are created using a object pool, then each tank has a object pool for projectile. The game runs normal in Unity, but on Android it crashes at Unity startup loading screen. I tested the game and it works if I remove the projectile pool.

This is the object pool script:

  • using UnityEngine;
  • using System.Collections;
  • using System.Collections.Generic;
  • public class ObjectPoolScript : MonoBehaviour {
    • public GameObject pooledObject;
  • public int pooledAmount;
    • List pooledObjects;
    • void Start (){
  • pooledObjects = new List ();
  • for (int i = 0; i<pooledAmount; i++) {
  • GameObject obj = (GameObject)Instantiate (pooledObject);
  • obj.SetActive (false);
  • pooledObjects.Add (obj);
  • }
  • }
    • public GameObject GetPooledObject(){
  • for (int i = 0; i < pooledObjects.Count; i++) {
  • if(!pooledObjects*.activeInHierarchy){*
    - return pooledObjects*;*
    - - }*
    - - }*
    - - return null;*
    - - }*
    - - }*
    - [/i][/i]*

What error are you receiving? It should display an exception or some error if you use adb logcat.
The first two thing that come to mind: you’re either pooling too many objects and the game crashes because it uses too much memory or you may be calling GetPooledObject before Start is called.

For testing i use only one object for each pool, with the script mentioned above, nothing else, but it keeps crasing on Android.

This are the main errors from logcat:
09-25 23:03:00.968 W/Unity (24755): GpuProgram creation error: empty shader string

F/libc (24755): Fatal signal 11 (SIGSEGV) at 0x00000038 (code=1), thread 24773 (UnityMain)
I/DEBUG (16265): #00 pc 00461440 /data/app-lib/com.artanks-2/libunity.so

W/InputDispatcher(1017): channel ‘42e981a8 com.artanks/com.unity3d.player.UnityPlayerNativeActivity (server)’ ~ Consumer closed input channel or an error occurred. events=0x9

E/InputDispatcher(1017): channel ‘42e981a8 com.artanks/com.unity3d.player.UnityPlayerNativeActivity (server)’ ~ Channel is unrecoverably broken and will be disposed!

W/ActivityManager(1017): Force removing ActivityRecord{42d5dc70 u0 com.artanks/com.unity3d.player.UnityPlayerNativeActivity}: app died, no saved state

W/InputDispatcher(1017): Attempted to unregister already unregistered input channel ‘42e981a8 com.artanks/com.unity3d.player.UnityPlayerNativeActivity (server)’

I/WindowState(1017): WIN DEATH: Window{42e981a8 u0 com.artanks/com.unity3d.player.UnityPlayerNativeActivity}

2312215–155800–logcat.txt (6.79 KB)

After some more testing I think I’ve found the problem, a bad shader, hence the GPU error.