Farama-Foundation / Arcade-Learning-Environment

The Arcade Learning Environment (ALE) -- a platform for AI research.
https://ale.farama.org/
GNU General Public License v2.0
2.18k stars 424 forks source link

ALEInterface + SDL crashes on Mac OSX 10.9 #30

Closed michael-p closed 9 years ago

michael-p commented 9 years ago

Dear all,

I modified sharedLibraryInterfaceExample.cpp in docs/examples by adding the line

ale.set("display_screen", "true"); // or ale.set("display_screen", true);

directly before calling loadRom in order to display the emulator screen using SDL. However, the program crashes with the following error:

A.L.E: Arcade Learning Environment (version 0.4.4)
[Powered by Stella]
Use -help for help screen.
Warning: couldn't load settings file: ./stellarc
Game console created:
  ROM file:  ../../atari/roms/pong.bin
  Cart Name: Video Olympics (1978) (Atari)
  Cart MD5:  60e0ea3cbe0913d39803477945e9e5ec
  Display Format:  AUTO-DETECT ==> NTSC
  ROM Size:        2048
  Bankswitch Type: AUTO-DETECT ==> 2K

2015-02-06 09:55:02.372 sharedLibraryInterfaceExample[5124:507] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error (1000) creating CGSWindow on line 263'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff8b32125c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8956de75 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8b32110c +[NSException raise:format:] + 204
    3   AppKit                              0x00007fff839f4e95 _NSCreateWindowWithOpaqueShape2 + 1403
    4   AppKit                              0x00007fff839f3a21 -[NSWindow _commonAwake] + 3720
    5   AppKit                              0x00007fff838cf400 -[NSWindow _commonInitFrame:styleMask:backing:defer:] + 882
    6   AppKit                              0x00007fff838ce882 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1054
    7   AppKit                              0x00007fff838ce458 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
    8   libSDL-1.2.0.dylib                  0x00000001093f1ced -[SDL_QuartzWindow initWithContentRect:styleMask:backing:defer:] + 285
    9   libSDL-1.2.0.dylib                  0x00000001093ef1c4 QZ_SetVideoMode + 1076
    10  libSDL-1.2.0.dylib                  0x00000001093e633f SDL_SetVideoMode + 527
    11  libale.so                           0x0000000109244894 _ZN13DisplayScreenC2EP12ExportScreenii + 148
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

Running the ALE-binary with -display_screen true works fine. Any ideas what might be going on here? Is displaying the screen through ALEInterface not yet supported?

Thanks Michael

mhauskn commented 9 years ago

I have been able to recreate the issue on OSX 10.9. This functionality works as expected on Unix but apparently not on mac. Thanks for pointing this out, I'll look into fixing it!

mhauskn commented 9 years ago

A short term fix which got this working for me:

Add to sharedLibraryInterfaceExample.cpp:

include "SDL/SDL.h"

And use the following make command: bash-3.2$ g++ -I../../src -L../.. sharedLibraryInterfaceExample.cpp -framework Cocoa -lale -lz -lSDL -lSDLmain -lSDL_gfx -lSDL_image -o sharedLibraryInterfaceExample

I'll look into some longer term better solutions, but let me know if this fixes things for you.

michael-p commented 9 years ago

The fix works, thank you very much! I also tested it on OSX 10.8 and it's the same situation there (not working initially but the fix does the job).

mhauskn commented 9 years ago

The dev branch of ALE addresses this issue with a new sharedLibraryInterfaceExample and Makefile.sharedlibrary.