Skip to content

an empty Ebitengine application uses 6-8% CPU #3318

@hajimehoshi

Description

@hajimehoshi

Ebitengine Version

4bb016f

Operating System

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

Go Version (go version)

go version go1.24.3 darwin/arm64

What steps will reproduce the problem?

  1. Run this program:
package main

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

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

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(*ebiten.Image) {}

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

	game := &Game{}
	ebiten.SetScreenClearedEveryFrame(false)
	if err := ebiten.RunGame(game); err != nil {
		log.Fatal(err)
	}
}
  1. See the CPU usage at Activity Monitor
  2. Run

What is the expected result?

CPU usages should be much low like 1%

What happens instead?

CPU usages were around 6-8%

Anything else you feel useful to add?

go tool pprof -http=:8081 "http://localhost:6060/debug/pprof/profile?seconds=5" shows that pthread_cond is called many times

Image

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions