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

internal/graphicsdriver/directx: DirectX can be unexpectedly chosen even when the feature level 12 is not supported #2478

Closed
1 of 10 tasks
erexo opened this issue Dec 2, 2022 · 24 comments

Comments

@erexo
Copy link
Contributor

erexo commented Dec 2, 2022

Ebitengine Version

b3be334

Operating System

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

Go Version (go version)

1.19.1

What steps will reproduce the problem?

A few of my players reported, that while running my game on DirectX the game suddenly and without any observable reason closes. I can't really force them to look deeper on what could cause this, but every player is claiming that they are not doing anything special in particular, and the game will crash after ~5-20 minutes after launching.
There are two distinctive errors and I'm not sure how related they are:

First error reported by 2 players:

FATAL|2022/12/02 17:07:20 glfwwin: wglSwapIntervalEXT failed: The operation completed successfully.
panic({0x8d9140, 0xc0213aa900})
	C:/Program Files/Go/src/runtime/panic.go:884 +0x212
github.com/hajimehoshi/ebiten/v2/internal/glfw.SwapInterval(...)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/glfw/glfw_windows.go:368
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).updateVsync(0x6640780)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/ui/ui_glfw.go:1390 +0x99
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).update(0x6640780)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/ui/ui_glfw.go:1066 +0xda
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).loop.func2()
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/ui/ui_glfw.go:1120 +0x4a
github.com/hajimehoshi/ebiten/v2/internal/thread.(*OSThread).Loop.func1(0xc01e74bcb8?, 0xc01e74bca8?)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/thread/thread.go:54 +0x53
github.com/hajimehoshi/ebiten/v2/internal/thread.(*OSThread).Loop(0xc0000081f8)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/thread/thread.go:55 +0x2e
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).Run(0x6640780, {0x62f75a8?, 0xc0091f6f50})
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/ui/run_notsinglethread.go:52 +0x231
github.com/hajimehoshi/ebiten/v2.RunGame({0x62f4d70, 0xc000a08240})
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/run.go:233 +0x9d

EDIT(hajimehoshi): See #2481 for this issue.

Second error/s reported by one player:

FATAL|2022/11/30 22:05:05 directx: ID3D12Device::CreateCommittedResource failed: HANDLE(2289696773)
goroutine 1 [running, locked to thread]:
runtime/debug.Stack()
	C:/Program Files/Go/src/runtime/debug/stack.go:24 +0x65
github.com/erexo/logz.Critical({0xc00d927e78?, 0x61931b0?, 0xc0003da840?})
	C:/Users/Erexo/go/src/github.com/erexo/logz/logz.go:212 +0x65
main.main()
	C:/Users/Erexo/go/src/github.com/erexo/gobia/main.go:87 +0x6c8
	
FATAL|2022/12/02 17:48:51 runtime error: index out of range [0] with length 0
panic({0xf34100, 0xc000127da0})
	C:/Program Files/Go/src/runtime/panic.go:884 +0x212
github.com/hajimehoshi/ebiten/v2/internal/glfwwin._DragQueryFileW(...)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/glfwwin/api_windows.go:1066
github.com/hajimehoshi/ebiten/v2/internal/glfwwin.windowProc(0x30496, 0x233, 0x201056c0078, 0x0)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/glfwwin/win32window_windows.go:1175 +0x297b
syscall.SyscallN(0x0?, {0xc0093cf180?, 0x30496?, 0x20?})
	C:/Program Files/Go/src/runtime/syscall_windows.go:557 +0x109
syscall.Syscall6(0x10000ffff?, 0x100000001?, 0x100000008?, 0x100000001?, 0x1000000ae219a?, 0xa8df5f?, 0x0?, 0x0?)
	C:/Program Files/Go/src/runtime/syscall_windows.go:501 +0x50
golang.org/x/sys/windows.(*Proc).Call(0xa8e2a7?, {0xc009375a40?, 0xec9240?, 0xc000203401?})
	C:/Users/Erexo/go/pkg/mod/golang.org/x/sys@v0.2.0/windows/dll_windows.go:178 +0x233
golang.org/x/sys/windows.(*LazyProc).Call(0xc000203440, {0xc009375a40, 0x5, 0x5})
	C:/Users/Erexo/go/pkg/mod/golang.org/x/sys@v0.2.0/windows/dll_windows.go:348 +0x50
github.com/hajimehoshi/ebiten/v2/internal/gamepad._CallWindowProcW(...)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/gamepad/api_desktop_windows.go:163
github.com/hajimehoshi/ebiten/v2/internal/gamepad.(*nativeGamepadsDesktop).wndProc(0x0?, 0x30496, 0x233, 0x201056c0078, 0x0)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/gamepad/gamepad_desktop_windows.go:552 +0x97
syscall.SyscallN(0x7ffeee7de040?, {0xc0093cf9b0?, 0x3?, 0x0?})
	C:/Program Files/Go/src/runtime/syscall_windows.go:557 +0x109
syscall.Syscall(0x4?, 0xc00076a6c0?, 0x6c50340?, 0x0?, 0xc0093cfb98?)
	C:/Program Files/Go/src/runtime/syscall_windows.go:495 +0x3b
golang.org/x/sys/windows.(*Proc).Call(0xa8e2a7?, {0xc009d64288?, 0xec7320?, 0x1?})
	C:/Users/Erexo/go/pkg/mod/golang.org/x/sys@v0.2.0/windows/dll_windows.go:170 +0xae
golang.org/x/sys/windows.(*LazyProc).Call(0xc00022c060, {0xc009d64288, 0x1, 0x1})
	C:/Users/Erexo/go/pkg/mod/golang.org/x/sys@v0.2.0/windows/dll_windows.go:348 +0x50
github.com/hajimehoshi/ebiten/v2/internal/glfwwin._DispatchMessageW(...)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/glfwwin/api_windows.go:1049
github.com/hajimehoshi/ebiten/v2/internal/glfwwin.platformPollEvents()
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/glfwwin/win32window_windows.go:2052 +0x174
github.com/hajimehoshi/ebiten/v2/internal/glfwwin.PollEvents(...)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/glfwwin/window_windows.go:820
github.com/hajimehoshi/ebiten/v2/internal/glfw.PollEvents()
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/glfw/glfw_windows.go:347 +0x27
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).update(0x6c50780)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/ui/ui_glfw.go:1070 +0xeb
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).loop.func2()
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/ui/ui_glfw.go:1120 +0x4a
github.com/hajimehoshi/ebiten/v2/internal/thread.(*OSThread).Loop.func1(0xc0093cfcb8?, 0xc0093cfca8?)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/thread/thread.go:54 +0x53
github.com/hajimehoshi/ebiten/v2/internal/thread.(*OSThread).Loop(0xc000559170)
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/thread/thread.go:55 +0x2e
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).Run(0x6c50780, {0x69075a8?, 0xc00930d260})
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/internal/ui/run_notsinglethread.go:52 +0x231
github.com/hajimehoshi/ebiten/v2.RunGame({0x6904d70, 0xc0008187b0})
	C:/Users/Erexo/go/src/github.com/erexo/ebiten/run.go:233 +0x9d

EDIT(hajimehoshi): See #2480 for the latter issue.

Only a few players reported those errors, I couldn't get their system specs or directx status, and when they switched to OpenGL everything is working as intended.

What is the expected result?

Game does not crash

What happens instead?

ebiten.RunGame return errors

Anything else you feel useful to add?

As OpenGL is working fine for them and they can play normally, that's the another "I told you" about usefulness of having the ability to switch the engine.

@erexo erexo added the bug label Dec 2, 2022
@hajimehoshi
Copy link
Owner

Thank you for reporting!

Ebitengine Version
b3be334

What about the latest version?

FATAL|2022/12/02 17:07:20 glfwwin: wglSwapIntervalEXT failed: The operation completed successfully.

This seems pretty odd... Isn't this an OpenGL operation? I'll take a look

FATAL|2022/11/30 22:05:05 directx: ID3D12Device::CreateCommittedResource failed: HANDLE(2289696773)

This seems a device lost. Isn't the actual device unstable? TBH I have no idea how to fix this 🤔

@hajimehoshi hajimehoshi added this to the v2.4.14 milestone Dec 2, 2022
@erexo
Copy link
Contributor Author

erexo commented Dec 2, 2022

What about the latest version?

I'll try to upgrade to the latest version during my next client update, but I can't guarantee that those players will be still playing 😄
I do understand that those bugs are quite unique and without any reproducible path, but they were discovered by regular users on production so, I can't really say more

@hajimehoshi
Copy link
Owner

hajimehoshi commented Dec 2, 2022

Fixed the first issue at 15c2fe0.

As this bug seems pretty rare, I will not backport this to v2.4, maybe (and I believe you are using v2.5)

@hajimehoshi hajimehoshi modified the milestones: v2.4.14, v2.5.0 Dec 2, 2022
@erexo
Copy link
Contributor Author

erexo commented Dec 2, 2022

thank you! there is no need since I'll just use the HEAD.
Is there anything we can do with those two latter issues?

@hajimehoshi
Copy link
Owner

Hm, I'll take a look further tomorrow. I'm gonna sleep soon..

@hajimehoshi
Copy link
Owner

Is there anything we can do with those two latter issues?

Nothing so far, thanks!

@hajimehoshi
Copy link
Owner

hajimehoshi commented Dec 2, 2022

Fixed the third one. 6a0eb82

This seems serious so I'll backport this.

EDIT: I separated this issue to #2480

@hajimehoshi hajimehoshi modified the milestones: v2.5.0, v2.4.14 Dec 2, 2022
@erexo
Copy link
Contributor Author

erexo commented Dec 2, 2022

you are great, thank you so much! 😊

@erexo
Copy link
Contributor Author

erexo commented Dec 2, 2022

I can confirm that the third one happens whenever I move a file over the game window.
Since I don't use and I'm not planning to use the drag-drop feature, is there any chance to disable it completely? (To not have the dragging cursor)

@hajimehoshi
Copy link
Owner

Since I don't use and I'm not planning to use the drag-drop feature, is there any chance to disable it completely? (To not have the dragging cursor)

This is in #1868

@hajimehoshi
Copy link
Owner

So now the remaining issue is

FATAL|2022/11/30 22:05:05 directx: ID3D12Device::CreateCommittedResource failed: HANDLE(2289696773)
goroutine 1 [running, locked to thread]:
runtime/debug.Stack()
	C:/Program Files/Go/src/runtime/debug/stack.go:24 +0x65
github.com/erexo/logz.Critical({0xc00d927e78?, 0x61931b0?, 0xc0003da840?})
	C:/Users/Erexo/go/src/github.com/erexo/logz/logz.go:212 +0x65
main.main()
	C:/Users/Erexo/go/src/github.com/erexo/gobia/main.go:87 +0x6c8

but, as I have already said, I have no idea how to fix. Probably there is nothing we can do...

@hajimehoshi
Copy link
Owner

@erexo Does this happen when lancuing a game, or during a game?

@hajimehoshi hajimehoshi removed this from the v2.5.0 milestone Dec 3, 2022
@erexo
Copy link
Contributor Author

erexo commented Dec 3, 2022

Currently It's hard to say, because the "I was playing for a while and then suddenly the game stops" was probably describing the third panic, but when that player sent me his logs I also discovered this one. There is a good chance that it happened during game launch.

Since I don't use and I'm not planning to use the drag-drop feature, is there any chance to disable it completely? (To not have the dragging cursor)

This is in #1868

So is there an option to disable it?

@hajimehoshi
Copy link
Owner

hajimehoshi commented Dec 3, 2022

So is there an option to disable it?

Ebitengine doesn't have a feature of drag and drop so far. We might have a new one in the future, but you can ignore it if you don't use it. I have already fixed the crash anyway.

@erexo
Copy link
Contributor Author

erexo commented Dec 4, 2022

I can confirm that the 2nd error is still viable at 6a0eb82 .
ebiten.RunGame throws an error: directx: ID3D12Device::CreateCommittedResource failed: HANDLE(2289696773) after the game was launched, so the user is able to actually run the game, but after a short while the game just throw this error, consistently. Fortunately the player is able to quickly switch to OpenGL and omit this problem.
I was able to reach one of such players and he was kind enough to share his dxdiag with me:
image

@hajimehoshi
Copy link
Owner

In the machine, as DX12 is not supported directly, OpenGL should be used. Does this bug still occur with the newest commit?

@erexo
Copy link
Contributor Author

erexo commented Dec 4, 2022

I'm not sure how does it behave on the newest commit (760e6b9), but my HEAD (6a0eb82) was pretty far up and I don't see anything that could affect that situation.
Probably tomorrow I'll update the game, so I can upgrade to the latest commit and let you know

@hajimehoshi
Copy link
Owner

What did you specify EBITENGINE_GRAPHICS_LIBRARY by the way?

@erexo
Copy link
Contributor Author

erexo commented Dec 6, 2022

It was set to "auto", so DirectX was actually used and launched, but during game the game crashes. When it's set to "opengl", it works fine

@hajimehoshi
Copy link
Owner

The latest version should not choose DirectX as Ebitengine tries to choose the feature level 12(#2447), and this machine doesn't seem to support it. Please try the HEAD version.

@erexo
Copy link
Contributor Author

erexo commented Dec 6, 2022

That player tested the game on 760e6b9, and the problem persists.
directx: ID3D12Device::CreateCommittedResource failed: HANDLE(2289696773)
I did not set that new feature level env, and the engine env is set to "auto"

@hajimehoshi
Copy link
Owner

That's pretty odd. This GPU doesn't support the feature level 12, right?

@erexo
Copy link
Contributor Author

erexo commented Dec 6, 2022

dxdiag suggests so, yes

@hajimehoshi hajimehoshi changed the title Random ebitengine crash on DirectX internal/graphicsdriver/directx: DirectX can be unexpectedly chosen even when the feature level 12 is not supported Dec 7, 2022
hajimehoshi added a commit that referenced this issue Dec 8, 2022
This is still mysterious, but this can happen on some old machines.

Updates #2478
Closes #2489
@hajimehoshi
Copy link
Owner

Now Ebitengine supports feature level 11 for DirectX, this should no longer be an issue.

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