Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Bug Editor Crash - BuildPipeline.BuildPlayer

Discussion in 'Editor & General Support' started by Originator99, Apr 21, 2024.

  1. Originator99

    Originator99

    Joined:
    May 5, 2019
    Posts:
    6
    I have been trying to build a custom build pipeline for my project. I created an editor window with a build button that calls UnityEditor's BuildPipeline.BuildPlayer method to make a build targeting android platform.

    Unity Version: 2022.3.14f1

    Here's my build code:

    Code (CSharp):
    1. public static string[] GetFirstScene() {
    2.             string[] scenes = new string[1];
    3.             for(int i = 0; i < scenes.Length; i++) {
    4.                 scenes[i] = EditorBuildSettings.scenes[i].path;
    5.             }
    6.             return scenes;
    7.         }
    8. public static void BuildAndroid(string apk_name, string app_version, int bundle_version_code, bool is_prod = false) {
    9.            
    10.             PlayerSettings.Android.keystoreName = "myproject.keystore";
    11.             PlayerSettings.Android.keystorePass = "password";
    12.             PlayerSettings.Android.keyaliasName = "alias";
    13.             PlayerSettings.Android.keyaliasPass = "password";
    14.             PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARMv7 | AndroidArchitecture.ARM64;
    15.             PlayerSettings.Android.bundleVersionCode = bundle_version_code;
    16.             PlayerSettings.bundleVersion = app_version;
    17.             string extension = is_prod ? "aab" : "apk";
    18.             if(!Directory.Exists("../xbuilds/"))
    19.                 Directory.CreateDirectory("../xbuilds/");
    20.             if(!Directory.Exists($"../xbuilds/{apk_name}/"))
    21.                 Directory.CreateDirectory($"../xbuilds/{apk_name}/");
    22.             BuildPipeline.BuildPlayer(GetFirstScene(), $"../xbuilds/{apk_name}/{apk_name}.{extension}", BuildTarget.Android, BuildOptions.None);
    23.         }
    24.  

    Here's the issue: Whenever I run my tool, editor crashes. Weirdly the build process is fine when I access the usual build flow of going under "File-> Build Settings-> Build".
    Here's the crash log:

    Assertion failed on expression: '!(copyData == NULL && byteSize != 0)'
    UnityEngine.StackTraceUtility:ExtractStackTrace ()
    UnityEditor.BuildPipeline:BuildPlayerInternal (string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string[])
    UnityEditor.BuildPipeline:BuildPlayer (string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string[])
    UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions)
    UnityEditor.BuildPipeline:BuildPlayer (string[],string,UnityEditor.BuildTarget,UnityEditor.BuildOptions)
    HWBuildPipeline.BP_BuildAndroid_ES:BuildAndroid (string,string,int,bool) (at Assets/Editor/BuildPipeline/BP_BuildAndroid_ES.cs:62)
    HWBuildPipeline.BP_BuildTool:BuildAndroid () (at Assets/Editor/BuildPipeline/Tool/BP_BuildTool.cs:106)
    HWBuildPipeline.BP_BuildTool:DrawAndroidOptions () (at Assets/Editor/BuildPipeline/Tool/BP_BuildTool.cs:92)
    HWBuildPipeline.BP_BuildTool:OnGUI () (at Assets/Editor/BuildPipeline/Tool/BP_BuildTool.cs:39)
    UnityEditor.HostView:InvokeOnGUI (UnityEngine.Rect)
    UnityEditor.DockArea:DrawView (UnityEngine.Rect)
    UnityEditor.DockArea:OldOnGUI ()
    UnityEngine.UIElements.IMGUIContainer:DoOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect,System.Action,bool)
    UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,System.Action,bool)
    UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,System.Action,bool)
    UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,bool)
    UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase,bool,bool)
    UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUI (UnityEngine.UIElements.EventBase,bool,bool)
    UnityEngine.UIElements.IMGUIContainer:processEvent (UnityEngine.UIElements.EventBase)
    UnityEngine.UIElements.CallbackEventHandler:HandleEvent (UnityEngine.UIElements.EventBase)
    UnityEngine.UIElements.CallbackEventHandler:HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase)
    UnityEngine.UIElements.CallbackEventHandler:HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase)
    UnityEngine.UIElements.MouseCaptureDispatchingStrategy:DispatchEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
    UnityEngine.UIElements.EventDispatcher:ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel,bool)
    UnityEngine.UIElements.EventDispatcher:processEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
    UnityEngine.UIElements.EventDispatcher:processEventQueue ()
    UnityEngine.UIElements.EventDispatcher:OpenGate ()
    UnityEngine.UIElements.EventDispatcherGate:Dispose ()
    UnityEngine.UIElements.EventDispatcher:processEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
    UnityEngine.UIElements.EventDispatcher:Dispatch (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel,UnityEngine.UIElements.DispatchMode)
    UnityEngine.UIElements.BaseVisualElementPanel:SendEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.DispatchMode)
    UnityEngine.UIElements.UIElementsUtility:DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel)
    UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&)
    UnityEngine.UIElements.UIEventRegistration:processEvent (int,intptr)
    UnityEngine.UIElements.UIEventRegistration/<>c:<.cctor>b__1_2 (int,intptr)
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)

    [Assets/Editor/BuildPipeline/BP_BuildAndroid_ES.cs line 62]


    =================================================================
    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.
    =================================================================

    =================================================================
    Managed Stacktrace:
    =================================================================
    at <unknown> <0xffffffff>
    at UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck <0x001a7>
    at UnityEditor.BuildPipeline:BuildPlayerInternal <0x003ca>
    at UnityEditor.BuildPipeline:BuildPlayer <0x00a4a>
    at UnityEditor.BuildPipeline:BuildPlayer <0x001fa>
    at UnityEditor.BuildPipeline:BuildPlayer <0x00462>
    at HWBuildPipeline.BP_BuildAndroid_ES:BuildAndroid <0x00642>
    at HWBuildPipeline.BP_BuildTool:BuildAndroid <0x00232>
    at HWBuildPipeline.BP_BuildTool:DrawAndroidOptions <0x00682>
    at HWBuildPipeline.BP_BuildTool:OnGUI <0x0015a>
    at UnityEditor.HostView:InvokeOnGUI <0x00459>
    at UnityEditor.DockArea:DrawView <0x000d2>
    at UnityEditor.DockArea:OldOnGUI <0x0156a>
    at UnityEngine.UIElements.IMGUIContainer:DoOnGUI <0x01dc8>
    at UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent <0x00b92>
    at UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent <0x0024a>
    at UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent <0x000e2>
    at UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUIRaw <0x0029a>
    at UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUI <0x00f72>
    at UnityEngine.UIElements.IMGUIContainer:processEvent <0x000f2>
    at UnityEngine.UIElements.CallbackEventHandler:HandleEvent <0x00a92>
    at UnityEngine.UIElements.CallbackEventHandler:HandleEventAtCurrentTargetAndPhase <0x0008b>
    at UnityEngine.UIElements.CallbackEventHandler:HandleEventAtTargetPhase <0x0016a>
    at UnityEngine.UIElements.MouseCaptureDispatchingStrategy:DispatchEvent <0x01212>
    at UnityEngine.UIElements.EventDispatcher:ApplyDispatchingStrategies <0x002b5>
    at UnityEngine.UIElements.EventDispatcher:processEvent <0x0046a>
    at UnityEngine.UIElements.EventDispatcher:processEventQueue <0x0033a>
    at UnityEngine.UIElements.EventDispatcher:OpenGate <0x001ea>
    at UnityEngine.UIElements.EventDispatcherGate:Dispose <0x0008a>
    at UnityEngine.UIElements.EventDispatcher:processEvent <0x01442>
    at UnityEngine.UIElements.EventDispatcher:Dispatch <0x0043a>
    at UnityEngine.UIElements.BaseVisualElementPanel:SendEvent <0x0017a>
    at UnityEngine.UIElements.UIElementsUtility:DoDispatch <0x00c62>
    at UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent <0x002c2>
    at UnityEngine.UIElements.UIEventRegistration:processEvent <0x00233>
    at <>c:<.cctor>b__1_2 <0x0009a>
    at UnityEngine.GUIUtility:processEvent <0x002e0>
    at <Module>:runtime_invoke_void_int_intptr_intptr& <0x001b5>
    =================================================================
    Received signal SIGSEGV
    Obtained 71 stack frames
    0x00007ff63c2be3f2 (Unity) CachedWriter::Write
    0x00007ff63c69e161 (Unity) StreamedBinaryWrite::TransferTypelessData
    0x00007ff63c0abcad (Unity) Texture2D::Transfer<StreamedBinaryWrite>
    0x00007ff63c688a43 (Unity) SerializedFile::WriteObject
    0x00007ff63c6723de (Unity) PersistentManager::WriteFile
    0x00007ff63c67443f (Unity) PersistentManager::WriteFile
    0x00007ff63d3864b1 (Unity) WriteSharedAssetFile
    0x00007ff63d37302e (Unity) CompileSharedAssetsFile
    0x00007ff63e0c6881 (Unity) BuildPlayerData
    0x00007ff63e0d0937 (Unity) DoBuildPlayer_Build
    0x00007ff63e0cf346 (Unity) DoBuildPlayer
    0x00007ff63e0c2638 (Unity) BuildPlayer
    0x00007ff63be3ce9f (Unity) BuildPipeline::BuildPlayerInternalNoCheck
    0x00007ff63bb6c1cc (Unity) BuildPipeline_CUSTOM_BuildPlayerInternalNoCheck
    0x000002dc4e2b5c08 (Mono JIT Code) (wrapper managed-to-native) UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck (string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string[],bool)
    0x000002dc4e2b404b (Mono JIT Code) UnityEditor.BuildPipeline:BuildPlayerInternal (string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string[])
    0x000002dc4e2b2e0b (Mono JIT Code) UnityEditor.BuildPipeline:BuildPlayer (string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string[])
    0x000002dc4e2b1b8b (Mono JIT Code) UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions)
    0x000002dc4e2b1173 (Mono JIT Code) UnityEditor.BuildPipeline:BuildPlayer (string[],string,UnityEditor.BuildTarget,UnityEditor.BuildOptions)
    0x000002dc4e2af4a3 (Mono JIT Code) HWBuildPipeline.BP_BuildAndroid_ES:BuildAndroid (string,string,int,bool) (at D:/UnityProjects/HitwicketSuperstars/HitwicketUnity2/Assets/Editor/BuildPipeline/BP_BuildAndroid_ES.cs:62)
    0x000002dc4e2aeca3 (Mono JIT Code) HWBuildPipeline.BP_BuildTool:BuildAndroid () (at D:/UnityProjects/HitwicketSuperstars/HitwicketUnity2/Assets/Editor/BuildPipeline/Tool/BP_BuildTool.cs:106)
    0x000002dc4e2acf43 (Mono JIT Code) HWBuildPipeline.BP_BuildTool:DrawAndroidOptions () (at D:/UnityProjects/HitwicketSuperstars/HitwicketUnity2/Assets/Editor/BuildPipeline/Tool/BP_BuildTool.cs:92)
    0x000002dc4e2a393b (Mono JIT Code) HWBuildPipeline.BP_BuildTool:OnGUI () (at D:/UnityProjects/HitwicketSuperstars/HitwicketUnity2/Assets/Editor/BuildPipeline/Tool/BP_BuildTool.cs:39)
    0x000002dc570adbba (Mono JIT Code) UnityEditor.HostView:InvokeOnGUI (UnityEngine.Rect)
    0x000002dc570ad643 (Mono JIT Code) UnityEditor.DockArea:DrawView (UnityEngine.Rect)
    0x000002dc5708c4db (Mono JIT Code) UnityEditor.DockArea:OldOnGUI ()
    0x000002dc55e777c9 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:DoOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect,System.Action,bool)
    0x000002dabab00b93 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,System.Action,bool)
    0x000002dc52f0729b (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,System.Action,bool)
    0x000002dc52f06f73 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,bool)
    0x000002dc52f061ab (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase,bool,bool)
    0x000002dc52f05e03 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUI (UnityEngine.UIElements.EventBase,bool,bool)
    0x000002dc50ba4663 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:processEvent (UnityEngine.UIElements.EventBase)
    0x000002dc50ba36c3 (Mono JIT Code) UnityEngine.UIElements.CallbackEventHandler:HandleEvent (UnityEngine.UIElements.EventBase)
    0x000002dc50ba2b6c (Mono JIT Code) UnityEngine.UIElements.CallbackEventHandler:HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase)
    0x000002dc50ba205b (Mono JIT Code) UnityEngine.UIElements.CallbackEventHandler:HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase)
    0x000002dc52efe313 (Mono JIT Code) UnityEngine.UIElements.MouseCaptureDispatchingStrategy:DispatchEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
    0x000002dc50cfd236 (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel,bool)
    0x000002dc50cfbacb (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:processEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
    0x000002dc50b6c0eb (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:processEventQueue ()
    0x000002dc50b6bceb (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:OpenGate ()
    0x000002dc50b6ba6b (Mono JIT Code) UnityEngine.UIElements.EventDispatcherGate:Dispose ()
    0x000002dc50cfcaa3 (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:processEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
    0x000002dc50cfaa7b (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:Dispatch (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel,UnityEngine.UIElements.DispatchMode)
    0x000002dc50cfa58b (Mono JIT Code) UnityEngine.UIElements.BaseVisualElementPanel:SendEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.DispatchMode)
    0x000002dc5370cf13 (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel)
    0x000002dc5370c153 (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&)
    0x000002dc5370bac4 (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration:processEvent (int,intptr)
    0x000002dc5370b7bb (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration/<>c:<.cctor>b__1_2 (int,intptr)
    0x000002dc5370a081 (Mono JIT Code) UnityEngine.GUIUtility:processEvent (int,intptr,bool&)
    0x000002dc5370a346 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_int_intptr_intptr& (object,intptr,intptr,intptr)
    0x00007ff8ed4d4c1e (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
    0x00007ff8ed40d254 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3068)
    0x00007ff8ed40d3cc (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3115)
    0x00007ff63c5d0ad4 (Unity) scripting_method_invoke
    0x00007ff63c5ae844 (Unity) ScriptingInvocation::Invoke
    0x00007ff63c5a9455 (Unity) ScriptingInvocation::Invoke<void>
    0x00007ff63c70224a (Unity) Scripting::UnityEngine::GUIUtilityProxy::processEvent
    0x00007ff63d1004f8 (Unity) GUIView::processRetainedMode
    0x00007ff63d6d00a0 (Unity) GUIView::OnInputEvent
    0x00007ff63d100443 (Unity) GUIView::processInputEventFromAPI
    0x00007ff63d100318 (Unity) GUIView::processInputEvent
    0x00007ff63d6d0ede (Unity) GUIView::processEventMessages
    0x00007ff63d6cacf4 (Unity) GUIView::GUIViewWndProc
    0x00007ff9455aef75 (USER32) CallWindowProcW
    0x00007ff9455ae69d (USER32) DispatchMessageW
    0x00007ff63d6a4643 (Unity) MainMessageLoop
    0x00007ff63d6a9690 (Unity) WinMain
    0x00007ff63ea8c26e (Unity) __scrt_common_main_seh
    0x00007ff944b47344 (KERNEL32) BaseThreadInitThunk
    0x00007ff946a226b1 (ntdll) RtlUserThreadStart

    Solutions that I have already tried are:
    1. Reimporting all the assets
    2. Upgrading unity to latest LTS (from 2022.3.14f1 -> 2022.3.25f1)
    3. Deleted Library & Temp folders from the project
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,019
    Try calling BuildPlayer by itself and then start adding the changes to build settings until you find the one that crashes.

    Also check if GetFirstScene does what it is supposed to. It may be returning an array with null entries perhaps.
     
  3. Originator99

    Originator99

    Joined:
    May 5, 2019
    Posts:
    6
    Hi, Thanks for responding to my issue,

    I Called BuildPlayer separately in a single line with hard coded parameters and still crashes the unity editor.
    Moreover, I did check GetFirstScene() method earlier and returns what's required. It does not return any null values.