<div dir="ltr"><div><div><div><div><div><div><div><div><div>Hello.<br><br></div>I wanted to record and replay a trace on a headless server for regression testing purposes. The headless server does not have an X session so the plan was to create one with Xvfb.<br><br></div>Something like:<br><br></div>    % Xvfb :99 -screen 0 640x480x24 &<br></div>    % DISPLAY=:99 apitrace trace -o trace /path/to/executable<br></div>    % DISPLAY=:99 apitrace replay trace <br><br></div>While replaying the trace I'd capture the frame checksums and check against the golden copy and that'd confirm the tests.<br><br></div>When I try this with apitrace the third step (replay) fails with the error message:<br><br>    error: failed to create OpenGL 3.3 core context.<br><br></div><div>My test program is attached. It is a very simple program that uses freeglut to initialise a window and then prints the GL_RENDERER, GL_VENDOR, ... strings.<br><br></div><div>It is compiled with: <br><br>    g++ -o example example.cpp -lGL -lglut<br></div><div><br></div><div>If I run the program when an X session is active:<br><br></div><div>    % ./example<br>    OpenGL initialized:<br>      Version:  3.3 (Core Profile) Mesa 10.6.0-devel<br>      Vendor:   Intel Open Source Technology Center<br>      Renderer: Mesa DRI Intel(R) HD Graphics 5500 (Broadwell GT2) <br>      GLSL:     3.30<br><br></div><div>(Note: running on a broadwell laptop, so this output is entirely expected).<br></div><div><br></div><div>Running it in the Xvfb session:<br><br></div><div>    % DISPLAY=:99 ./example<br></div><div>    OpenGL initialized:<br>      Version:  3.3 (Core Profile) Mesa 10.6.0-devel<br>      Vendor:   VMware, Inc.<br>      Renderer: Gallium 0.4 on llvmpipe (LLVM 3.6, 256 bits)<br>      GLSL:     3.30<br><br></div><div>Running the trace I get:<br><br></div><div>    % DISPLAY=:99 apitrace trace -o trace example<br>    apitrace: loaded into /usr/local/bin/apitrace<br>    apitrace: loaded into /home/nick/example<br>    apitrace: tracing to trace<br>    apitrace: redirecting dlopen("libGL.so.1", 0x102)<br>    OpenGL initialized:<br>    apitrace: attempting to read configuration file: /home/nick/.config/apitrace/gltrace.conf<br>      Version:  3.3 (Core Profile) Mesa 10.6.0-devel<br>      Vendor:   VMware, Inc.<br>      Renderer: Gallium 0.4 on llvmpipe (LLVM 3.6, 256 bits)<br>      GLSL:     3.30<br><br></div><div>If I use apitrace to dump the trace:<br><br></div><div>    % DISPLAY=:99 apitrace dump trace<br></div><div>    1 glXChooseFBConfig(dpy = 0xa444f0, screen = 0, attribList = {GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, True, GLX_DEPTH_SIZE, 1, 0}, nitems = &64) = {0xa7e020, 0xa7e200, 0xa83480, 0xa83660, 0xa7d4e0, 0xa7d6c0, 0xa82940, 0xa82b20, 0xa7da80, 0xa7dc60, 0xa82ee0, 0xa830c0, 0xa7ce10, 0xa7d120, 0xa823a0, 0xa82580, 0xa7c2d0, 0xa7c4b0, 0xa81860, 0xa81a40, 0xa7b790, 0xa7b970, 0xa80d20, 0xa80f00, 0xa7bd30, 0xa7bf10, 0xa812c0, 0xa814a0, 0xa7b1f0, 0xa7b3d0, 0xa80780, 0xa80960, 0xa7e110, 0xa7e2f0, 0xa83570, 0xa83750, 0xa7d5d0, 0xa7d7b0, 0xa82a30, 0xa82c10, 0xa7db70, 0xa7dd50, 0xa82fd0, 0xa831b0, 0xa7cf00, 0xa7d210, 0xa82490, 0xa82670, 0xa7c3c0, 0xa7c5a0, 0xa81950, 0xa81b30, 0xa7b880, 0xa7ba60, 0xa80e10, 0xa80ff0, 0xa7be20, 0xa7c000, 0xa813b0, 0xa81590, 0xa7b2e0, 0xa7b4c0, 0xa80870, 0xa80a50}<br>    2 glXGetVisualFromFBConfig(dpy = 0xa444f0, config = 0xa7e020) = &{visual = 0xa4f630, visualid = 297, screen = 0, depth = 24, c_class = 4, red_mask = 16711680, green_mask = 65280, blue_mask = 255, colormap_size = 256, bits_per_rgb = 8}<br>    4 glXCreateContextAttribsARB(dpy = 0xa444f0, config = 0xa7e020, share_context = NULL, direct = True, attrib_list = {GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MINOR_VERSION_ARB, 3, GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, 0}) = 0xa55da0<br>    6 glXMakeContextCurrent(dpy = 0xa444f0, draw = 2097154, read = 2097154, ctx = 0xa55da0) = True<br>    7 glViewport(x = 0, y = 0, width = 400, height = 400)<br>    8 glScissor(x = 0, y = 0, width = 400, height = 400)<br>    9 glXMakeContextCurrent(dpy = 0xa444f0, draw = 2097154, read = 2097154, ctx = 0xa55da0) = True<br>    14 glXMakeContextCurrent(dpy = 0xa444f0, draw = 2097154, read = 2097154, ctx = 0xa55da0) = True<br>    15 glXDestroyContext(dpy = 0xa444f0, ctx = 0xa55da0)<br><br></div><div>If I try to replay:<br><br></div><div>    %DISPLAY=:99 apitrace replay -vvv trace<br>    0 @0 glXQueryExtension(dpy = 0xa444f0, errorb = NULL, event = NULL) = True<br>    1 @0 glXChooseFBConfig(dpy = 0xa444f0, screen = 0, attribList = {GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, True, GLX_DEPTH_SIZE, 1, 0}, nitems = &64) = {0xa7e020, 0xa7e200, 0xa83480, 0xa83660, 0xa7d4e0, 0xa7d6c0, 0xa82940, 0xa82b20, 0xa7da80, 0xa7dc60, 0xa82ee0, 0xa830c0, 0xa7ce10, 0xa7d120, 0xa823a0, 0xa82580, 0xa7c2d0, 0xa7c4b0, 0xa81860, 0xa81a40, 0xa7b790, 0xa7b970, 0xa80d20, 0xa80f00, 0xa7bd30, 0xa7bf10, 0xa812c0, 0xa814a0, 0xa7b1f0, 0xa7b3d0, 0xa80780, 0xa80960, 0xa7e110, 0xa7e2f0, 0xa83570, 0xa83750, 0xa7d5d0, 0xa7d7b0, 0xa82a30, 0xa82c10, 0xa7db70, 0xa7dd50, 0xa82fd0, 0xa831b0, 0xa7cf00, 0xa7d210, 0xa82490, 0xa82670, 0xa7c3c0, 0xa7c5a0, 0xa81950, 0xa81b30, 0xa7b880, 0xa7ba60, 0xa80e10, 0xa80ff0, 0xa7be20, 0xa7c000, 0xa813b0, 0xa81590, 0xa7b2e0, 0xa7b4c0, 0xa80870, 0xa80a50}<br>    2 @0 glXGetVisualFromFBConfig(dpy = 0xa444f0, config = 0xa7e020) = &{visual = 0xa4f630, visualid = 297, screen = 0, depth = 24, c_class = 4, red_mask = 16711680, green_mask = 65280, blue_mask = 255, colormap_size = 256, bits_per_rgb = 8}<br>    3 @0 glXGetProcAddressARB(procName = "glXCreateContextAttribsARB") = 0x7f49a8ac15f2<br>    4 @0 glXCreateContextAttribsARB(dpy = 0xa444f0, config = 0xa7e020, share_context = NULL, direct = True, attrib_list = {GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MINOR_VERSION_ARB, 3, GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, 0}) = 0xa55da0<br>    <b>error: failed to create OpenGL 3.3 core context.</b><br></div><div><br></div>Initially I suspected that the DISPLAY variable was not propagating to the glretrace child of "apitrace replay" but I have<br> 1) straced to verify that the environment variable DISPLAY=:99 is making it through to the glretrace child process spawned by apitrace, and<br></div><div> 2) confirmed that the code uses XOpenDisplay(NULL), which should open the X display in the environment variable DISPLAY<br><br></div><div>Anyone have any ideas or experience running apitrace on headless servers?<br><br></div><div>Thanks,<br></div><div> -- Nick<br></div><div><br></div></div>