giu: [bug] Window grows until filling screen then app crashes

What happend?

Title?

Code example

main.go
package main

import (
	g "github.com/AllenDang/giu"
)

func loop() {
	g.Window("main").Layout(
		g.Labelf("hi"),
	)
}

func main() {
	wnd := g.NewMasterWindow("main", 400, 200, 0)
	wnd.Run(loop)
}

To Reproduce

  1. Run my code
  2. see the crash…

Version

(latest)

OS

Windows 10

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16

Commits related to this issue

Most upvoted comments

To me it seems that

imgui.CurrentStyle().ScaleAllSizes(xScale=1.5)

is called during each render frame, and it doesn’t set the scale to an absolute 1.5 (150%), but it scales the current scale up by 150%, so it recursively scales up to infinity. Maybe it only needs a single call during initialization?

Edit: this solved the issue, so perhaps this should be in the initialization section, not in the loop:

func (w *MasterWindow) setTheme() (fin func()) {
	// Scale DPI in windows
	if runtime.GOOS == "windows" && !w.initialized {
		w.initialized = true
		xScale, _ := Context.backend.ContentScale()
		imgui.CurrentStyle().ScaleAllSizes(xScale)
	}

With version github.com/AllenDang/giu@v0.7.0 the issue is not present.

Answers:

  • It does not matter, it’s the same behavior if the only content is InputTextMultiline as well.

Message and call stack:

PS C:\Temp\giu> go run "c:\Temp\giu\examples\helloworld\helloworld.go"
panic: Assertion failed!
File: D:/a/cimgui-go/cimgui-go/cimgui/imgui/imgui.cpp, Line 10226

Expression: g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting."


goroutine 1 [running]:
github.com/AllenDang/cimgui-go.init.func1({0xc0001c1500?, 0x0?}, {0xc00000ed20?, 0x7ff7bc6a3ac0?}, 0xc000138000?)
        C:/Users/Alex/go/pkg/mod/github.com/!allen!dang/cimgui-go@v0.0.0-20240424153022-294abe7370df/assert.go:28 +0x65
github.com/AllenDang/cimgui-go.goImguiAssertHandler(0xc00007fc50?, 0x7ff7bce316c0, 0xbc6296ef?)
        C:/Users/Alex/go/pkg/mod/github.com/!allen!dang/cimgui-go@v0.0.0-20240424153022-294abe7370df/assert.go:45 +0x67
github.com/AllenDang/cimgui-go._Cfunc_igGLFWRunLoop(0x25ece753cf0, 0x7ff7bc6a58e0, 0x7ff7bc6a5920, 0x7ff7bc6a5960, 0x7ff7bc6a59e0)
        _cgo_gotypes.go:24237 +0x4d
github.com/AllenDang/cimgui-go.(*GLFWBackend).Run.func1(0x7ff7bc55da01?)
        C:/Users/Alex/go/pkg/mod/github.com/!allen!dang/cimgui-go@v0.0.0-20240424153022-294abe7370df/glfw_backend.go:249 +0x9c    
github.com/AllenDang/cimgui-go.(*GLFWBackend).Run(0xc00006c050?, 0xc00006c050?)
        C:/Users/Alex/go/pkg/mod/github.com/!allen!dang/cimgui-go@v0.0.0-20240424153022-294abe7370df/glfw_backend.go:249 +0x32    
main.main.(*MasterWindow).Run.func1()
        C:/Temp/giu/MasterWindow.go:244 +0xcb
github.com/AllenDang/giu.mainthreadCallPlatform(...)
        C:/Temp/giu/mainthread_windows.go:12
github.com/AllenDang/giu.(*MasterWindow).Run(...)
        C:/Temp/giu/MasterWindow.go:236
main.main()
        c:/Temp/giu/examples/helloworld/helloworld.go:18 +0x67
exit status 2

Is it specific for SingleWindow or for Window too?

It’s present for both.

Hi, thats really strange… could you try to run example from github.com/AllenDang/cimgui-go and lmk if it also fails? Giu has some extra logic about window handling.

Hi, I got the same issue as the issue creator, on Win10 as well, and for me the example from github.com/AllenDang/cimgui-go is working fine.