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

a game with ebiten.SetRunnableOnUnfocused(false) doesn't show a window on macOS desktops #2620

Closed
1 of 10 tasks
hajimehoshi opened this issue Mar 31, 2023 · 0 comments
Closed
1 of 10 tasks

Comments

@hajimehoshi
Copy link
Owner

hajimehoshi commented Mar 31, 2023

Ebitengine Version

v2.6.0-alpha.1 / v2.5.0

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • Xbox
  • Web Browsers

Go Version (go version)

go version go1.20 darwin/amd64

What steps will reproduce the problem?

Run this program:

package main

import (
	"github.com/hajimehoshi/ebiten/v2"
)

type Game struct {}

func (g *Game) Update() error {
	return nil
}

func (g *Game) Draw(screen *ebiten.Image) {
}

func (g *Game) Layout(width, height int) (int, int) {
	return 320, 240
}

func main() {
	ebiten.SetRunnableOnUnfocused(false)
	if err := ebiten.RunGame(&Game{}); err != nil {
		panic(err)
	}
}

What is the expected result?

A window shows.

What happens instead?

A window is not shown.

Anything else you feel useful to add?

git-bisect says:

1656c47abf014498bfdb67f04a8041441274eadb is the first bad commit
commit 1656c47abf014498bfdb67f04a8041441274eadb
Author: Hajime Hoshi <hajimehoshi@gmail.com>
Date:   Tue Mar 14 00:18:28 2023 +0900

    internal/ui: bug fix: hiding a window decoration at initialization doesn't work on macOS
    
    Closes #2600

 internal/ui/ui_glfw.go | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)
@hajimehoshi hajimehoshi added this to the v2.5.1 milestone Mar 31, 2023
@hajimehoshi hajimehoshi changed the title the game doesn't launch on macOS desktops a game doesn't launch on macOS desktops Mar 31, 2023
@hajimehoshi hajimehoshi changed the title a game doesn't launch on macOS desktops a game with ebiten.SetRunnableOnUnfocused(false) doesn't launch on macOS desktops Mar 31, 2023
@hajimehoshi hajimehoshi changed the title a game with ebiten.SetRunnableOnUnfocused(false) doesn't launch on macOS desktops a game with ebiten.SetRunnableOnUnfocused(false) doesn't show a window on macOS desktops Mar 31, 2023
hajimehoshi added a commit that referenced this issue Mar 31, 2023
…rs are swapped once

On macOS, a window is hidden until buffers are swapped once. If a game is
not runnable on unfocused, as the window is hidden and unfocused, the
waiting loop for a window never ends.

This change fixes the issue by changing the loop condition.

Closes #2620
hajimehoshi added a commit that referenced this issue Mar 31, 2023
Depending on the member variable bufferOnceSwapped is a little fragile.
Detect whether the window is shown or not instead.

Updates #2620
hajimehoshi added a commit that referenced this issue Mar 31, 2023
Depending on the member variable bufferOnceSwapped is a little fragile.
Detect whether the window is shown or not instead.

Updates #2620
hajimehoshi added a commit that referenced this issue Mar 31, 2023
hajimehoshi added a commit that referenced this issue Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant