Skip to content

FPS of unfocused window is ~56 not ~60 #3397

@elee1766

Description

@elee1766

Ebitengine Version

v2.9.8

Operating System

  • Windows
  • macOS
  • Linux (X11)
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

Go Version (go version)

1.25.7

What steps will reproduce the problem?

package main

import (
	"fmt"
	"log"
	"net/http"
	_ "net/http/pprof"

	"github.com/hajimehoshi/ebiten/v2"
	"github.com/hajimehoshi/ebiten/v2/ebitenutil"
)

type Game struct{}

func (self *Game) Layout(w, h int) (int, int) {
	return w, h
}

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

func (self *Game) Draw(screen *ebiten.Image) {
	ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %.2f", ebiten.ActualFPS()))
}

func main() {
	go func() {
		log.Println(http.ListenAndServe("localhost:6060", nil))
	}()

	game := &Game{}
	ebiten.SetScreenClearedEveryFrame(true)
	if err := ebiten.RunGame(game); err != nil {
		log.Fatal(err)
	}
}

What is the expected result?

the fps should be close to 60 ish when the window is unfocused

What happens instead?

the fps is around 56-57fps

Anything else you feel useful to add?

for some reason this:
https://github.com/elee1766/ebiten/tree/use-wait-events-timeout-unfocused

seems to make it better? but i'm not 100% sure why. maybe its a go scheduler thing? (this gets me to 59.5 fps)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions