Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#2847 closed defect (fixed)

[PATCH] SDL2: Atlas fails to start on Linux

Reported by: historic_bruno Owned by: ben
Priority: Must Have Milestone: Alpha 18
Component: Atlas editor Keywords: patch
Cc: yashi, againsttcpa84@… Patch:

Description

This is an OpenGL context initialization problem, yashi has been debugging it and made a patch on #2041.

#7  0x0000000000a7ddc7 in ogl_Init () at ../../../source/lib/ogl.cpp:479
#8  0x00000000009b3e31 in AtlasMessage::fInitGraphics (msg=0x168ade0)
    at ../../../source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp:84
#9  0x00000000009b3de7 in AtlasMessage::fInitGraphics_wrapper (msg=0x168ade0)
    at ../../../source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp:64
#10 0x0000000000979714 in RunEngine (data=0x7fffffffe100)
    at ../../../source/tools/atlas/GameInterface/GameLoop.cpp:174
#11 0x00007ffff3c7f0a4 in start_thread (arg=0x7fffe077f700) at pthread_create.c:309
#12 0x00007ffff39b4c2d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
(gdb) f 7
#7  0x0000000000a7ddc7 in ogl_Init () at ../../../source/lib/ogl.cpp:479
479		ENSURE(exts);	// else: called before OpenGL is ready for use
(gdb) p exts
$1 = 0x0
(gdb) 

Attachments (2)

fix-atlas-sdl2.diff (2.4 KB) - added by historic_bruno 5 years ago.
cleaned up version of yashi's patch from #2041
fix-atlas-sdl2.v2.diff (2.7 KB) - added by historic_bruno 5 years ago.
updated patch to fix crash on Windows

Download all attachments as: .zip

Change History (15)

comment:1 Changed 5 years ago by historic_bruno

Priority: Should HaveMust Have

comment:2 Changed 5 years ago by Michael

Cc: againsttcpa84@… added

comment:3 Changed 5 years ago by trompetin17

Atlas use wxGLCanvas, it create opengl context, if you look in the code for linux https://github.com/wxWidgets/wxWidgets/blob/master/src/unix/glx11.cpp#L119

if ( gc->GetGLXContextAttribs()[0] != 0 ) // OpenGL 3 context creation

so by default use opengl version 3 if you already can use in linux. and glGetString(GL_EXTENSIONS) is obsolete as of OpenGL 3.0. most drivers seem to be tolerant of its continued use, but at least some cases on Linux are NOT, and this call returns NULL, thus causing an actual crash in the code.

One way to fix this is to set in atlas.

int glAttribList[] = {
		0, //this 0 make the difference from opengl 3
		WX_GL_RGBA,
		WX_GL_DOUBLEBUFFER,
		WX_GL_DEPTH_SIZE, 24, // TODO: wx documentation doesn't say 24 is valid
		WX_GL_STENCIL_SIZE, 8,
		WX_GL_BUFFER_SIZE, 24, // colour bits
		WX_GL_MIN_ALPHA, 8, // alpha bits
		0
	};
	Canvas* canvas = new GameCanvas(*this, m_SectionLayout.GetCanvasParent(), glAttribList);

but i need someone who has linux that help me to test,

Last edited 5 years ago by trompetin17 (previous) (diff)

comment:4 Changed 5 years ago by historic_bruno

Keywords: patch review added
Milestone: BacklogAlpha 18
Summary: SDL2: Atlas fails to start on Linux[PATCH] SDL2: Atlas fails to start on Linux

I haven't tested that the patch works, it should definitely be a Linux-only patch as it breaks on Windows. But looking at the wxWidgets source code, it seems the hack that makes this possible requires wxWidgets 3.0.2? At least on my Ubuntu 14.04 VM, the latest I have is 3.0.0, so to test I need a custom wxWidgets build.

comment:5 Changed 5 years ago by historic_bruno

Keywords: review removed

There was some discussion and testing in IRC on 2015-02-17.

I built wxWidgets 3.0.2 on my Ubuntu VM and tested the above patch, unfortunately the error still occurred.

OpenGL vendor string: VMware, Inc.
OpenGL renderer string: Gallium 0.4 on SVGA3D; build: RELEASE;  
OpenGL version string: 2.1 Mesa 10.1.3
OpenGL shading language version string: 1.20

Changed 5 years ago by historic_bruno

Attachment: fix-atlas-sdl2.diff added

cleaned up version of yashi's patch from #2041

comment:6 Changed 5 years ago by historic_bruno

Finally got around to testing yashi's patch from #2041 and it solves the main problem. I cleaned it up slightly and added a new InitSDL message. So the Atlas init order is now: 1) Init 2) InitSDL 3) SetCanvas 4) InitGraphics

So far I have tested it on Ubuntu 14.04 with both SDL 1.2.15 and SDL 2.0.2, as well as wxWidgets 2.8.12 and 3.0.2, and on Windows (SDL 2.0.3/wxWidgets 3.0.2). Please test on as many systems as possible to help get this into A18!

The OpenGL 3+ GL_EXTENSIONS issue is not addressed by the patch, and I don't have a system that can reproduce that problem. I'm going to consider it a separate issue for now. If anyone has a Linux system w/ OpenGL 3+ and can test Atlas with wxWidgets 3.0.2, that would be great.

Last edited 5 years ago by historic_bruno (previous) (diff)

comment:7 Changed 5 years ago by historic_bruno

Keywords: review added

comment:8 in reply to:  6 Changed 5 years ago by trompetin17

Tested with Yosemite and everything looks ok from atlas

Replying to historic_bruno:

Finally got around to testing yashi's patch from #2041 and it solves the main problem. I cleaned it up slightly and added a new InitSDL message. So the Atlas init order is now: 1) Init 2) InitSDL 3) SetCanvas 4) InitGraphics

So far I have tested it on Ubuntu 14.04 with both SDL 1.2.15 and SDL 2.0.2, as well as wxWidgets 2.8.12 and 3.0.2, and on Windows (SDL 2.0.3/wxWidgets 3.0.2). Please test on as many systems as possible to help get this into A18!

The OpenGL 3+ GL_EXTENSIONS issue is not addressed by the patch, and I don't have a system that can reproduce that problem. I'm going to consider it a separate issue for now. If anyone has a Linux system w/ OpenGL 3+ and can test Atlas with wxWidgets 3.0.2, that would be great.

comment:9 Changed 5 years ago by elexis

The patch (http://trac.wildfiregames.com/attachment/ticket/2847/fix-atlas-sdl2.diff) works on my system and Atlas doesn't crash & works as expected.

System Info: -Ubuntu 14.10 -OpenGL version string: 4.4.12968 Compatibility Profile Context 14.501.1003 -AMD Graphics card with fglrx driver from the repository -compiled 0ad against SDL2

comment:10 Changed 5 years ago by stanislas69

It breaks the windows build though. VS reports an access violation and breaks line 495 in HWDETECT.cpp

System Info :

  • Windows 8.1.1 64Bits

Changed 5 years ago by historic_bruno

Attachment: fix-atlas-sdl2.v2.diff added

updated patch to fix crash on Windows

comment:11 Changed 5 years ago by stanislas69

Works for me, with the first patch, the problem was the way I was building atlas.

comment:12 Changed 5 years ago by ben

Owner: set to ben
Resolution: fixed
Status: newclosed

In 16356:

Fixes Atlas on Linux with SDL2 by reordering OpenGL init, based on patch by yashi, fixes #2847

comment:13 Changed 4 years ago by sanderd17

Keywords: review removed
Note: See TracTickets for help on using tickets.