I spoke with John from Esoteric about this issue via email, but wanted to continue the discussion on the forums in case it helps out other people.
In short, whenever I try to build asset bundles in Unity where an asset to be included in a bundle contains a Skeleton Animation component with a Skeleton Data Asset attached, Unity crashes. Here's the error message and (probably mostly unhelpful) stack trace from Unity's Editor.log file:
Packing sprites:
- Repacking is not required. Check took 0.776764 ms.
identifier.serializedFileIndex != -1
UnityEditor.BuildPipeline:BuildAssetBundlesInternal(String, BuildAssetBundleOptions, BuildTarget)
UnityEditor.BuildPipeline:BuildAssetBundles(String, BuildAssetBundleOptions, BuildTarget) (at /Users/builduser/buildslave/unity/build/artifacts/genera
ted/common/editor/BuildPipelineBindings.gen.cs:372)
ContentManagerMenuItems:BuildAssetBundles() (at Assets/Editor/ContentManagerMenuItems.cs:15)
[/Users/builduser/buildslave/unity/build/Editor/Src/BuildPipeline/AssetBundleBuilder.cpp line 75]
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/BuildPipelineBindings.gen.cs Line: 372)
Receiving unhandled NULL exception
Launching bug reporter
Obtained 45 stack frames.
#0 0x00000101a7b2d9 in GUIDPersistentManager::PathIDToFileIdentifierInternal(int)
#1 0x000001017bd0fe in GenerateDeterministicIDFromPersistentInstanceID(int, int, std::map<UnityGUID, int, std::less<UnityGUID>, std::allocator<std::p
air<UnityGUID const, int> > > const*)
#2 0x000001017bfbe9 in AssetBundleBuilder::AddBuildAssets(std::string const&, int, bool)
#3 0x000001017bdeb0 in AssetBundleBuilder::BuildCustomAssetBundle(PPtr<Object>, std::vector<PPtr<Object>, std::allocator<PPtr<Object> > > const&, std
::vector<std::string, std::allocator<std::string> > const*, std::string const&, int, BuildTargetPlatform, TransferInstructionFlags, BuildAssetBundleOp
tions, std::set<std::string, std::less<std::string>, std::allocator<std::string> >&)
#4 0x000001017cc442 in BuildAssetBundle(std::string const&, AssetBundleFullName const&, AssetBundleBuildData*, std::vector<PPtr<Object>, std::allocat
or<PPtr<Object> > > const&, BuildTargetPlatform, TransferInstructionFlags, BuildAssetBundleOptions, bool)
#5 0x000001017c782d in BuildAssetBundlesInternal(std::string&, std::map<int, std::set<UnityGUID, std::less<UnityGUID>, std::allocator<UnityGUID> >, s
td::less<int>, std::allocator<std::pair<int const, std::set<UnityGUID, std::less<UnityGUID>, std::allocator<UnityGUID> > > > >&, std::map<UnityGUID, i
nt, std::less<UnityGUID>, std::allocator<std::pair<UnityGUID const, int> > >&, BuildTargetPlatform, BuildAssetBundleOptions, bool, std::string&)
#6 0x000001017c4ddc in BuildAssetBundles(std::string, BuildTargetPlatform, BuildAssetBundleOptions, bool, std::string&)
#7 0x000001023d9508 in BuildPipeline_CUSTOM_BuildAssetBundlesInternal(ICallString, BuildAssetBundleOptions, BuildTargetPlatform)
#8 0x000001226b0305 in (wrapper managed-to-native) UnityEditor.BuildPipeline:BuildAssetBundlesInternal (string,UnityEditor.BuildAssetBundleOptions,U
nityEditor.BuildTarget) + 0xa5 (0x1226b0260 0x1226b0334) [0x110358330 - Unity Child Domain]
#9 0x000001226b0141 in UnityEditor.BuildPipeline:BuildAssetBundles (string,UnityEditor.BuildAssetBundleOptions,UnityEditor.BuildTarget) + 0x101 (0x1226b0040 0x1226b023a) [0x110358330 - Unity Child Domain]
#10 0x00000122626b84 in ContentManagerMenuItems:BuildAssetBundles () + 0xe4 (0x122626aa0 0x122626ba8) [0x110358330 - Unity Child Domain]
#11 0x00000113c05fc6 in (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr) + 0xf6 (0x113c05ed0 0x113c060f9) [0x110358330 - Unity Child Domain]
#12 0x00000109ba10d0 in mono_get_runtime_build_info
#13 0x00000109ccf3f6 in mono_runtime_invoke
#14 0x0000010115a3ba in ScriptingInvocation::Invoke(MonoException**, bool)
#15 0x0000010115b50b in ScriptingInvocationNoArgs::InvokeChecked()
#16 0x000001018f4652 in ScriptCommands::Execute(MenuItem const&)
#17 0x00000101b3e714 in MenuController::ExecuteMenuItem(MenuItem&)
#18 0x00000101c36a9d in -[CocoaMainMenu executeStandard:]
#19 0x007fff97e6e07a in _os_activity_initiate
#20 0x007fff90e52e89 in -[NSApplication sendAction:to:from:]
#21 0x007fff90e52c23 in -[NSMenuItem _corePerformAction]
#22 0x007fff90e52983 in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:]
#23 0x007fff97e6e07a in _os_activity_initiate
#24 0x007fff90ee4f20 in -[NSMenu performActionForItemAtIndex:]
#25 0x007fff90ee4e93 in -[NSMenu _internalPerformActionForItemAtIndex:]
#26 0x007fff90ee4ceb in -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:]
#27 0x007fff90d8a0dd in NSSLMMenuEventHandler
#28 0x007fffa16047be in DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*)
#29 0x007fffa1603c48 in SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*)
#30 0x007fffa16199e6 in SendEventToEventTarget
#31 0x007fffa166399a in SendHICommandEvent(unsigned int, HICommand const*, unsigned int, unsigned int, unsigned char, void const*, OpaqueEventTargetRef*, OpaqueEventTargetRef*, OpaqueEventRef**)
#32 0x007fffa168ed5b in SendMenuCommandWithContextAndModifiers
#33 0x007fffa168ed0c in SendMenuItemSelectedEvent
#34 0x007fffa168ebe8 in FinishMenuSelection(SelectionData*, MenuResult*, MenuResult*)
#35 0x007fffa168f596 in MenuSelectCore(MenuData*, Point, double, unsigned int, OpaqueMenuRef**, unsigned short*)
#36 0x007fffa168f230 in _HandleMenuSelection2
#37 0x007fff90d751fe in _NSHandleCarbonMenuEvent
#38 0x007fff90bea241 in _DPSNextEvent
#39 0x007fff90be932a in -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
#40 0x007fff90bdde84 in -[NSApplication run]
#41 0x007fff90ba746c in NSApplicationMain
#42 0x00000101c528b8 in EditorMain(int, char const**)
#43 0x00000101c52f69 in main
#44 0x00000100002ad4 in start
Here are the relevant version numbers of the various tools:
- Unity Pro v5.3.4f1 (the personal edition should also cause the error, since asset bundle support is now included in Unity Personal)
- Spine Professional v2.1.27
- Spine Unity runtime v2.3
In Pharan's email, he asked a few questions related to my setup so I'll answer them here as well:
-
Please send me the version of SkeletonRenderer.cs that you're currently using. I've included this in the linked archive (see below)
-
When the error says "Repacking is not required", does that mean your textures were incorrectly being set as a Sprite when it should be a Texture? Is there anything about your setup that's special and anything to do with Unity Sprites? I'm not sure what that message means, really. The textures attached to our prefabs are marked as "Texture" in Unity (we import them using the process described in the Spine Unity documentation, here: http://esotericsoftware.com/spine-unity#Importing-into-Unity)
-
Does the crash only happen when you bundle Prefabs with SkeletonAnimations? Yes. "Standard" Unity assets (e.g., prefabs with only Unity components and our custom MonoBehaviour scripts) build just fine.
-
Does it crash on all AssetBundle targets? As far as I can tell, yes. We're a mobile shop, so we're mostly concerned with iOS and Android. However, I switched my build target to StandAlone yesterday and the crash still happened.
The reproduction steps for the issue are a bit tricky, but I'll try to lay them out here:
-
Unzip this ZIP archive file: https://www.dropbox.com/s/4h24u7ohxl2b2az/spine-asset-bundle-crash-project.zip?dl=0 (I tried to attach it to this topic, but your forum software just ignores the upload and redirects me to a blank posting page)
-
Open the contents of the archive as a Unity project My build target is set to iOS, but the issue should also happen with StandAlone or Android, in my experience
-
Note that there is one prefab called "avatar_boy" assigned to the "character" asset bundle
-
Select Assets -> Build Asset Bundles from the Unity menubar This process might take a while. I'm unclear as to why, but it should finish normally
-
Select the aforementioned "avatar_boy" prefab and assign it to a new asset bundle (e.g., "test")
-
Build the asset bundles again (step 4)
-
Unity should crash and display the bug reporting dialog
You can see in the project that we have 5 materials attached to the "avatar_boy" prefab, but they're all imported as Unity textures, not sprites. Hopefully this is enough information to get you started.