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
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:

  1. Please send me the version of SkeletonRenderer.cs that you're currently using. I've included this in the linked archive (see below)
  2. 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:
  3. 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.
  4. 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:

  1. Unzip this ZIP archive file: (I tried to attach it to this topic, but your forum software just ignores the upload and redirects me to a blank posting page)
  2. 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
  3. Note that there is one prefab called "avatar_boy" assigned to the "character" asset bundle
  4. 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
  5. Select the aforementioned "avatar_boy" prefab and assign it to a new asset bundle (e.g., "test")
  6. Build the asset bundles again (step 4)
  7. 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.
  • Posts: 27


Thanks for posting this as a new topic.

Just to start off, I'd like to establish (you might already know this) that Unity's C# side overloads a lot of null-value behavior. When you have a value type and you try to get a bool (myMesh == null) or (myGameObject == null), it doesn't check the actual variable for a null value. It checks for the existence of the object on the C++ side of Unity. More on that issue here:

What does that have to do with your issue?
Well, your issue seems to be slightly different from the issue other people have been having with AssetBundles.
And thankfully in your case, you and other users have discovered that removing the mesh reference from the MeshFilder's mesh field (ie, actual-nulling), seems to prevent the strange crash.
And you've also noticed "Type Mismatch" written on the field in the Inspector. Whenever "Type Mismatch", making an AssetBundle also seems to crash Unity. Googling does not seem to yield any useful answers about what "type mismatch" really means.

Regardless, removing this mysterious "type mismatch" state on MeshFilter seems to suffice to prevent the crash. So that may be where we'll start.

Your project does seem to take a long time to generate the bundle. My reproduction case only took a couple of seconds. I guess it's because of your four large textures being run through compression.

Your spine-unity folders seem to include too many folders. I'll repackage them into a unitypackage so you can import them easily.
Please delete your old spine-unity and spine-csharp folders before importing this unitypackage.
This version will automatically remove the mesh from the prefab's MeshFilter which should prevent the "type mismatch" state and prevent the crash. In this version, this only happens when (1) you create the prefab and (2) when you select the prefab individually in the project view and show its inspector. So to fix your project's state, you need to select all your Prefabs individually with SkeletonRenderer/SkeletonAnimation/SkeletonAnimator on them, then the Inspector will fix them.

(Just FYI, there is no "Spine runtime v2.3". You may have read the license version number.)
You do not have the required permissions to view the files attached to this post.
User avatar
  • Posts: 5366


Thanks for the response, Pharan.

I downloaded the ZIP file, but I'm unclear how to import it into my project. I initially unzipped the file and it contained a bunch of folders with hashes for names, and files such as "asset" and "pathname" in each folder. Unity wouldn't let me import the folder, so I instead changed the extension of the ZIP file to "unitypackage." Doing that and importing it into my project (after deleting the spine-unity and spine-csharp folders) gave me a Unity dialog that told me "Nothing to import. All assets from this package are already in your project." I also got this dialog when I tried to import the package into a completely new project, so I'm a bit stumped.
  • Posts: 27


Is this your first time importing a unitypackage?
The zip file should contain one file. A .unitypackage.
Just double-click on that file or drag it into Unity and it will import it.

As I mentioned, you need to remove your old spine-unity and spine-csharp folders before importing it.
Normally, this isn't needed, but the folder structure you originally imported for Spine contained a lot of extra files that shouldn't have been there in the first place anyway.
User avatar
  • Posts: 5366


Unfortunately, the ZIP file doesn't contain a .unitypackage file, just a collection of folders. Here's what it looks like:

You do not have the required permissions to view the files attached to this post.
  • Posts: 27


I downloaded this attachment and it contains a unitypackage. I'll email you the unitypackage.
User avatar
  • Posts: 5366


It looks like this did the trick with fixing the Unity crash. Thanks!

Now, however, all of my Spine assets show up as pink boxes when I instantiate them from an asset bundle. I'm assuming it's something related to this thread: Spine and AssetBundles but I've tried to call SkeletonDataAssets.Reset() and SkeletonAnimation.Initialize() (there's no override that accepts a boolean parameter in my version of the runtime) to no avail.

The asset bundle downloading/caching in my game happens in an interstitial Unity scene before any assets in the bundles are instantiated, so everything should be available anyhow, in theory. Is there another step I'm missing?
  • Posts: 27


This is the issue that made absolutely no sense to me.

But there also seems to be a plenty of ways you can group/bundle your assets into AssetBundles.
It's possible that some groupings cause the problem while others don't.
Some of those other users seem to have been able to make sense of things.

In your older version of spine-unity,
Initialize(true) is Reset(), and
Initialize(false) is if (!valid) Reset()
User avatar
  • Posts: 5366


I think I've figured out the pink boxes! I'll post in the other relevant threads, too, in case it helps people in there. I stumbled upon this thread that did the trick:

For my particular situation, I almost always run Unity with either iOS or Android as my target platform, in the editor. Our CI platform switches the platform during its build process to the correct platform, but for testing purposes (e.g., playmode resolution and #define statements in scripts), I like to mimic those platforms on my Mac. However, this causes an issue with shaders contained within asset bundles: When I tell my script to build the latest asset bundles, I do so choosing the currently set target platform. In recent weeks, that's been iOS. But asset bundles are incompatible between platforms, so loading the iOS asset bundles on my Mac was causing issues (specifically, it sounds like it might be related to precompiled shaders inside asset bundles and incompatibilities between rendering engines, but Unity says they disabled that in 5.3, so I'm not sure if it's actually the cause or if it's something else).

Long story short, if you're getting pink/magenta boxes on any materials attached to spine prefabs at runtime, make sure your development environment is loading asset bundles compatible with your target platform (File > Build Settings > Platform -- the currently targeted platform will have the Unity logo next to it). Most of the time, that will mean choosing "PC, Mac & Linux Standalone" as the platform, then making sure you've built your asset bundles properly for that platform before running your game.
  • Posts: 27


Thanks, @atraver. I really couldn't figure that part out. Never would have thought it was a target platform thing.
What you found makes sense to me though.
But regarding asset bundle incompatibilty across platforms, I thought its behavior would just be that it wouldn't load at all rather than actually successfully loading some assets but breaking others.

I'll make a new topic so this information is easier to find.
User avatar
  • Posts: 5366


One last thing I just noticed is that my player is now stuck facing to the right, even when we flip him to the left via code:
public bool ShouldFlipX
if(this.animationControl.skeleton.FlipX != value)
this.animationControl.skeleton.FlipX = value;

CharacterAttachment[] attachments = this.animationControl.GetComponentsInChildren<CharacterAttachment>();

foreach(CharacterAttachment a in attachments)
Vector3 pos = a.transform.localPosition;
pos.x *= -1f;
a.transform.localPosition = pos;

Vector3 scale = a.transform.localScale;
scale.x *= -1f;
a.transform.localScale = scale;
Here are the right (normal) and left (flipX) poses for the avatar:



You can see that some of the model's attachments are flipped (shoes, chestpiece) but most everything else (head, weapon, arms) are not. Flipping works properly in my original version of the runtime (presumably 2.1.25 -- the one where asset bundles were crashing Unity).

Did something change in the version of the Spine runtimes you gave to me that would cause this to not flip the attachments, or is my code flipping the prefab incorrectly? I did a quick diff of the runtimes you provided, and it looks closer to 3.0 than 2.1.25, so I'm wondering if there are larger changes at play that our animator will need to address when he exports Spine models.
You do not have the required permissions to view the files attached to this post.
  • Posts: 27


I just rearranged the spine folders from your project. I didn't import any new spine runtime files. I really just edited the inspector code for SkeletonRenderer and SkeletonAnimation. Did you possibly import some new spine-csharp files yourself?
User avatar
  • Posts: 5366


Crap, in all my various testing, I might've accidentally given you the version of my project with v3.0 runtimes. I have like 3 distinct projects with various configurations to try to figure all of this out, and I guess I gave you the wrong version of my runtime. Is it possible to tell me the inspector changes you made and I can just merge them into my 2.1.25 runtime? I also think I see where you would've rearranged the spine folders (I'm assuming you removed the Assets, Examples, and Gizmos folders from within the spine-unity runtime?).

Sorry about the confusion.
  • Posts: 27


*************Unity 2018.3.6f bundle unity crash bug**************

A prefab depends on B prefab, and if the dependent B prefab is removed, the bundle will crash, and if you want to remove it, don't reference it at another prefab.
  • Posts: 1

Return to Bugs