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

SetFullScreen(false) give error #2588

Closed
Hashcode-Ankit opened this issue Oct 25, 2021 · 6 comments
Closed

SetFullScreen(false) give error #2588

Hashcode-Ankit opened this issue Oct 25, 2021 · 6 comments
Labels
unverified A bug that has been reported but not verified

Comments

@Hashcode-Ankit
Copy link

Hashcode-Ankit commented Oct 25, 2021

When I am exiting from full screen I got the exit status 2 The error is given below in Bold
**panic: InvalidValue: Invalid window size 0x0

goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.3/glfw.acceptError({0x0, 0x0, 0x3c})
C:/Users/Ankit Sharma/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20210410170116-ea3d685f79fb/error.go:174 +0x186
github.com/go-gl/glfw/v3.3/glfw.panicError(...)
C:/Users/Ankit Sharma/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20210410170116-ea3d685f79fb/error.go:185
github.com/go-gl/glfw/v3.3/glfw.(*Window).SetMonitor(0xc0000b2000, 0xc000032088, 0xc000032148, 0x1, 0x0, 0x7ff752bbd54b, 0x0)
C:/Users/Ankit Sharma/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20210410170116-ea3d685f79fb/window.go:692 +0x35
fyne.io/fyne/v2/internal/driver/glfw.(*window).SetFullScreen.func1()
C:/Users/Ankit Sharma/go/pkg/mod/fyne.io/fyne/v2@v2.1.1/internal/driver/glfw/window.go:136 +0x9b
fyne.io/fyne/v2/internal/driver/glfw.(gLDriver).runGL(0xc00007e910)
C:/Users/Ankit Sharma/go/pkg/mod/fyne.io/fyne/v2@v2.1.1/internal/driver/glfw/loop.go:104 +0x197
C:/Users/Ankit Sharma/go/pkg/mod/fyne.io/fyne/v2@v2.1.1/internal/driver/glfw/driver.go:83 +0x30
fyne.io/fyne/v2/internal/driver/glfw.(window).ShowAndRun(0xc0000b2000)
C:/Users/Ankit Sharma/go/pkg/mod/fyne.io/fyne/v2@v2.1.1/internal/driver/glfw/window.go:462 +0x2f
main.main()
C:/Users/Ankit Sharma/Desktop/golang crazy/project/os.go:33 +0x157
exit status 2

To Reproduce:

Steps to reproduce the behaviour:

  1. create a button for SetFullScreen false
  2. Click on it after building
  3. See error in cmd and GUI window will be exited

Example code:

package main

import (
	// "fmt"
	// "fyne.io/fyne/v2"
	"fmt"

	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/widget"
)

func main(){
	a:=app.New()
	w:=a.NewWindow("ALinux")
	fullScreen:=true;
	fullScreenBtn:=widget.NewButton("Full Screen",func(){
		w.SetFullScreen(fullScreen)
		fullScreen=!fullScreen
	})
	
	w.SetContent(fullScreenBtn)
	w.ShowAndRun()
}

Device (please complete the following information):

Windows 10
go version go1.17.1 windows/amd64
fyne cli version: v2.1.1

@Hashcode-Ankit Hashcode-Ankit added the unverified A bug that has been reported but not verified label Oct 25, 2021
@Hashcode-Ankit Hashcode-Ankit changed the title SetFullScree(false) give error SetFullScreen(false) give error Oct 25, 2021
@Hashcode-Ankit
Copy link
Author

The error is because of not resizing the window first or the window size only have one content (size is approx 0*0)initially and when we exit there is no such window exist so this case should be handled if fyne give me authority to change i can fix this

@andydotxyz
Copy link
Member

Thanks for the info. The basic size should not be 0x0 - the button has a minimum size that is much larger because it needs to include "Full Screen" text and border. If you can find out why that tiny size is happening and/or resolve it that would be amazing thanks.

@MatejMagat305
Copy link
Contributor

MatejMagat305 commented Oct 27, 2021

I do not know wheter I can....., (I m in linux amd64)
but it happening due to function "CreateWindow" in fyne/v2/internal/driver/glfw/windows(if not change in 1396 line) where at inicialization window get width and height equals zeros(because are uninicialized) and then function "SetFullScreen" call anonim function which call

   	if full {
   		w.viewport.SetMonitor(monitor, 0, 0, mode.Width, mode.Height, mode.RefreshRate)
   	} else {
   		w.viewport.SetMonitor(nil, w.xpos, w.ypos, w.width, w.height, 0)
}

in fyne/v2/internal/driver/glfw/windows(if not change in 136 line)
where w.width, w.height are zeros and this cause crash..........,
the solution should be add to inicialization windows

w.width, w.height = 1,1// (in fyne/v2/internal/driver/glfw/windows)

or add to "SetFullScreen"

if w.width == 0 & w.height == 0{
....
}

@andydotxyz
Copy link
Member

Hmm, interesting idea. But I think w.width and w.height are set during the window construction based on the content, so it should not cause this.
Can you confirm if these ideas help @AnkitKumar2698

@MatejMagat305
Copy link
Contributor

so I was debuging and I do not know where is bug (my modification work, but I was looked at content)....., I send screenshot after second pressing above code....
2021-10-29_17-03

andydotxyz added a commit that referenced this issue Nov 30, 2021
Caused if the window has never had a resize event before.
Fixes #2588
andydotxyz added a commit that referenced this issue Nov 30, 2021
Caused if the window has never had a resize event before.
Fixes #2588
@andydotxyz
Copy link
Member

Fixed on release/v2.1.x for v2.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

3 participants