Uploading this as a test basically. The module owner(s) will need to decide what to do for this file / situation (involves G.background).
Context:
file: source/blender/windowmanager/intern/wm_playanim.c
function: playanim_toscreen (the "public" function in the file is actually WM_main_playanim, called in creator.c)
This function only runs in background mode, when Blender is playing animation files, e.g.: blender -a file.avi
Deprecated OpenGL immediate mode glBegin / etc. functions are used here simply to draw an optional vertical green line (toggle it by pressing "i" on the keyboard) at each keyframe of the animation, as an indicator. It may be an obscure feature, even.
This patch crashes Blender because the gpu is not initialized if !G.background (if we're running in background mode). I tested initializing it with immInit() / immDestroy() in WM_main_playanim(), then it crashes here:
source/blender/gpu/gawain/immediate.c:55 : glGenVertexArrays(1, &imm.vao_id);
then substituted immInit() by GPU_init() / immDestroy() by GPU_exit() and it crashes because of this assert:
BLI_assert failed: source/blender/gpu/intern/gpu_extensions.c:143, gpu_extensions_init(), at '(*(const GLboolean*)&GLEW_VERSION_3_2) || ((*(const GLboolean*)&GLEW_VERSION_3_0) && (*(const GLboolean*)&__GLEW_ARB_draw_elements_base_vertex))'
So it seems a more complete initialization is necessary unless a different solution instead of the immediate mode substitute immXXX API is used.