lispgames / cl-sdl2

Common Lisp bindings for SDL2 using C2FFI.
MIT License
309 stars 82 forks source link

sdl2-examples:basic-test kills slime-repl on macOS #89

Closed ajpaon closed 6 years ago

ajpaon commented 7 years ago

I'm running CCL:

> (sdl2-examples:basic-test)

The example runs and displays properly. I'm able to close the window with ESC. But then the slime repl stops responding. Inferior lisp is still running, though, and I'm able to rerun the example from there.

I also tried something I saw in a different issue:

> (sdl:make-this-thread-main #'sdl2-examples:basic-test)

But now I'm no longer able to close the window. Inferior lisp has the following warning:

WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.

Davidbhodge commented 7 years ago

If its any comfort, its not just you. Running CCL in terminal, not in slime, has a similar result, I see the warning message , a single mouse movement message and then it freezes and I am unable to close the window. Killing the lisp process is the only way out. I think its a slime problem - the sdl issue #23 suggests

(bt:make-thread (lambda () (swank:create-server :port 4005 :dont-close t))) (sdl2:make-this-thread-main (lambda () (sdl2.kit:start)))

in a terminal and then slime-connect to that. I will try that and see if it works

zacharycarter commented 7 years ago

I have the same issue that @ajpaon is reporting

clarkenciel commented 7 years ago

same issue. here's the trace fwiw:

Using SDL Library Version: 2.0.4
Setting up window/gl.
Opening game controllers.
Beginning main loop.
2017-11-09 09:20:07.816 sbcl[75566:1267072] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'nextEventMatchingMask should only be called from the Main Thread!'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fffa2d6e2cb __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fffb7b8648d objc_exception_throw + 48
    2   AppKit                              0x00007fffa0f59e82 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 4480
    3   libSDL2.dylib                       0x000000000079240c Cocoa_PumpEvents + 211
    4   libSDL2.dylib                       0x000000000072fca5 SDL_PumpEvents_REAL + 23
    5   libSDL2.dylib                       0x000000000072fd20 SDL_WaitEventTimeout_REAL + 76
    6   ???                                 0x0000000022ba2d4b 0x0 + 582626635
    7   ???                                 0x0000000022bebb79 0x0 + 582925177
    8   ???                                 0x0000000022beb5fc 0x0 + 582923772
    9   ???                                 0x0000000022bc39d2 0x0 + 582760914
    10  ???                                 0x0000000022bc424a 0x0 + 582763082
    11  ???                                 0x00000000227ab231 0x0 + 578466353
)
libc++abi.dylib: terminating with uncaught exception of type NSException
fatal error encountered in SBCL pid 75566(tid 0xb0006000):
SIGABRT received.

macOS Sierra 10.12.6

mfiano commented 6 years ago

Is this still an issue?

alex-eg commented 4 years ago

Yes, I have the same issues on Sly on Mac OS 10.15.1

Issuing

(sdl2:make-this-thread-main #'sdl2-examples:basic-test)

results in

SDL Error: NSWindow drag regions should only be invalidated on the Main Thread!

It doesn't happen if I run the loop from the terminal.

Edit: I'm on sbcl.

andi23rosca commented 4 years ago

@alex-eg and any others who have problems, it's cause slime is creating many threads. You can fix the issue by forcing swank to run in a single thread.

What I've done is create the file ~/.swank.lisp and put in it

(setf swank:*communication-style* nil)