reflex-platform icon indicating copy to clipboard operation
reflex-platform copied to clipboard

macOS Mojave WKWebview error with ghci/runghc

Open DoctorRyner opened this issue 6 years ago • 10 comments

Should it work on 10.14 (Mojave)? 2019-01-18 18 10 03

DoctorRyner avatar Jan 18 '19 14:01 DoctorRyner

@hamishmack Have you seen this one?

ryantrinkle avatar Jan 18 '19 22:01 ryantrinkle

Ran into the same problem running the example hello world in Mojave.

[nix-shell:~/repos/reflex-platform]$ runghc hello.hs
2019-01-19 18:19:38.059 ghc[9529:1749709] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
	0   AppKit                              0x00007fff3c9712e3 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 386
	1   AppKit                              0x00007fff3c96e68c -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1488
	2   AppKit                              0x00007fff3c96e0b6 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
	3   libHSjsaddle-wkwebview-0.9.4.0-Ee7aUZFptb2Lvwf44IHsxL-ghc8.4.3.dylib 0x000000011993d471 -[AppDelegate initApp:progName:] + 193
	4   libHSjsaddle-wkwebview-0.9.4.0-Ee7aUZFptb2Lvwf44IHsxL-ghc8.4.3.dylib 0x000000011993d778 runInWKWebView + 120
	5   libHSjsaddle-wkwebview-0.9.4.0-Ee7aUZFptb2Lvwf44IHsxL-ghc8.4.3.dylib 0x0000000119936105 smeo_info + 661```

alexfmpe avatar Jan 19 '19 18:01 alexfmpe

Yeah, that's pretty annoying since ghcjs takes more than 10 seconds to even build for testing a laughably small project

DoctorRyner avatar Jan 20 '19 11:01 DoctorRyner

This seems to work okay if you don't use runghc:

$ ghc -dynamic -threaded examples/helloDom.hs
$ ./examples/helloDom

I can't figure out why runghc breaks here. I think it is having issues finding libraries...

matthewbauer avatar Jan 24 '19 03:01 matthewbauer

Thanks, it works now with these flags, I added them to my .cabal file and build it with ghc & cabal new-build at least twice faster

DoctorRyner avatar Jan 24 '19 05:01 DoctorRyner

An update on some research on this. It looks like this is a somewhat common problem. Mojave prevents applications from drawing to the UI in a sub thread. All of the UI operations will have to go in the main thread.

https://developer.apple.com/documentation/code_diagnostics/main_thread_checker

When you use runghc, it calls ghci which controls its own thread and manages the Haskell runtime. ghci will then load and execute your Haskell code. Unfortunately, ghci will need to use another thread for execution. In Mojave, the OS will block these UI operations. If we want ghci to support UI in Mojave, we probably will need to have some way to proxy these between threads. That could go into the GHC issue tracker.

matthewbauer avatar Jan 24 '19 19:01 matthewbauer

Is there nothing I can do with this, some hack or anything? Repl would be really neat. if there is no way then does it work on High Sierra?

DoctorRyner avatar Feb 04 '19 06:02 DoctorRyner

ghci only supports one OS thread BTW.

3noch avatar Feb 04 '19 21:02 3noch

It works with -fno-ghci-sandbox, but ghci exits along with the app

DoctorRyner avatar Feb 07 '19 16:02 DoctorRyner

Ah, this is an interesting point @DoctorRyner! I wonder if there's anything we can do to make this work under that constraint.

ryantrinkle avatar Feb 20 '19 20:02 ryantrinkle