Search Issue Tracker

Won't Fix



Found in


Issue ID




Errors and crashes when opening Unity project via Jenkins on Windows



This issue has no description.

  1. Response avatar

    Resolution Note:

    The issue happens because Jenkins runs Unity in non-interactive window station. Non-interactive window stations have very small memory limits for GUI operations. Depending on the project, Unity might create less or more Windows GUI objects, and if the limit is reached, Unity will crash.

    There's more information here:

    A good workaround would be to launch the process via this script (Jenkins launches this instead of Unity, and this launches Unity), which makes Unity start on the interactive window station:

    using System;
    using System.ComponentModel;
    using System.Runtime.InteropServices;
    using System.Text;

    namespace ConsoleApp63
    class Program
    public uint cb;
    public string lpReserved;
    public string lpDesktop;
    public string lpTitle;
    public uint dwX;
    public uint dwY;
    public uint dwXSize;
    public uint dwYSize;
    public uint dwXCountChars;
    public uint dwYCountChars;
    public uint dwFillAttribute;
    public uint dwFlags;
    public ushort wShowWindow;
    public ushort cbReserved2;
    public IntPtr lpReserved2;
    public IntPtr hStdInput;
    public IntPtr hStdOutput;
    public IntPtr hStdError;

    public IntPtr hProcess;
    public IntPtr hThread;
    public uint dwProcessId;
    public uint dwThreadId;

    [DllImport("kernel32.dll", SetLastError = true)]
    static extern bool CreateProcessW(
    [MarshalAs(UnmanagedType.LPWStr)] string lpApplicationName,
    [MarshalAs(UnmanagedType.LPWStr)] string lpCommandLine,
    IntPtr lpProcessAttributes,
    IntPtr lpThreadAttributes,
    bool bInheritHandles,
    uint dwCreationFlags,
    IntPtr lpEnvironment,
    [MarshalAs(UnmanagedType.LPWStr)] string lpCurrentDirectory,
    ref STARTUPINFOW lpStartupInfo,
    out PROCESS_INFORMATION lpProcessInformation);

    [DllImport("kernel32.dll", SetLastError = true)]
    static extern uint WaitForSingleObject(IntPtr hHandle, uint dwMilliseconds);

    [DllImport("kernel32.dll", SetLastError = true)]
    static extern bool GetExitCodeProcess(IntPtr hProcess, out uint lpExitCode);

    static int Main(string[] args)
    if (args.Length == 0)
    Console.WriteLine("Usage: <exe> <args>");

    var cmdLineBuilder = new StringBuilder();
    foreach (var arg in args)
    cmdLineBuilder.Append($"\"{arg}\" ");

    var cmdLine = cmdLineBuilder.ToString().Trim();

    STARTUPINFOW startupInfo = default;
    startupInfo.cb = (uint)Marshal.SizeOf(typeof(STARTUPINFOW));
    startupInfo.lpDesktop = "winsta0\\default";

    Console.WriteLine($"Running '{cmdLine}'.");
    var result = CreateProcessW(null, cmdLine, IntPtr.Zero, IntPtr.Zero, true, 0, IntPtr.Zero, null, ref startupInfo, out var processInfo);
    if (!result)
    throw new Win32Exception(Marshal.GetLastWin32Error(), $"Failed to run '{cmdLine}'");

    var waitResult = WaitForSingleObject(processInfo.hProcess, 0xFFFFFFFF);
    switch (waitResult)
    case 0:

    case 0x80:
    throw new Exception($"Failed to wait for '{cmdLine}' to exit: wait was abandoned.");

    case 0x102:
    throw new Exception($"Failed to wait for '{cmdLine}' to exit: wait timed out.");

    throw new Win32Exception(Marshal.GetLastWin32Error(), $"Failed to wait for '{cmdLine}' to exit");

    if (!GetExitCodeProcess(processInfo.hProcess, out var exitCode))
    throw new Win32Exception(Marshal.GetLastWin32Error(), $"Failed to retrieve the exit code of '{cmdLine}'");

    return (int)exitCode;

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.