Search Issue Tracker
Won't Fix
Votes
0
Found in
2019.4.18f1
Issue ID
1311345
Regression
No
Errors and crashes when opening Unity project via Jenkins on Windows
This issue has no description.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- [Mobile] Developer Console does not appear when an error is thrown
- [HDRP] Game view renders artifacts when Camera's Component "Post Anti-aliasing" is set to "TAA" and Dynamic Resolution's "Forced Screen Percentage" is changed
- A deactivated Prefab's name color becomes white when a GameObject in the scene is deactivated
- The Game view becomes blank when using Frame Debugger with MSAA and Texture binding enabled in Play Mode
- NullReferenceException is thrown when changing the Inspector preview selection
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: https://docs.microsoft.com/en-US/troubleshoot/windows/win32/user32-kernel32-not-initialize
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
{
struct STARTUPINFOW
{
public uint cb;
[MarshalAs(UnmanagedType.LPWStr)]
public string lpReserved;
[MarshalAs(UnmanagedType.LPWStr)]
public string lpDesktop;
[MarshalAs(UnmanagedType.LPWStr)]
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;
}
struct PROCESS_INFORMATION
{
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:
break;
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.");
default:
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;
}
}
}