recently, i meet a tough problems, it puzzles me!
when i want to active gameobjct, the game will be crash.
i want to know why hanpped and how to fixed it?
detailed crash infomation.
the crash stack:
1 #00 pc 0010358c libunity.so Object::AddEvent(void (*)(void*, void*, int), void*) [armeabi-v7a]
2 #01 pc 007715b0 libunity.so Animation::RecomputeContainedRenderersRecurse(Transform&) [armeabi-v7a]
3 #02 pc 007715d0 libunity.so Animation::RecomputeContainedRenderersRecurse(Transform&) [armeabi-v7a]
4 #03 pc 007715d0 libunity.so Animation::RecomputeContainedRenderersRecurse(Transform&) [armeabi-v7a]
5 #04 pc 007715d0 libunity.so Animation::RecomputeContainedRenderersRecurse(Transform&) [armeabi-v7a]
6 #05 pc 007715d0 libunity.so Animation::RecomputeContainedRenderersRecurse(Transform&) [armeabi-v7a]
7 #06 pc 007715d0 libunity.so Animation::RecomputeContainedRenderersRecurse(Transform&) [armeabi-v7a]
8 #07 pc 007728e8 libunity.so Animation::BuildAnimationStates() [armeabi-v7a]
9 #08 pc 0076b638 libunity.so Animation::Play(int) [armeabi-v7a]
10 #09 pc 004b6ca0 libunity.so AwakeFromLoadQueue::AwakeFromLoad(AwakeFromLoadMode, bool) [armeabi-v7a]
11 #10 pc 00105acc libunity.so GameObject::Activate() [armeabi-v7a]
12 #11 pc 010339cc libil2cpp.so ActorMgr_UpdateReadyModel_m2736514389 (D:\MyGame\Android_Current\code\client_code\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Assembly-CSharp_0.cpp:17935) [armeabi-v7a]
13 #12 pc 01032704 libil2cpp.so ActorMgr_Update_m3466065769 (D:\MyGame\Android_Current\code\client_code\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Assembly-CSharp_0.cpp:8793) [armeabi-v7a]
14 #13 pc 00e0c924 libil2cpp.so RuntimeInvoker_Void_t1841601450(MethodInfo const*, void*, void**) (D:\MyGame\Android_Current\code\client_code\Temp\StagingArea\Il2Cpp\il2cppOutput/Il2CppInvokerTable.cpp:1304) [armeabi-v7a]
15 #14 pc 017845b8 libil2cpp.so il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) (C:\Program Files\Unity\Editor\Data\il2cpp\libil2cpp\vm/Runtime.cpp:476) [armeabi-v7a]
16 #15 pc 004b30f0 libunity.so ScriptingInvocation::Invoke(Il2CppException**, bool) [armeabi-v7a]
17 #16 pc 004811d0 libunity.so MonoBehaviour::CallUpdateMethod(int) [armeabi-v7a]
18 #17 pc 001b9900 libunity.so void BaseBehaviourManager::CommonUpdate<BehaviourManager>() [armeabi-v7a]
19 #18 pc 002e7368 libunity.so PlayerLoop() [armeabi-v7a]
20 #19 pc 00547668 libunity.so UnityPlayerLoop() [armeabi-v7a]
21 #20 pc 00549e60 libunity.so nativeRender(_JNIEnv*, _jobject*) [armeabi-v7a]
22 #21 pc 00056313 /data/app/com.xy.byws-o8vddlMpLTGbBJupumgApQ==/oat/arm/base.odex [armeabi]
the code sample:
class ModelCache {
public string abName;
public string assetName;
public int RefCount;
public GameObject Object;
public PoolEx<ModelObj> Frees = new PoolEx<ModelObj>();
public List<Actions.BoolAction<GameObject>> Callbacks = new List<Actions.BoolAction<GameObject>>();
public float nextCheckFreeTime = 0f;
public float unloadTime = 0f;
}
public class ActorMgr : MonoBehaviour {
private List<string> _listReadyModel = new List<string>();
private Dictionary<string, ModelCache> _dictCacheCommonModel = new Dictionary<string, ModelCache>();
private static DateTime curUpdateDate = DateTime.Now;
public static int nMaxReadyModelTick = 4;
void Update() {
var time = Time.time;
curUpdateDate = DateTime.Now;
UpdateReadyModel();
UpdateCacheCommonModel();
UpdateDestoryModel();
}
private void UpdateReadyModel() {
for (int i = _listReadyModel.Count - 1; i >= 0 ; --i) {
ModelCache cacheObj = null;
if (!_dictCacheCommonModel.TryGetValue(_listReadyModel[i], out cacheObj)) {
_listReadyModel.RemoveAt(i);
return;
}
for (int j = cacheObj.Callbacks.Count - 1; j >= 0; --j) {
var func = cacheObj.Callbacks[j];
cacheObj.Callbacks.RemoveAt(j);
// accoding to crash infomation.
// i think the crash reason is call GameObject.Instantiate func or set gameobject.SetActive
// cause line 11 on the crash stack info notice the code is call GameObject::Activate().
// actually, this crash is not happend a hundred percent.
var newObj = GameObject.Instantiate(cacheObj.Object);
if (newObj.activeSelf != true)
newObj.SetActive(true);
bool bOk = false;
try {
bOk = func(newObj);
} finally {
if (!bOk) {
GameObject.Destroy(newObj);
cacheObj.RefCount--;
}
}
if ((DateTime.Now - curUpdateDate).TotalMilliseconds > nMaxReadyModelTick) {
break;
}
}
if (cacheObj.Callbacks.Count == 0) {
_listReadyModel.RemoveAt(i);
}
}
}
}
this game develop on Unity5.5.5p1 and running on Android platform.
very grateful to you for your help!!