-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
[bug ]The application freezes and does not respond tightly #881
Comments
Is this on windows? is so, is your icon if dimension 2^n ? |
I think I am facing similar issue of occasion freeze on start. It is very random, and even happens when having just a master window and an empty run loop. |
I found a fix for the application freezing issue. It's necessary to add runtime.LockOSThread() and runtime.UnlockOSThread() in the main function to ensure proper access to the GUI from a single thread. This should resolve the freezing during startup. Fixed code
|
ref: #764 |
Could you guys try this? diff --git a/mainthread_windows.go b/mainthread_windows.go
index e38db0d..4eade0a 100755
--- a/mainthread_windows.go
+++ b/mainthread_windows.go
@@ -3,10 +3,16 @@
package giu
+import "runtime"
+
+func init() {
+ runtime.LockOSThread()
+}
+
// TODO: I have no working mainthread library for windows.
// - this one for macOS crashes app immediately
// - this for linux (and everything else) freezes after a few seconds
-//
+//
// With no mianthread support this at least runs sometimes. Just keep your giu calls in one thread and everything should work.
func mainthreadCallPlatform(c func()) {
c() |
CC @kenn1dy @SleepyPrince |
@gucio321 Yeah, that diff has fixed the same issue for me as well (Windows 11, latest giu/cimgui-go master), thanks a lot! |
ok, so let me apply that diff to master and close this and #764 |
What happend?
When you start the application, it freezes, it may start after 3,5,6 times, or it may not start. I don't understand what the problem is. The issue tends to reproduce approximately once in every 30-50 launches. Please attempt multiple restarts to observe the problem, as it may not occur within the first few attempts.
Code example
main.go
To Reproduce
Version
(latest)
OS
Windows 11
The text was updated successfully, but these errors were encountered: