Unity 5.3 seems to break -batchmode -nographics on headless linux

Hi everyone,

I’m experimenting with building Unity in a headless Amazon EC2 instance. Sadly, it seems to be somehow broken with Unity 5.3.

Running/opt/Unity/Editor/Unity -batchmode -nographics -logFileonly crashes Unity with the following error:
Forcing GfxDevice: Null

NullGfxDevice:
Version: NULL 1.0 [1.0]
Renderer: Null Device
Vendor: Unity Technologies

Receiving unhandled NULL exception
Launching bug reporter

#0 0x007fff9821e6c0 in _L_unlock_13
#1 0x007fff9821ec70 in PPtr::operator Camera*() const
#2 0x007fff9821ece0 in RenderTexture::SetActive(GfxRenderTargetSetup const&, RenderTexture**, unsigned int)
#3 0x007fff9821ed80 in RenderTexture::SetActive(int, ObjectHandle<RenderSurface_Tag, RenderSurfaceBase*>, ObjectHandle<RenderSurface_Tag, RenderSurfaceBase>, RenderTexture**, int, CubemapFace, unsigned int)
#4 0x007fff9821ee70 in RenderTexture::SetActive(RenderTexture*, int, CubemapFace, unsigned int)
#5 0x007fff9821eed0 in InitializeGfxDevice(unsigned int)
#6 0x007fff9821ef10 in InitializeUnity(void*)
#7 0x007fff9821ef90 in main
#8 0x007fff9821f330 in __libc_start_main
#9 0x007fff9821f3f0 in _start

Using xvrb-run yields the same result. Using xvfb-run without the -nographics option results in crashes that seem to be related to the switch to the new OpenGL 3.2 API.

The same commands are working with Unity 5.2. However, we are already using new 5.3 APIs so switching back is not really an easy option.

Anyone else got similar problems?

Cheers,

Christian

I’ll help contribute and run a headless build to see if I get the issue as well, give me a moment… :smile:

Thanks for the report - we’ll investigate.
Does passing -batchmode -force-opengl when using xvfb-run help anything?

Here are the different outputs from different xvfb-run commands:

xvfb-run /opt/Unity/Editor/Unity -batchmode -force-opengl -logFile

mono profile = ‘/opt/Unity/Editor/Data/Mono/lib/mono/2.0’
Initialize mono
Mono path[0] = ‘/opt/Unity/Editor/Data/Managed’
Mono path[1] = ‘/opt/Unity/Editor/Data/Mono/lib/mono/2.0’
Mono path[2] = ‘/opt/Unity/Editor/Data/UnityScript’
Mono path[3] = ‘/opt/Unity/Editor/Data/Mono/lib/mono/2.0’
Mono config path = ‘/opt/Unity/Editor/Data/Mono/etc’
Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,defer=y,address=0.0.0.0:56378

(process:28378): Gtk-WARNING : Locale not supported by C library.
Using the fallback ‘C’ locale.
Xlib: extension “RANDR” missing on display “:99”.
libGL error: failed to load driver: swrast
No matching FBConfig foundReceiving unhandled NULL exception
Launching bug reporter
#0 0x007fffaf021080 in _L_unlock_13
#1 0x007fffaf021630 in CreateWindowForEditor(void
, void
, char const*, int, int, int, bool, std::string const&)
#2 0x007fffaf021750 in ScreenManagerLinux::CreateMainWindow(bool, int, int, bool)
#3 0x007fffaf0217d0 in ScreenManagerLinux::Initialize(bool, int, int, bool, int, int, bool)
#4 0x007fffaf021810 in InitializeUnity(void*)
#5 0x007fffaf021890 in g_source_get_time
#6 0x007fffaf0218b0 in g_main_context_dispatch
#7 0x007fffaf021930 in g_main_context_dispatch
#8 0x007fffaf021990 in g_main_loop_run
#9 0x007fffaf0219b0 in gtk_main
#10 0x007fffaf021a20 in main
#11 0x007fffaf021dc0 in __libc_start_main
#12 0x007fffaf021e80 in _start
Fontconfig warning: ignoring UTF-8: not a valid region tag
libGL error: failed to load driver: swrast
Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.
Unsupported screen depth: 8
Unsupported screen depth: 8
Unsupported screen depth: 8
QWidget::paintEngine: Should no longer be called
QPainter::begin: Paint device returned engine == 0, type: 1
QWidget::paintEngine: Should no longer be called
(continues on for quite a while with more QWidget/QPainter errors)

Next try, setting a display with xvfb-run seems to at least bring some progress, but still seems to use the new OpenGL 3.2-based API

xvfb-run --server-args="-screen 0 1024x768x24" /opt/Unity/Editor/Unity -batchmode -force-opengl -logFile

mono profile = ‘/opt/Unity/Editor/Data/Mono/lib/mono/2.0’
Initialize mono
Mono path[0] = ‘/opt/Unity/Editor/Data/Managed’
Mono path[1] = ‘/opt/Unity/Editor/Data/Mono/lib/mono/2.0’
Mono path[2] = ‘/opt/Unity/Editor/Data/UnityScript’
Mono path[3] = ‘/opt/Unity/Editor/Data/Mono/lib/mono/2.0’
Mono config path = ‘/opt/Unity/Editor/Data/Mono/etc’
Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,defer=y,address=0.0.0.0:56166

(process:25166): Gtk-WARNING **: Locale not supported by C library.
Using the fallback ‘C’ locale.
Xlib: extension “RANDR” missing on display “:99”.

Selecting FBConfig
GLX_FBCONFIG_ID=83
GLX_BUFFER_SIZE=32
GLX_DOUBLEBUFFER=1
GLX_RED_SIZE=8
GLX_GREEN_SIZE=8
GLX_BLUE_SIZE=8
GLX_ALPHA_SIZE=8
GLX_DEPTH_SIZE=24
GLX_STENCIL_SIZE=8
GLX_SAMPLES_ARB=0
GLX_SAMPLE_BUFFERS_ARB=0
GLX_STEREO=0
GLX_CONFIG_CAVEAT=NONE

BATCHMODE ARGUMENTS:
/opt/Unity/Editor/Unity
-batchmode
-force-opengl
-logFile
/home/ubuntu/src/aybaze
kLargestEditorClassID == ms_MaxClassID

(Filename: /home/builduser/buildslave/unity/build/Runtime/BaseClasses/BaseObject.cpp Line: 982)

UpdateMenuTitleForLanguage: 10
Using libudev for joystick management

Importing game controller configs
Loading GUID ↔ Path mappings…0.000521 seconds
Loading Asset Database…0.012283 seconds
ALSA lib confmisc.c:768:(parse_card) cannot find card ‘0’
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default
FMOD failed to initialize the output device, attempting to initialize the null output.

(Filename: /home/builduser/buildslave/unity/build/Runtime/Audio/AudioManager.cpp Line: 1186)

AudioManager: Using Unknown: NoSound Driver
AssetDatabase consistency checks…0.101109 seconds
Initialize engine version: 5.3.0f4 (b14eb5634aa2)
GLX Extensions: GLX_ARB_get_proc_address GLX_ARB_multisample GLX_EXT_import_context GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_copy_sub_buffer GLX_MESA_multithread_makecurrent GLX_OML_swap_method GLX_SGI_make_current_read GLX_SGIS_multisample GLX_SGIX_fbconfig GLX_SGIX_pbuffer GLX_EXT_texture_from_pixmap
Setting maxVSyncInterval to 0
Renderer: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits)
Vendor: VMware, Inc.
Version: 2.1 Mesa 10.1.3
GLES: 0
glGetString(GL_EXTENSIONS) - failureOPENGL LOG: Creating OpenGL 0.0 graphics device
/home/builduser/buildslave/unity/build/Editor/Platform/Linux/EditorUtility.cpp:smile:isplayDialog
title=‘Graphics card not supported by Unity’
content=‘OpenGL 3.2 is required. Your GPU (Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits)) or OpenGL drivers only supports OpenGL 0.0’
process_set_termination_details: error looking up process handle 0x401

I’m having the exact same response with the same input on Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-57-generic x86_64)

If you find a solution I would be happy if you find the time to post it here :wink:

Hi, i’m facing exact the same problem on a Ubunut Server 15.10 amd64. Any hint would be great.

xvfb-run --server-args=“-screen 0 1024x768x24” /opt/Unity/Editor/Unity -batchmode -logfile -force-opengl -quit -projectPath /home/red/cc/Main/CCMain/ -buildWindows64Player /home/red/cc_build/cc.exe
[sudo] password for red:
mono profile = ‘/opt/Unity/Editor/Data/Mono/lib/mono/2.0’
Initialize mono
Mono path[0] = ‘/opt/Unity/Editor/Data/Managed’
Mono path[1] = ‘/opt/Unity/Editor/Data/Mono/lib/mono/2.0’
Mono path[2] = ‘/opt/Unity/Editor/Data/UnityScript’
Mono path[3] = ‘/opt/Unity/Editor/Data/Mono/lib/mono/2.0’
Mono config path = ‘/opt/Unity/Editor/Data/Mono/etc’
Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,defer=y,address=0.0.0.0:56049
Xlib: extension “RANDR” missing on display “:99”.

Selecting FBConfig
GLX_FBCONFIG_ID=83
GLX_BUFFER_SIZE=32
GLX_DOUBLEBUFFER=1
GLX_RED_SIZE=8
GLX_GREEN_SIZE=8
GLX_BLUE_SIZE=8
GLX_ALPHA_SIZE=8
GLX_DEPTH_SIZE=24
GLX_STENCIL_SIZE=8
GLX_SAMPLES_ARB=0
GLX_SAMPLE_BUFFERS_ARB=0
GLX_STEREO=0
GLX_CONFIG_CAVEAT=NONE

CreateDirectory ‘/home/red/.local/share/unity3d/Unity’ failed:

BATCHMODE ARGUMENTS:
/opt/Unity/Editor/Unity
-batchmode
-logfile
-force-opengl
-quit
-projectPath
/home/red/cc/Main/CCMain/
-buildWindows64Player
/home/red/cc_build/cc.exe
Successfully changed project path to: /home/red/cc/Main/CCMain/
/home/red/cc/Main/CCMain
kLargestEditorClassID == ms_MaxClassID

(Filename: /home/builduser/buildslave/unity/build/Runtime/BaseClasses/BaseObject.cpp Line: 982)

UpdateMenuTitleForLanguage: 10
Using libudev for joystick management

Importing game controller configs
Loading GUID ↔ Path mappings…0.001154 seconds
Loading Asset Database…0.002021 seconds
ALSA lib confmisc.c:768:(parse_card) cannot find card ‘0’
ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM default
FMOD failed to initialize the output device, attempting to initialize the null output.

(Filename: /home/builduser/buildslave/unity/build/Runtime/Audio/AudioManager.cpp Line: 1186)

AudioManager: Using Unknown: NoSound Driver
AssetDatabase consistency checks…0.151039 seconds
Initialize engine version: 5.3.0f4 (b14eb5634aa2)
GLX Extensions: GLX_ARB_get_proc_address GLX_ARB_multisample GLX_EXT_import_context GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_copy_sub_buffer GLX_MESA_multithread_makecurrent GLX_MESA_query_renderer GLX_OML_swap_method GLX_SGI_make_current_read GLX_SGIS_multisample GLX_SGIX_fbconfig GLX_SGIX_pbuffer GLX_EXT_texture_from_pixmap
Setting maxVSyncInterval to 0
Renderer: Gallium 0.4 on llvmpipe (LLVM 3.6, 256 bits)
Vendor: VMware, Inc.
Version: 3.0 Mesa 11.0.2
GLES: 0
GL_ARB_ES2_compatibility GL_ARB_ES3_compatibility GL_ARB_base_instance GL_ARB_blend_func_extended GL_ARB_buffer_storage GL_ARB_clear_buffer_object GL_ARB_clip_control GL_ARB_color_buffer_float GL_ARB_compressed_texture_pixel_storage GL_ARB_conditional_render_inverted GL_ARB_copy_buffer GL_ARB_conservative_depth GL_ARB_debug_output GL_ARB_depth_buffer_float GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_draw_buffers_blend GL_ARB_draw_elements_base_vertex GL_ARB_draw_instanced GL_ARB_explicit_attrib_location GL_ARB_explicit_uniform_location GL_ARB_fragment_coord_conventions GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_framebuffer_object GL_ARB_framebuffer_sRGB GL_ARB_get_program_binary GL_ARB_get_texture_sub_image GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_instanced_arrays GL_ARB_internalformat_query GL_ARB_invalidate_subdata GL_ARB_map_buffer_alignment GL_ARB_map_buffer_range GL_ARB_multi_bind GL_ARB_multisample GL_ARB_multitexture GL_A
RB_occlusion_query2 GL_ARB_occlusion_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_program_interface_query GL_ARB_provoking_vertex GL_ARB_robustness GL_ARB_sampler_objects GL_ARB_seamless_cube_map GL_ARB_seamless_cubemap_per_texture GL_ARB_separate_shader_objects GL_ARB_shader_bit_encoding GL_ARB_shader_objects GL_ARB_shader_stencil_export GL_ARB_shader_texture_lod GL_ARB_shading_language_100 GL_ARB_shading_language_packing GL_ARB_shading_language_420pack GL_ARB_shadow GL_ARB_stencil_texturing GL_ARB_sync GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_compression_rgtc GL_ARB_texture_cube_map GL_ARB_texture_cube_map_array GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_gather GL_ARB_texture_mirrored_repeat GL_ARB_texture_mirror_clamp_to_edge GL_ARB_texture_multisample GL_ARB_texture_non_power_of_two GL_ARB_texture_query_levels GL_ARB_texture_rectangle GL_ARB_te
xture_rgb10_a2ui GL_ARB_texture_rg GL_ARB_texture_stencil8 GL_ARB_texture_storage GL_ARB_texture_storage_multisample GL_ARB_texture_view GL_ARB_texture_swizzle GL_ARB_timer_query GL_ARB_transform_feedback2 GL_ARB_transform_feedback3 GL_ARB_transform_feedback_instanced GL_ARB_transpose_matrix GL_ARB_uniform_buffer_object GL_ARB_vertex_array_bgra GL_ARB_vertex_array_object GL_ARB_vertex_attrib_binding GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_vertex_type_10f_11f_11f_rev GL_ARB_vertex_type_2_10_10_10_rev GL_ARB_window_pos GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_copy_texture GL_EXT_draw_buffers2 GL_EXT_draw_instanced GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_framebuffer_multisample_blit_scaled GL_EXT_framebuffer_object GL_EXT_framebuffer_sRGB GL_EXT_gpu_program_parameters GL_EX
T_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_packed_pixels GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_polygon_offset GL_EXT_polygon_offset_clamp GL_EXT_provoking_vertex GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shader_integer_mix GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_subtexture GL_EXT_texture3D GL_EXT_texture_array GL_EXT_texture_compression_dxt1 GL_ANGLE_texture_compression_dxt3 GL_ANGLE_texture_compression_dxt5 GL_EXT_texture_compression_latc GL_EXT_texture_compression_rgtc GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_add GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_integer GL_EXT_texture_lod_bias GL_EXT_texture_mirror_clamp GL_EXT_texture_object GL_EXT_texture GL_EXT_texture_rectangle GL_EXT_texture_shared_exponent GL_EXT_texture_snorm GL_EXT_texture_sRGB GL_EXT_texture_sRGB_decode GL_EXT_texture_swizzle GL_EXT_t
imer_query GL_EXT_transform_feedback GL_EXT_vertex_array_bgra GL_EXT_vertex_array GL_OES_EGL_image GL_OES_read_format GL_KHR_debug GL_KHR_context_flush_control GL_AMD_conservative_depth GL_AMD_draw_buffers_blend GL_AMD_seamless_cubemap_per_texture GL_AMD_shader_stencil_export GL_AMD_shader_trinary_minmax GL_APPLE_packed_pixels GL_APPLE_vertex_array_object GL_ATI_blend_equation_separate GL_ATI_draw_buffers GL_ATI_separate_stencil GL_ATI_texture_compression_3dc GL_ATI_texture_env_combine3 GL_ATI_texture_float GL_ATI_texture_mirror_once GL_IBM_multimode_draw_arrays GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_INGR_blend_func_separate GL_MESA_pack_invert GL_MESA_texture_signed_rgba GL_MESA_window_pos GL_MESA_ycbcr_texture GL_NV_blend_square GL_NV_conditional_render GL_NV_depth_clamp GL_NV_fog_distance GL_NV_light_max_exponent GL_NV_packed_depth_stencil GL_NV_primitive_restart GL_NV_texgen_reflection GL_NV_texture_env_combine4 GL_NV_texture_rectangle GL_S3_s3tc GL_SGIS_generate_mipmap GL_SGIS_texture_b
order_clamp GL_SGIS_texture_edge_clamp GL_SGIS_texture_lod GL_SUN_multi_draw_arrays
OPENGL LOG: Creating OpenGL 3.0 graphics device
/home/builduser/buildslave/unity/build/Editor/Platform/Linux/EditorUtility.cpp:smile:isplayDialog
title=‘Graphics card not supported by Unity’
content=‘OpenGL 3.2 is required. Your GPU (Gallium 0.4 on llvmpipe (LLVM 3.6, 256 bits)) or OpenGL drivers only supports OpenGL 3.0’
process_set_termination_details: error looking up process handle 0x401
Receiving unhandled NULL exception
Launching bug reporter
Receiving unhandled NULL exception
Launching bug reporter
#0 0x007f145c03c580 in funlockfile
Receiving unhandled NULL exception
Launching bug reporter
#0 0x007f145c83d580 in funlockfile
Receiving unhandled NULL exception
Launching bug reporter
#0 0x007f145a839580 in funlockfile
#1 0x007f145a839b10 in MemoryProfiler::PushAllocationRoot(void*, BaseAllocator*, bool)
#1 0x007f145a839b10 in MemoryProfilReceiving unhandled NULL exception
Launching bug reporter
#0 0x007f1459837580 in funlockfile
Receiving unhandled NULL exception
Launching bug reporter
#0 0x007f1460044580 in funlockfile
#1 0x007f1460044b10 in MemoryProfiler::PushAllocationRoot(void*, BaseAllocator*, bool)
Receiving unhandled NULL exception
Launching bug reporter
#0 0x007f145b03a580 in funlockfile
Receiving unhandled NULL exception
Launching bug reporter
#0 0x007f145a038580 in funlockfile
#1 0x007f145a038b10 in MemoryProfiler::PushAllocationRoot(void*, BaseAllocator*, bool)
#1 0x007f145c03cb10 in MemoryProfiler::PushAllocationRoot(void*, BaseAllocator*, bool)
#1 0x007f145c83db10 in MemoryProfiler::PushAllocationRoot(void*, BaseAllocator*, bool)
Receiving unhandled NULL exception
Launching bug reporter
#0 0x007f145d03e580 in funlockfile
Receiving unhandled NULL exception
Launching bug reporter
#1 0x007f1459837b10 in MemoryProfiler::PushAllocationRoot(void*, BaseAllocator*, bool)
Receiving unhandled NULL exception
Launching bug reporter
#1 0x007f145b03ab10 in MemoryProfiler::PushAllocationRoot(void*, BaseAllocator*, bool)
Receiving unhandled NULL exception
Receiving unhandled NULL exception
Launching bug reporter
Launching bug reporter

Just FYI. With the recent 5.3.1 release of Unity, things seem to work fine again. Here is the excerpt of my running bamboo agent:
#/bin/bash
projectPath=pwd
echo "Building in project {projectPath}" /usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" /opt/Unity/Editor/Unity -batchmode -logfile -force-opengl -quit -projectPath {projectPath} -executeMethod $1

I can confirm that moving from -nographics to -force-opengl worked on my end.

The amount of smileys (more like sad faces and tongues… :smile:) on that post is absolutely HILARIOUS. :slight_smile:

Adding the -force-opengl seems to work on my server too.

Um… wut? XD
In that case, this weird headless mode bug must be linked to the graphics initialization error a lot of people get with some intel chipsets, as that is caused by unity ignoring what it’s supposed to use, and immediately tries to fire up a GL 3.3 context.

Some smart guy on another thread (can’t remember his name!) found this by hooking into his game’s process while it was starting up, and found out it was trying to compile a GLSL 1.5 shader… and ultimately failing, when it should have checked the context version first. :smile: This could very well be why headless mode fails… Just some food for thought.

Feel free to correct me if I’m wrong though, unity’s a complex and sometimes illogical beast at times. :wink: