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

Debug breakpoint make High GPU #3160

Closed
1 of 11 tasks
diiyw opened this issue Nov 10, 2024 · 5 comments
Closed
1 of 11 tasks

Debug breakpoint make High GPU #3160

diiyw opened this issue Nov 10, 2024 · 5 comments

Comments

@diiyw
Copy link

diiyw commented Nov 10, 2024

Ebitengine Version

2.8.1

Operating System

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

Go Version (go version)

go version go1.22.5 windows/amd64

What steps will reproduce the problem?

My GPU: RTX 3060
Test code:

package main

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

type game struct {
}

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

func (g *game) Draw(screen *ebiten.Image) {
	for i := 0; i < 1000; i++ {  // breakpoint here
		screen.Fill(color.White)
	}
}

func (g *game) Layout(outsideWidth, outsideHeight int) (int, int) {
	return outsideWidth, outsideHeight
}

func main() {
	ebiten.SetTPS(60)
	ebiten.SetVsyncEnabled(true)
	ebiten.SetWindowSize(800, 600)
	ebiten.MaximizeWindow()
	ebiten.RunGame(&game{})
}

Add beakpoint here.
1731249805210
When the program first breaks, remove this breakpoint, let Ebiten continue running, and you will observe the high GPU usage.

What is the expected result?

GPU less 1%

What happens instead?

Very very high GPU usage
1731249291230

Anything else you feel useful to add?

No response

@hajimehoshi
Copy link
Owner

This doesn't sound like a real world issue, so I perhaps don't fix this.

@hajimehoshi
Copy link
Owner

When the program first breaks, remove this breakpoint, let Ebiten continue running, and you will observe the high GPU usage.

Oh, does this happen when you added a breakpoint?

@diiyw
Copy link
Author

diiyw commented Nov 10, 2024

Yes, I added this breakpoint before launching, and when I start the game in Debug mode, the breakpoint is effective. At this point, if I remove the breakpoint, Ebiten runs normally, but it uses a very high amount of GPU.

@hajimehoshi
Copy link
Owner

hajimehoshi commented Nov 10, 2024

What about using OpenGL?

op := &ebiten.RunGameOptions{
    GraphicsLibrary: ebiten.GraphicsLibraryOpenGL,
}
ebiten.RunGame(&game{}, op)

@diiyw
Copy link
Author

diiyw commented Nov 14, 2024

What about using OpenGL?

op := &ebiten.RunGameOptions{
    GraphicsLibrary: ebiten.GraphicsLibraryOpenGL,
}
ebiten.RunGame(&game{}, op)

Using OpenGL seems to be running normally, with an 8% GPU usage. I noticed that with the default settings, when I hit a breakpoint and then resume for the first time, the window displays but is not active. When I pause the program a second time and disable the breakpoint, it no longer runs in the foreground and consumes a high amount of GPU resources. Once I bring it back to the foreground, the GPU usage gradually returns to a normal 0.5% after a short wait.

@diiyw diiyw closed this as completed Nov 17, 2024
@hajimehoshi hajimehoshi closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2024
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

2 participants