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

[Linux] Gtk-CRITICAL **: 22:23:23.129: gtk_main_quit: assertion 'main_loops != NULL' failed #1654

Closed
ianmjones opened this issue Jul 25, 2022 · 3 comments · Fixed by #1656
Closed
Labels
Bug Something isn't working Ready For Testing A fix is available and needs testing

Comments

@ianmjones
Copy link
Contributor

Description

When running an app built with Wails v2.0.0-beta.42 (and some earlier versions), whether as a built binary or via wails dev, when the app is quit, the following is displayed on the console:

Gtk-CRITICAL **: 22:23:23.129: gtk_main_quit: assertion 'main_loops != NULL' failed

To Reproduce

  1. Update to wails v2.0.0-beta.42
  2. wails init -t svelte -n wailsv2b42
  3. cd wailsv2b42
  4. wails build
  5. build/bin/wailsv2b42
  6. Quit the app.

Expected behaviour

No critical error displayed on console when app quits.

Screenshots

No response

Attempted Fixes

No response

System Details

Wails CLI v2.0.0-beta.42

Scanning system - Please wait (this may take a long time)...Done.

System
------
OS:             NixOS
Version:        22.11
ID:             nixos
Go Version:     go1.18.4
Platform:       linux
Architecture:   amd64

Wails
------
Version:                v2.0.0-beta.42
Package Manager:        nixpkgs

Dependency      Package Name    Status          Version
----------      ------------    ------          -------
*docker         nixos.docker    Installed       20.10.17
gcc             nixos.gcc       Installed       11.3.0
libgtk-3        nixos.gtk3      Installed       3.24.34
libwebkit       nixos.webkitgtk Installed       2.36.4
npm             nixos.nodejs    Installed       16.15.0
*nsis           nixos.nsis      Available       3.06.1
pkg-config      nixos.pkg-configInstalled       0.29.2
*upx            nixos.upx       Installed       3.96

* - Optional Dependency

Diagnosis
---------
Your system is ready for Wails development!
Optional package(s) installation details:
  - nsis: nix-env -iA nixos.nsis



If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

Additional context

No response

@leaanthony leaanthony added the Bug Something isn't working label Jul 25, 2022
@leaanthony
Copy link
Member

Potentially using g_application_quit() instead of gtk_main() may fix this: https://stackoverflow.com/questions/36905118/code-cannot-exit-from-gtk-application-apparently-no-message-loops

Just need to test that the Go code continues to run after calling this.

@stffabi
Copy link
Collaborator

stffabi commented Jul 26, 2022

The problem is frontend.Quit is called two times. The first time it is called e.g. when clicking the close button on the window. This call successfully executes gtk_main_quit. Then a second call to frontend.Quit will be initiated by the app.Shutdown method which is called after frontend.Run returns.

func (a *App) Shutdown() {
if a.shutdownCallback != nil {
a.shutdownCallback(a.ctx)
}
a.frontend.Quit()
}
func (a *App) Run() error {
err := a.frontend.Run(a.ctx)
a.Shutdown()
return err
}

This second call will then issue the assertion because the main_loop has already been finished. This has been introduced with PR #1488

@leaanthony leaanthony added the Ready For Testing A fix is available and needs testing label Jul 26, 2022
@leaanthony
Copy link
Member

I think this one is covered by the PR and has been tested but not merged. Closing this to reduce noise 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Ready For Testing A fix is available and needs testing
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants