How to run Headless Cinder?

I’m trying to run Cinder on a Jetson TX2 and was interested in using the headless mode. I found the PR1997 with information about it, and was able to get cinder to compile with the headless CMake settings from the master branch.

I compiled the HeadlessTestApp, but when I run it, it crashes immediately:

|info   | virtual bool cinder::app::RendererGlLinux::initialize(glm::ivec2, cinder::app::RendererRef)[61] Supported EGL extensions : EGL_KHR_client_get_all_proc_addresses EGL_EXT_client_extensions EGL_EXT_platform_base EGL_EXT_device_base EGL_KHR_debug EGL_KHR_platform_x11 EGL_EXT_platform_x11 EGL_EXT_platform_device EGL_EXT_platform_wayland
Segmentation fault (core dumped)

This also happens for any app with headless cinder. One big place I may have made a mistake is that I’m trying to run projects that would normally run with cinder – if the app itself needs to be configured specifically for headless, I didn’t notice any special settings. In fact, it looks like the HeadlessTestApp uses a few calls like setWindowSize() so I assume that it’ll work with those calls left in…

Unfortunately, I couldn’t find much other documentation about headless mode other than in a few PRs, so I’m not quite sure how to parse the error message or figure out what I’m missing.

any help would be greatly appreciated.

thanks!

Hey,

Not sure if there is proper support implemented on the ARM drivers that ship with the Jetson for the EGL_EXT_platform_device extension although from your output it seems that it is at least present.

A quick search for headless rendering on the Jetson with this extension shows that people have failed to make it work ( at least in the past ) and couldn’t find any resource indicating that this should/would work properly on this device.

That said you can at least run a debug build of Cinder and the test app through gdb and take a backtrace of the application the moment it crashes so that we have an opportunity to see where exactly things go off.

Cheers,
Petros

Interesting; I saw that the Jetson supported EGL 1.5 and was hoping that meant I could run headless rendering on it. But admittedly, this is pretty uncharted territory for me, so I could be missing something.

I ran the HeadlessTest in gdb, and it gave me a bit more information about where the segmentation fault is happening:

Thread 1 "HeadlessTest" received signal SIGSEGV, Segmentation fault.
strchr () at ../sysdeps/aarch64/strchr.S:101
101     ../sysdeps/aarch64/strchr.S: No such file or directory.

I performed a backtrace and got:

#0  strchr () at ../sysdeps/aarch64/strchr.S:101
#1  0x0000000000889b18 in ParseVersionFromString (pOutMajor=0xc46b58 <g_majorVersion>, pOutMinor=0xc46b5c <g_minorVersion>, strVersion=0x0)
    at /home/nvidia/Documents/myProject/dependencies/cinder/src/glload/gl_load.c:12000
#2  0x0000000000889ec4 in InternalLoad () at /home/nvidia/Documents/myProject/dependencies/cinder/src/glload/gl_load.c:12092
#3  0x000000000088a0f0 in ogl_LoadFunctions () at /home/nvidia/Documents/myProject/dependencies/cinder/src/glload/gl_load.c:12151
#4  0x00000000007e0180 in cinder::gl::EnvironmentCore::initializeFunctionPointers (this=0xc58c80)
    at /home/nvidia/Documents/myProject/dependencies/cinder/src/cinder/gl/EnvironmentCore.cpp:74
#5  0x00000000008e1e00 in cinder::app::RendererGlLinux::initialize (this=0xc83fa0, renderSize=..., sharedRenderer=std::shared_ptr (empty) 0x0)
    at /home/nvidia/Documents/myProject/dependencies/cinder/src/cinder/app/linux/RendererGlLinuxHeadless.cpp:212
#6  0x00000000007c6ac8 in cinder::app::RendererGl::setup (this=0xc84580, renderSize=..., sharedRenderer=std::shared_ptr (empty) 0x0)
    at /home/nvidia/Documents/myProject/dependencies/cinder/src/cinder/app/RendererGl.cpp:447
#7  0x00000000008e4464 in cinder::app::WindowImplLinux::WindowImplLinux (this=0xc84610, format=..., sharedRendererWindow=0x0, appImpl=0xc83d50)
    at /home/nvidia/Documents/myProject/dependencies/cinder/src/cinder/app/linux/WindowImplLinuxHeadless.cpp:39
#8  0x0000000000ab8c78 in cinder::app::AppImplLinux::createWindow (this=0xc83d50, format=...)
    at /home/nvidia/Documents/myProject/dependencies/cinder/src/cinder/app/linux/AppImplLinuxHeadless.cpp:152
#9  0x0000000000ab8458 in cinder::app::AppImplLinux::AppImplLinux (this=0xc83d50, aApp=0xc840e0, settings=...)
    at /home/nvidia/Documents/myProject/dependencies/cinder/src/cinder/app/linux/AppImplLinuxHeadless.cpp:51
#10 0x00000000008e8bfc in cinder::app::AppLinux::AppLinux (this=0xc840e0) at /home/nvidia/Documents/myProject/dependencies/cinder/src/cinder/app/linux/AppLinux.cpp:37
#11 0x000000000075081c in HeadlessTestApp::HeadlessTestApp (this=0xc840e0)
    at /home/ubuntu/Documents/myProject/dependencies/cinder/test/Linux/HeadlessTestApp/src/HeadlessTestApp.cpp:13
#12 0x0000000000750904 in cinder::app::AppLinux::main<HeadlessTestApp>(std::shared_ptr<cinder::app::Renderer> const&, char const*, int, char* const*, std::function<void (cinder::app::AppBase::Settings*)> const&) (defaultRenderer=std::shared_ptr (count 3, weak 0) 0xc82980, title=0xad2210 "HeadlessTestApp", argc=1, argv=0x7ffffff458, settingsFn=...)
    at /home/nvidia/Documents/myProject/dependencies/cinder/include/cinder/app/linux/AppLinux.h:84
#13 0x000000000074e698 in main (argc=1, argv=0x7ffffff458) at /home/ubuntu/Documents/myProject/dependencies/cinder/test/Linux/HeadlessTestApp/src/HeadlessTestApp.cpp:81

Hey,

I had a more detailed look on this and it indeed seems that this could work on recent Jetson devices at least. I found one post that indicates that someone succeeded with the same exact approach the headless Cinder renderer follows so not sure what exactly is happening here.

From your output it looks that all the checks for context/offscreen buffer creation that happen up to this line pass and the application is crashing when trying to get the gl version, just before the function pointers initialization. This looks like that besides the fact that no error has been reported up to that point there is still no valid context created.

Unfortunately I don’t have a device to test so I cannot really offer much of help besides maybe trying to use GLESv2 instead of OpenGL on the Jetson.

I believe you could try to configure Cinder with the following and see if that makes any difference:

cmake .. -DCINDER_HEADLESS_GL=egl -DCINDER_TARGET_GL=es2

Make sure you start with a fresh build directory if you try this out.

EDIT: Found this post (#14) that provides some more info that could be relevant in your situation. More specifically the following quote ( which seems similar to what you are experiencing ):

If we didn’t link against libGLESv2 in addition to libGL, it would silently fail to bind a GL 3.3 core context. No EGL errors are thrown, but all the GL functions tend to fail including glGetString(). We are definitely not using GLES at all so it seems odd that we need to link it.

If the straight es2 route doesn’t work then a quick thing to try would be to add GLESv2 in this line as a link dependency next to EGL and then try to configure and re-compile Cinder for headless as usual with cmake .. -DCINDER_HEADLESS_GL=egl

2 Likes