OneLoneCoder / Javidx9

The official distribution of Javidx9's YouTube videos and projects
http://www.youtube.com/javidx9
Other
2.09k stars 1.29k forks source link

olcConsoleGameEngineSDL leads to crash on MacOS #37

Open Stannislav opened 4 years ago

Stannislav commented 4 years ago

Following the first video in the 3D Graphics series (https://www.youtube.com/watch?v=ih20l3pJoeU) and being on Mac I'm using olcConsoleGameEngineSDL.h rather than olcConsoleGameEngine.h. The minimal code for the instantiation of the game engine

int main() {
    olcEngine3D demo;
    if(demo.ConstructConsole(256, 240, 4, 4))
        demo.Start();

    return 0;
}

leads to the following crash:

$ ./olcEngine3D
2019-09-07 23:07:38.647 olcEngine3D[36851:411276] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'nextEventMatchingMask should only be called from the Main Thread!'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff4e8d72fd __exceptionPreprocess + 256
    1   libobjc.A.dylib                     0x00007fff78fa7a17 objc_exception_throw + 48
    2   AppKit                              0x00007fff4be16f8e -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 4180
    3   libSDL2-2.0.0.dylib                 0x000000010a4b8074 Cocoa_PumpEvents + 126
    4   libSDL2-2.0.0.dylib                 0x000000010a432e56 SDL_PumpEvents_REAL + 23
    5   libSDL2-2.0.0.dylib                 0x000000010a432edf SDL_WaitEventTimeout_REAL + 75
    6   olcEngine3D                         0x000000010a3efb55 _ZN20olcConsoleGameEngine10GameThreadEv + 709
    7   olcEngine3D                         0x000000010a3f25f1 _ZNSt3__1L8__invokeIM20olcConsoleGameEngineFvvEPS1_JEvEEDTcldsdeclsr3std3__1E7forwardIT0_Efp0_Efp_spclsr3std3__1E7forwardIT1_Efp1_EEEOT_OS5_DpOS6_ + 113
    8   olcEngine3D                         0x000000010a3f24fe _ZNSt3__1L16__thread_executeINS_10unique_ptrINS_15__thread_structENS_14default_deleteIS2_EEEEM20olcConsoleGameEngineFvvEJPS6_EJLm2EEEEvRNS_5tupleIJT_T0_DpT1_EEENS_15__tuple_indicesIJXspT2_EEEE + 62
    9   olcEngine3D                         0x000000010a3f1cf6 _ZNSt3__114__thread_proxyINS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEM20olcConsoleGameEngineFvvEPS7_EEEEEPvSC_ + 118
    10  libsystem_pthread.dylib             0x00007fff7a9692eb _pthread_body + 126
    11  libsystem_pthread.dylib             0x00007fff7a96c249 _pthread_start + 66
    12  libsystem_pthread.dylib             0x00007fff7a96840d thread_start + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Debugging shows that an exception is raised in olcConsoleGameEngineSDL.h in the line containing while (SDL_PollEvent(&e)). Similar issues elsewhere (https://github.com/littlevgl/pc_simulator_sdl_eclipse/issues/12) suggest that SDL might need special treatment under MacOS.

vikyathshirva commented 4 years ago

i've got the same error as well 2020-08-08 16:21:04.832475+0530 GameEngine[93886:3588776] Metal API Validation Enabled 2020-08-08 16:21:04.918261+0530 GameEngine[93886:3589412] flock failed to lock maps file: errno = 35 2020-08-08 16:21:04.919917+0530 GameEngine[93886:3589412] flock failed to lock maps file: errno = 35 2020-08-08 16:21:04.998693+0530 GameEngine[93886:3588776] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x1006b9b10> F8BB1C28-BAE8-11D6-9C31-00039315CD46 Please download the necessary bmp file too! libc++abi.dylib: terminating with uncaught exception of type int (lldb)