Crash when destroying scene object loaded from AssetBundles

Hi,

I implemented asset bundles. I’m loading all levels from them and levels are loaded ok .But now when I try to destroy root object of loaded level, game will crash.

It happens only on iOS. There is NO error or exception in editor. I’ve noticed that game will not crash when I include desired level in BuildSettings. (but still loading it from asset bundle). I am imagining why ActivateAwakeRecursively is called when destroying the objects … this is strange for me. We are using unity 5.1.2p2 since there was some fix with crashes and AssetBundles, but unfortunately it didn’t help.

Exception Type: EXC_CRASH (SIGSEGV)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 1

Thread 0:
0 soldiers 0x00edca90 Unity::GameObject::ActivateAwakeRecursivelyInternal(Unity::DeactivateOperation, AwakeFromLoadQueue&) (GameObject.cpp:209)

1 soldiers 0x00edcb3e Unity::GameObject::ActivateAwakeRecursively(Unity::DeactivateOperation) (GameObject.cpp:223)

2 soldiers 0x00fd599e DestroyGameObjectHierarchy(Unity::GameObject&) (GameObjectUtility.cpp:1307)

3 soldiers 0x00fd5c7a DestroyObjectHighLevel(Object*, bool) (GameObjectUtility.cpp:1468)

4 soldiers 0x00f5da44 DelayedCallManager::Update(int) (CallDelayed.cpp:178)

5 soldiers 0x00fdb2a4 PlayerLoop(bool, bool, IHookEvent*) (Player.cpp:1920)

6 soldiers 0x00e49332 UnityPlayerLoopImpl(bool)

Had a similar issue in a game I was porting to Apple TV, using Unity 5.3.5, where the game would crash in certain places when we tried loading different levels using AssetBundles.

I found this response from Unity in a bug report that says:

Asset bundles and code stripping don’t play nicely together in any current versions of Unity. If an engine code type is used only in an asset bundle, and not in any scene that present at build time, then stripping will remove the engine code type, and an error like this will occur. We’re working to correct this in a future version of Unity (likely 5.5), but the fix is pretty involved, so it cannot be back ported.

So the only solution for us was to uncheck the “Strip Engine Code” in the Build Settings.

Unity crashed when attempting to destroy object with LightProbesGroup. Deleting this object from scene prevents unity from crashing.

Try setting Strip Engine Code to Disabled.

It still occurs in 2018.2 :slight_smile: Asset bundles = death