Open matthewpalmer opened 9 years ago
Hi
It hasn't been tested on anything other than Linux. I should be able to get hold of a Mac soon and debug this.
Oh right. No worries—I can run it on Linux easily enough instead.
On 17 Jan 2015, at 4:47 pm, Adam Walker notifications@github.com wrote:
Hi
It hasn't been tested on anything other than Linux. I should be able to get hold of a Mac soon and debug this.
— Reply to this email directly or view it on GitHub.
Let me know if it works.
is this still an issue? i'm interested as well
I assume so. I haven't fixed it and don't have access to a mac, unfortunately.
Might be related to the comment under the createWindow function here:
https://hackage.haskell.org/package/GLFW-b-1.4.7.3/docs/Graphics-UI-GLFW.html
Might be fixed by: b9780bb8fe2a661ae653b128ecb2e065e58ea434
how to use the codes on qt,please?
I also get crashes on OS X. Out of the box I get,
2018-07-19 13:56:42.939 waterfall[38263:21299099] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
2018-07-19 13:56:42.939 waterfall[38263:21299099] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1349.91/Misc.subproj/NSUndoManager.m:363
2018-07-19 13:56:42.941 waterfall[38263:21299099] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1349.91/Misc.subproj/NSUndoManager.m:363
2018-07-19 13:56:42.941 waterfall[38263:21299099] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fffd16972cb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffe64ae48d objc_exception_throw + 48
2 CoreFoundation 0x00007fffd169c042 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00007fffd30e4be0 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 Foundation 0x00007fffd306f093 +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 170
5 AppKit 0x00007fffcf0f94ed -[NSApplication run] + 1200
6 libglfw.3.2.dylib 0x000000010507b88e initializeAppKit + 1534
7 libglfw.3.2.dylib 0x000000010507ada0 _glfwPlatformCreateWindow + 48
8 libglfw.3.2.dylib 0x0000000105075945 glfwCreateWindow + 501
9 waterfall 0x0000000104ec820a GLFWzmbzm3zi2zi1zi0zm2RXpO5VvXer1OcGugK5djJ_GraphicsziUIziGLFW_setErrorCallback1_info + 930
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
I tried moving the createWindow
call outside the forkIO
, but since the call to pollEvents
is still in the forkIO
it crashes:
2018-07-19 14:02:44.715 waterfall[52709:21321823] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
Segmentation fault: 11
According to this page,
https://hackage.haskell.org/package/GLFW
GLFW doesn't work well with GHC threads, forkIO or threadDelay. So avoid them if you can.
Avoiding forkIO
seems like a pretty fundamental design change -- but also perhaps an unavoidable one?
Just for fun I removed the forkIO
call entirely and the window opened. But then the app crashed due to an MVar blocked indefinitely. So that seems to indicate forkIO is a problem.
I hacked all the forkIO
out of window
and now things work. Some of the stuff I removed was probably important. But with this window
function I can actually display waterfalls,
window :: IsPixelData a
=> Int -- ^ Window width
-> Int -- ^ Window height
-> IO (Consumer a IO ()) -- ^ The Consumer that draws on the window. Obtain this from one of the other modules in this package. Must be given in an IO monad so that it can be initialised with the OpenGL context created within this function.
-> ExceptT String IO (Consumer a IO ())
window width height renderPipe = do
closed <- lift $ newIORef False
res' <- lift $ createWindow width height "" Nothing Nothing
do
res <- {- runExceptT $ -} do
win <- maybe (throwE "error creating window") return res'
lift $ setWindowSizeCallback win $ Just $ \win x y ->
viewport $= (Position 0 0, Size (fromIntegral x) (fromIntegral y))
lift $ setWindowCloseCallback win $ Just $ \win -> writeIORef closed True
lift $ makeContextCurrent (Just win)
lift $ clearColor $= Color4 0 0 0 0
renderPipe <- lift renderPipe
let thePipe = forever $ do
lift pollEvents
dat <- await -- lift $ takeMVar mv
lift $ makeContextCurrent (Just win)
lift pollEvents
lift $ clear [ColorBuffer]
yield dat
lift $ swapBuffers win
return $ {- runEffect $ -} thePipe >-> renderPipe
pure res
I'm trying to run the demo application on Mac OS X 10.10.2, and I get a segmentation fault. The display window opens with just a black background, and then crashes.
Here's a gist of the trace that OS X throws up after it crashes.
I tried to tweak the window width and height, the number of samples, and the x resolution, but that didn't seem to do anything.
This is the output of running the demo in GHCi.
Thanks very much for your help.