Android Crash when Resources.Load a ScriptableObject asset

I use a ScriptableObject asset to hold the references of textures.

public class Bundle : ScriptableObject {

public Texture2D[] textures;
}

And I create an asset at “Resources/Bundle.asset”.

When in play mode, I load the “Bundle.asset” dynamicly. Then all textures could be referenced.

bundle = Resources.Load("Bundle") as Bundle;

I have a large number of textures in it. (Over 2000).
It works well in Unity Editor. But when I put it onto an android phone (I have tried 3 different type of phones), it crashes and gives this error by “adb logcat”

D/Unity   (29832): NativeFile: fopen('/data/app/com.xd.LoadBundle-2.apk', rb) failed - Too many open files(24)

It’s strange that if I referenced the “bundle” in an Monobehavior in the scene. It won’t crash.
I guest there is something wrong during “Resources.Load”. It must work differently then “Application.LoadLevel”.
I have been struggling on this issue for days and could not find a clue.

Could anyone help me on this?
I made a testcase in the attachment that you might reproduce the issue.
You need:

  1. Menu->Create->BatchMakeTextures to create 2000 64x64 textures.
  2. Select Resources/Bundle and click “Reload Textures” in inspector. It assigns the textures in bundle.textures
  3. Debug on android with scene “LoadBundle1”
  4. When you click the “load” button on the phone, it should crash.
  5. adb logcat -s Unity could tell you the error.

BTW:
I prefer scriptableObject for 3 reasons:

  1. ScriptableObject is simple to serialize/deserialize in both edit mode & play mode. I don’t have to use xml or json.
  2. ScriptableObject saves runtime references. Ex. I could put a texture or a prefab in it.
  3. ScriptableObject could be nested to create complicated data structure.

1745897–110285–ResourceLoadSO.unitypackage (47.5 KB)

I was just having this same problem today. I called Resources.UnloadUnusedAssets and it fixed it for me. I wonder if that could work for you. I know Application.loadlevel calls Resources.UnloadUnusedAssets behind the scenes.

lol I just realized how old this post was. sorry for the necro bump