turion / rhine

Haskell Functional Reactive Programming framework with type-level clocks
http://hackage.haskell.org/package/rhine
117 stars 21 forks source link

MacOS error reappearing again #280

Open reubenharry opened 5 months ago

reubenharry commented 5 months ago

Running on a Mac (recently updated), when I run the rhine-bayes executable via cabal run rhine-bayes-gloss I get

2024-01-27 18:24:27.834 rhine-bayes-gloss[13639:2049511] GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: NSWindow drag regions should only be invalidated on the Main Thread!

(after selecting any of the 3 options in the list).

Curiously, I wasn't having this problem earlier today, and am on the master branch, and did cabal clean. Any ideas? (I'm on ghc 9.4.8)

(I've previously been able to resolve this issue, e.g. in my rhine-bayes-examples repo, but I can't presently remember how).

reubenharry commented 5 months ago

OK, closing this issue, as I remembered the fix, which is: use flowGlossIO and removed -threaded in the compilation options.

turion commented 5 months ago

Ah, great you remembered! Shouldn't we change the code then?

turion commented 5 months ago

Using flowGlossIO shouldn't have an effect, it's defined as launchInGlossThread settings . flow. But I guess -threaded makes a huge effect. Maybe it's possible to conditionally disable -threaded on mac?

reubenharry commented 5 months ago

Hmm interested. Just removing -threaded was not sufficient (although certainly necessary), so then it's unclear what I did to make it work...

turion commented 5 months ago

This is tricky: When you change the GHC options in the cabal files, it doesn't necessarily recompile (although it morally should). Can you maybe add a line of comment, recompile, and check whether changing -threaded maybe in fact is the relevant change?

reubenharry commented 5 months ago

I did cabal clean first. Would that cause recompilation?

turion commented 5 months ago

I would have thought it should. This is confusing. Can you try the following:

  1. Go to master
  2. cabal clean or git clean
  3. cabal run rhine-bayes-gloss (this should throw the error)
  4. Remove the flag
  5. cabal run rhine-bayes-gloss (this should still throw the error, right?)
  6. Use flowGlossIO directly (now the error is gone?)
  7. Remove flowGlossIO again (now the error returns?)

If the last steps are as predicted, then using flowGlossIO is indeed necessary.

reubenharry commented 5 months ago

I stand corrected! After 4, the bug is resolved. Sorry for the confusion.

reubenharry commented 5 months ago

So yeah, maybe we can disable -threaded conditionally on mac.

turion commented 5 months ago

Fantastic, thanks!