found some crash bugs over the last days while trying to build Addressables / AssetBundles. (Unity/Unity Bug Reporting Portal/IN-8238 & Unity/Unity Bug Reporting Portal/IN-8347).
What happend:
Building Addressables worked in my project before (Unity 2021.3.0f1). Took some hours but it worked - all 23.037 bundles were created. Project is GlobeViewer an 3D visual representation of earths surface. So these 23.037 bundles are all 1°x1° tiles on the map with land.
Then I added a “few” label game objects into each of my Prefabs (wich are exported as Addressables). In all addressables should be 7.5 million x 5 objects (one parent go, one 3D mesh, a canvas, one UI Image and one UI Text) in the prefabs - 37.5 million game objects in total. Now the build process will crash Unity when collecting dependencies. As this is not a RAM problem, it seems that there is a maximum number of objects which can be worked with.
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
at <0xffffffff>
at UnityEditor.Build.Content.ContentBuildInterface:GetPlayerObjectIdentifiersInAsset_Injected <0x00094>
at UnityEditor.Build.Content.ContentBuildInterface:GetPlayerObjectIdentifiersInAsset <0x0002a>
at UnityEditor.Build.Pipeline.Tasks.CalculateAssetDependencyData:RunInternal <0x00c12>
at UnityEditor.Build.Pipeline.Tasks.CalculateAssetDependencyData:Run <0x0062a>
at UnityEditor.Build.Pipeline.BuildTasksRunner:Run <0x00346>
at UnityEditor.Build.Pipeline.ContentPipeline:BuildAssetBundles <0x00a22>
at UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode:smile:oBuild <0x008aa>
at UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode:BuildDataImplementation <0x001d0>
at UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptBase:BuildData <0x00274>
at UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContentImpl <0x00149>
at UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContent <0x000fa>
at UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContent <0x0002a>
at UnityEditor.AddressableAssets.GUI.AddressableAssetsSettingsGroupEditor:OnBuildPlayerData <0x0001a>
at UnityEditor.AddressableAssets.GUI.AddressableAssetsSettingsGroupEditor:OnBuildScript <0x00032>
at UnityEditor.GenericMenu:CatchMenu <0x00062>
at :runtime_invoke_void__this___object_object_int <0x0009d>
Then I updated to the actual LTS version 2021.3.5f1 - asset database started an reimport of all assets. Result another crash of Unity:
EditorLog
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
at <0xffffffff>
at UnityEditor.AssetDatabase:LoadAllAssetsAtPath <0x00089>
at UnityEditor.ModelImporterPostProcessor:OnPostprocessAllAssets <0x00272>
at :runtime_invoke_void_object_object_object_object <0x000d7>
at <0xffffffff>
at System.Reflection.RuntimeMethodInfo:InternalInvoke <0x000af>
at System.Reflection.RuntimeMethodInfo:Invoke <0x0011a>
at System.Reflection.MethodBase:Invoke <0x0003d>
at UnityEditor.AssetPostprocessingInternal:InvokeMethod <0x000ea>
at UnityEditor.AssetPostprocessingInternal:postprocessAllAssets <0x005d2>
at :runtime_invoke_void_object_object_object_object_object_byte <0x000a8>
After opening the project again, everything seems to be ok. But building addressables won’t work. Same crash at collecting dependencies.
Are there known limits how many game objects can be managed in Unity?
If I remove all tile prefabs from the project, the addressables will finish the dependency collection with the remaining assets and build them. So it must depend on the numbers of objects, right?
Also tried to build AssetBundles. Export started but Unity crashed later so only a quarter of all bundles were created.
Editor Log
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
at <0xffffffff>
at UnityEditor.BuildPipeline:BuildAssetBundlesInternal <0x000a7>
at UnityEditor.BuildPipeline:BuildAssetBundles <0x0008a>
at UnityEditor.BuildPipeline:BuildAssetBundles <0x0006a>
at AssetBundleBrowser.AssetBundleDataSource.AssetDatabaseABDataSource:BuildAssetBundles <0x0006a>
at AssetBundleBrowser.AssetBundleBuildTab:ExecuteBuild <0x006e0>
at UnityEditor.EditorApplication:Internal_CallDelayFunctions <0x000cf>
at System.Object:runtime_invoke_void <0x0007c>
Removed all prefabs from project and imported them again.
Build AssetBundle via AssetBundle Browser started to export bundles but after 6.771 (of 23.037) assetbunldes Unity crashed again.
Unity/Unity Bug Reporting Portal/IN-8604
EditorLog
Native Crash Reporting
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
at <0xffffffff>
at UnityEditor.BuildPipeline:BuildAssetBundlesInternal <0x000a7>
at UnityEditor.BuildPipeline:BuildAssetBundles <0x0008a>
at UnityEditor.BuildPipeline:BuildAssetBundles <0x0006a>
at AssetBundleBrowser.AssetBundleDataSource.AssetDatabaseABDataSource:BuildAssetBundles <0x0006a>
at AssetBundleBrowser.AssetBundleBuildTab:ExecuteBuild <0x006e0>
at UnityEditor.EditorApplication:Internal_CallDelayFunctions <0x000cf>
at System.Object:runtime_invoke_void <0x0007c>
imported only Assets from tiles N00-N19 which are only 2379 tiles (aprox. 10% of all)
created new addressables for the assets
build addressables
went to bed
Crash. There is defenitly a RAM problem. Found my device with a running Unity incl. the busy bar window shows counting 9 hours… RAM has been completly used. Couldn’t start a browser.
Crash has been detected by Unity itself, but the crash reporter could also not be started.
The log is attached here. So there is no way to post the bug with all the call stack infos as there are no crash report files.
Try to remove the asset counts… N00-N09 did work yesterday.
tried to build only N00 - N16: crash: System out of memory
While building addressables:
Display says: Calculate Asset Dependency Data → up to 15 GB RAM usage (48%)
after last prefab N16E076 → rising RAM need. 30 GB97%
starts swapping out RAM to disk
Display changes to Update Bundle Object Layout (Menu.Default Build Script)
starts swapping out RAM to disk
Crash when the disk is full.
Is Unity loading all prefabs into memory at once? That would be a problem because the files are big (see screenshot).
The problem has been solved. It was a bad idea to place a lot GameObjects into prefabs. As the prefab is a text format, the files got huge after adding 7.5 Million labels (each label were 5 GameObjects) and bloated them to 90 GB. During the build process these prefabs were loaded into the RAM.
I solved that by creating binary files containing all label data for each tile and added the binary file as TextAsset to the prefab, reducing the file size of all prefabs to 280 MB. So the build process worked again.
Hello. I have the same problem. Could you tell us in more detail what you did and how you solved this problem. Maybe there is some example. I don’t understand from your message what exactly they did. Thank you in advance
Hi, my mistake was to create thousands of gameobjects in my scenes and save that into prefabs. The prefabs are text based formats, so all the files where very big in memory. So this started to fill up my RAM so the crash was the logical end.
I then created binary files (containing my asset data) and put those into unitys “TextAssets” (the file can be a binary not a text file) and saved those assets into the prefabs and created my game objects after scene loading from reading the binary TextAsset. A binary file will not take up so much RAM as text files will do. So I solved the problem in my case. Don’t know if this approach will work for you.
Is it possible to collect prefabs into a binary file, and then extract them from this file? And how did you create this binary. Maybe you can upload an example of a script or this file?
Hi, to be more clear: I put my needed object data into a binary file and put that into a script in my scene. This script incl. my binary file was packed inside the prefab. The binary file has been created with a seperate c# program outside Unity to create the file. When loading the prefab in a scene in Unity I used c# code to unpack my object data from that binary file and then created the needed game objects in a loop.
As the prefab/scene file is a text format I saved a lot of RAM while building the prefabs because my binary file was so much smaller than the scene file with the generated game objects in the scene.
Hello. I created a binary file of prefabs in a folder in a third-party program, but I can’t get the data from it. How did you do that? Please show me how you did it: “When loading the prefab in a scene in Unity I used c# code to unpack my object data from that binary file and then created the needed game objects in a loop.”. Thank you in advance
We have a misunderstanding. I created the binary file with the needed GameObject informations (some texts and a vector3) and removed the generated GameObjects from the scene. So thousand of game objects were no longer in the prefab/scene file - only the one small binary file inside one game object script. This reduced the size of the saved prefab and building the asset bundles worked again. I then recreated my needed GameObjects from reading my binary file in the prefab instead of saving all thousand GameObjects directly in the scene/prefab.
The solution is to reduce the file size, not to put the big prefab file into a binary file.
As I understand it, this is what I need. I have prefabs, they contain objects with components, sprites. Due to the fact that there are a lot of prefabs and there are a lot of objects, sprites, components inside the prefab, I also don’t get bundles, and the RAM is completely loaded.
If you showed me how you did it, then I could already try to apply it to my task
I created a script. He works in the editor. But the apk is not built because of GameObject prefab = PrefabUtility.LoadPrefabContents(tempPath);, because this only works in the editor. Please tell me what you did
public void ConvertPrefabToBinary() // create bytes from prefabs
{
for (int i = 0; i < goAll.Length; i++)
{
if (goAll != null) { string filePath = “path” + goAll*.name +“.bytes”;* byte[ ] binaryData = File.ReadAllBytes(AssetDatabase.GetAssetPath(goAll*));* File.WriteAllBytes(filePath, binaryData); Debug.Log("Prefab converted to binary and saved to " + filePath); } else { Debug.LogWarning(“No prefab selected”); } } Debug.Log(“END create BYTES”);
} public void ConvertBinaryToTXT() // create txt from bytes { for (int i = 0; i < goAll.Length; i++) { string filePath = “path to bytes” + goAll*.name ++“.bytes”;* string filePathTXT = “path to create txt” + goAll*.name + “.txt”;* byte[ ] fileData = File.ReadAllBytes(filePath); string text = System.Text.Encoding.UTF8.GetString(fileData); TextAsset textAsset = new TextAsset(text); File.WriteAllText(filePathTXT, text); } Debug.Log(“END TXT”); } public void CreatePrefabFromTXT()//create prefab from txt {
byte[ ] prefabBytes = System.Text.Encoding.UTF8.GetBytes(prefabTextAsset*.text);* string tempPath = “path where create new time prefab”+prefabTextAsset*.name+ “.prefab”;* File.WriteAllBytes(tempPath, prefabBytes); GameObject prefab = PrefabUtility.LoadPrefabContents(tempPath); // load new prefab Instantiate(prefab, Vector3.zero, Quaternion.identity); File.Delete(tempPath);