Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No window appears when running App.Simple application executable #38

Open
dimsuz opened this issue Jan 13, 2019 · 10 comments
Open

No window appears when running App.Simple application executable #38

dimsuz opened this issue Jan 13, 2019 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@dimsuz
Copy link

dimsuz commented Jan 13, 2019

I have created a standalone application based on GI.Gtk.Declarative.App.Simple. Its sources are copy paste of the Hello.hs example.

You can find the repository here.

I observe the following:

  1. Trying to build and run it produces no window at all
$ stack build && stack exec amfora-hs
# No window, have to interrupt
^C^C
$
  1. Trying to load it inside stack ghci and running main manually somehow does produce a window (greeting names cycle, all's working), but then there's another problem: when I click on x (close) button, the application hangs with x pressed down. In ghci I can see that main has returned, but window stays on screen

To be sure that all this is something related to gi-gtk-declarative, I tried to replace main contents with some simple hello-world window from haskell-gi samples and it does work both with stack exec and stack ghci: window is shown and closed.

I'm not sure why no window appears for the case 1., but as for window freeze I suspect that this might have to do with the fact that there's no listener to window #destroy event in App.Simple code, but I might be mistaken.


Stack version: 1.9.3
Resolver: lts-13.2 (ghc version 8.6.3)
gi-gtk-declarative: 0.4.1
gi-gtk-declarative-app-simple: 0.4.0

@aristaeus
Copy link

Make sure you comple with -threaded.

@owickstrom this is definitely something which could be better documented.

@owickstrom
Copy link
Owner

For the first case, as @aristaeus says, you need to add the -threaded GHC option.

For the second, I think you're right about the missing destroy listener. See the examples on how it's done there, with a special event for window being closed, eventually leading to Exit.

@dimsuz
Copy link
Author

dimsuz commented Jan 23, 2019

The hint to use -threaded helped to fix the first issue, thank you!

As for the second one in my project I actually use the example copy-pasted from this repo and it does have the special event for window closing which you mention, as you can see here, but the issue is still there.

When I said that there's no listener for #destroy I've meant not the client code, but library code, this is the event used in haskell-gi example, but not emitted by App.Simple internally (not sure if needed, just an observation).

Did you try to run Hello example from stack ghci, does it close normally for you? I didn't try to compile this repo on my machine, will try soon. If this only happens in my sample-project repository, but not in gtk-gi-declarative repo, must be some local issue...

@owickstrom
Copy link
Owner

owickstrom commented Jan 23, 2019 via email

@dimsuz
Copy link
Author

dimsuz commented Jan 23, 2019

Thanks, I'll report back if I find something interesting too. Have a good vacation! :)

@owickstrom
Copy link
Owner

OK, I can reproduce this in GHCi (and cabal v2-repl) locally on the Hello example. Haven't had time to dig into it yet, but I'll have a closer look this weekend hopefully.

@owickstrom owickstrom added the bug Something isn't working label Feb 2, 2019
@owickstrom owickstrom self-assigned this Feb 2, 2019
@niteria
Copy link

niteria commented Jul 12, 2019

I poked around a bit trying to fix the hang on exit in ghci and while I didn't fix it I discovered some things worth noting.

  1. I have a workaround that makes the X button work again. Namely just replace True to False here: https://github.com/owickstrom/gi-gtk-declarative/blob/master/examples/AddBoxes.hs#L30. As I understand this lets the destroy signal propagate to the window. That makes me wonder if the topmost widget doesn't need to be explicitly destroyed.

  2. The builder example from haskell-gi also hangs on exit in ghci: https://github.com/haskell-gi/haskell-gi/blob/master/examples/introductory/src/builder.hs Again, it seems that calling Gtk.mainQuit is not enough in ghci. Modifying the example to send a close signal to the window on button click made the example work for me.

  3. The root cause is probably different, I suspect that some finalizers are not getting called or get called in a wrong thread. I base that on the investigation from Application hangs when using onWidgetDraw haskell-gi/haskell-gi#96, but that's only a weak suspicion.

My GHC version: 8.6.5

@mrkgnao
Copy link

mrkgnao commented Nov 11, 2019

I ran into the exact same problem and the s/True/False/ workaround worked for me as well 👍

@owickstrom
Copy link
Owner

Switching the propagation, if I'm not mistaken (it's been a while since I hacked on this), has the unfortunate effect of the special Exit event not being emitted. Maybe this would not matter for most applications, but I think a graceful shutdown mechanism should depend on the Exit event.

@owickstrom
Copy link
Owner

I've also confirmed it hangs in GHCi for me. Can't say say for certain, but I think it has worked before (maybe an older GHCi or haskell-gi package version).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants