fjvallarino/monomer

Windows: Console/stdout seems locked?

Closed this issue · 3 comments

Hello everyone, I have been using the monomer library between two platforms: Linux and Windows, I have noticed a performance difference in that on Linux the user can freely spawn Tasks (via an event) for printing some text/string to console but the same code will NOT work on Windows:

handleEvent :: Wenv -> Node -> Model -> Evt -> [EventResponse Model Evt Model ()]
handleEvent wenv node model evt = case evt of
  printStatement s -> [ Task $ do
    print s
    return ResolveEvent 
  ]
  ResolveEvent -> []

It's as though Monomer is locked out of using the console! I did notice that only on Windows is DpiAwareness set automatically (the function is undefined if _WIN32 is undefined as per the pragma in cbits/dpi.c) thus the only string printed for the entire application lifecycle is when monomer starts:

 INFO: called SetProcessDpiAwareness: 1

I have attempted to tackle the problem but it's really throwing me off, has anyone else encountered issues printing to stdout or PowerShell on Windows?

Hi @MilesLitteral!

I also faced this issue in the past and it's related to SDL2 build flags (here's a reference to that issue in a C++ related question).

Unfortunately I don't currently have a Windows machine so I can't test it, but based on one of the last few comments in this issue, if you modify your package.yaml to also include this, it "should" work. You may need to remove the .stack-work folder in the root of your project, and I guess also excluding the -optl-mwindows flag may be worth a try if it does not work:

executables:
  app:
    ...
    ghc-options:
    ...
    - -optl-mconsole
    - -optl-mwindows

Thanks that worked 100%!

Now it can even print the Renderer message which it wasn't doing on Windows

INFO: called SetProcessDpiAwareness: 1

Renderer: NVIDIA GeForce GTX 980/PCIe/SSE2
Version: 3.2.0 NVIDIA 512.15

@MilesLitteral I'll close the issue. Please re-open or create a new one if needed. Thanks!