- Home /
Unity3d(4.7.1f1) App Crash when calls Resources.UnloadUnusedAssets() On IOS with IL2CPP
I have call Resources.UnloadUnusedAssets() after destory Gameobejcts in the scene. It crashed with EXC_BAD_ACCESS.
the callstack is :
#0 0x0000000102794534 in il2cpp::vm::MetadataCache::GetTypeInfoFromTypeDefinitionIndex(int) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/MetadataCache.cpp:750
#1 0x00000001027a4864 in il2cpp::vm::Type::GetClass(Il2CppType const*) [inlined] at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/Type.cpp:851
#2 0x00000001027a485c in il2cpp::vm::Type::IsEnum(Il2CppType const*) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/Type.cpp:820
#3 0x000000010278d214 in il2cpp::vm::Class::GetArrayElementSize(TypeInfo const*) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/Class.cpp:1527
#4 0x00000001027925bc in il2cpp::vm::LivenessState::TraverseArray(Il2CppArray*, il2cpp::vm::LivenessState*) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/Liveness.cpp:283
#5 0x000000010279260c in il2cpp::vm::LivenessState::TraverseObjects() [inlined] at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/Liveness.cpp:133
#6 0x00000001027925fc in il2cpp::vm::LivenessState::TraverseArray(Il2CppArray*, il2cpp::vm::LivenessState*) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/Liveness.cpp:291
..........
..........
..........
#25623 0x0000000102792ea0 in il2cpp::vm::LivenessState::TraverseGenericObject(Il2CppObject*, il2cpp::vm::LivenessState*) [inlined] at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/Liveness.cpp:171
#25624 0x0000000102792e4c in il2cpp::vm::LivenessState::TraverseObjects() [inlined] at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/Liveness.cpp:133
#25625 0x0000000102792e2c in il2cpp::vm::Liveness::FromStatics(void*) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/Liveness.cpp:460
#25626 0x0000000102255424 in MarkManagedStaticVariableRoots(GarbageCollectorState&) [inlined] at /Users/builduser/buildslave/unity/build/Runtime/Misc/GarbageCollectSharedAssets.cpp:510
#25627 0x0000000102255414 in GarbageCollectSharedAssets(bool) at /Users/builduser/buildslave/unity/build/Runtime/Misc/GarbageCollectSharedAssets.cpp:242
#25628 0x000000010225f64c in UnloadUnusedAssetsOperation::IntegrateMainThread() at /Users/builduser/buildslave/unity/build/Runtime/Misc/PreloadManager.cpp:867
#25629 0x000000010225e17c in PreloadManager::UpdatePreloadingSingleStep(bool) at /Users/builduser/buildslave/unity/build/Runtime/Misc/PreloadManager.cpp:488
#25630 0x000000010225ec08 in PreloadManager::UpdatePreloading() at /Users/builduser/buildslave/unity/build/Runtime/Misc/PreloadManager.cpp:586
#25631 0x000000010225b864 in PlayerLoop(bool, bool, IHookEvent*) at /Users/builduser/buildslave/unity/build/Runtime/Misc/Player.cpp:1800
Anyone has encountered this one before?
Thanks,
Answer by aldian · May 12, 2016 at 01:03 PM
From my time with IOS i have found that you shouldnt destroy gameobjects. Instead just deactivate them with:
gameobject.setactive(false);
Thanks for your reply.
But, If just deactivate gameobjects. Resources.UnloadUnusedAssets() can not unload the resources used by these gameobjects. $$anonymous$$emory usage will increase fast.
Answer by JoshPeterson · May 17, 2016 at 11:31 AM
I believe that this bug has already been corrected. However, we have not shipped updates for the 4.7 release series in a while, so you may need to move to the latest patch releases in 5.3 to try it.
Thank you Josh. We can not upgrade to 5.3 right now is because: 1. Our product will be released by the end of $$anonymous$$ay, the schedule is fixed 2. $$anonymous$$y company only purchase version 4.X
Do development $$anonymous$$m have plan to integrate this patch to fix this bug into next release in 4.X version, soon? Is there any workaround to fix this bug ? How we avoid this bug ? This is crucial to our company and the current product which is going to ship to market soon.
I'm not totally clear on the cause of the problem, so I can't suggest a work around, unfortunately. I can't find any similar bugs in our bug system now, although I do have a vague recollection that this was corrected.
We're not planning to ship more 4.7 updates for specific bug fixes like this, so I doubt that a fix will be available. If you would like to submit a bug report, we could try it and look for a work around. That may be your best option.
It might also be worth trying the latest 5.3 version as well. If the bug was not corrected in 5.3, that will give it higher priority for a fix or work around.
Your answer
Follow this Question
Related Questions
some iOS devices took more memory about 200%!! 1 Answer
The app is continually stopping in IOS 0 Answers
ERROR in IOS build with IL2CPP scripting backend 2 Answers
Why doesn't mono support arm64? 1 Answer
Interlocked methods crashing with IL2CPP 3 Answers