Project

General

Profile

Actions

Emulator Issues #12652

open

ImGui assertion error message on shutdown

Added by AmyRose1288 over 3 years ago. Updated 9 months ago.

Status:
Questionable
Priority:
Normal
Assignee:
-
% Done:

0%

Operating system:
N/A
Issue type:
Bug
Milestone:
Current
Regression:
No
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:

Description


Microsoft Visual C++ Runtime Library

Assertion failed!

Program: C:\Emulator\Dolphin-x64\Dolphin.exe
File: C:\buildbot\release-win-x64\build\Externals...\imgui.cpp
Line: 3079

Expression: GImGui != 0 && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts

(Press Retry to debug the application - JIT must be enabled)

中止(A) 重试(R) 忽略(I)

Emulator Info:

Dolphin
5.0-14790
Branch: master
Revision: 3cc274880f47d340bd508dba91aaf37c48acd367

Using Qt 5.15.0


Files

imgui.png (11.4 KB) imgui.png AlexFilar, 11/05/2022 05:34 PM
dolphin.png (23.2 KB) dolphin.png AlexFilar, 11/06/2022 10:52 PM
dolphin.png (66.6 KB) dolphin.png AlexFilar, 11/06/2022 11:24 PM

Related issues 1 (1 open0 closed)

Related to Emulator - Emulator Issues #12045: Dolphin crashes when stopping emulation during movie recordingNew

Actions
Actions #1

Updated by JosJuice over 3 years ago

Actions #2

Updated by JosJuice about 3 years ago

  • Milestone set to Current

Related forum topic: https://forums.dolphin-emu.org/Thread-crash-when-i-close-games

This is probably a regression, so I'm marking this as Current for now.

Actions #3

Updated by AmyRose1288 almost 3 years ago

Update as 2022/03/14 still exists in 5.0-16101

Actions #4

Updated by JMC4789 about 2 years ago

  • Status changed from New to Questionable

Is this still happening for anyone? I still can't reproduce it.

Actions #5

Updated by AlexFilar about 2 years ago

JMC4789 wrote:

Is this still happening for anyone? I still can't reproduce it.

Yes, it does. At least to me. I'm on 5.0-17790.

Actions #6

Updated by JMC4789 about 2 years ago

I have no idea how to reproduce it. If you can provide more information about your system, maybe that'd help.

Actions #7

Updated by AlexFilar about 2 years ago

JMC4789 wrote:

I have no idea how to reproduce it. If you can provide more information about your system, maybe that'd help.

I doubt my system is somehow special. I have Visual Studio. I built Dolphin from source, it happens even with debugger.
It happens at: RenderWidget.cpp, line 65, RenderWidget::SetImGuiKeyMap() calls ImGui::GetIO() that contains this IM_ASSERT.
But ImGui is already destroyed at this point by: RenderBase.cpp, line 1135, Renderer::ShutdownImGui() calls ImGui::DestroyContext().

Actions #8

Updated by AdmiralCurtiss about 2 years ago

I'm not sure why state would be Running during shutdown (see RenderWidget line 64), however I see how there could potentially be a race condition here. It should probably verify that the imgui context exists after acquiring the lock in SetImGuiKeyMap().

Actions #9

Updated by pokechu22 about 2 years ago

There's definitely a race condition, as this has happened to me too. But I don't have a way to consistently reproduce it. See https://github.com/dolphin-emu/dolphin/pull/10458 which theoretically may fix it (but in practice I haven't confirmed if it does).

Actions #10

Updated by AdmiralCurtiss about 2 years ago

Renderer::InitializeImGui() and Renderer::ShutdownImGui() probably also need to hold the lock (they currently don't) so this works consistently, otherwise it could still potentially get destroyed while it's looping through the keys.

Actions #11

Updated by AlexFilar about 2 years ago

pokechu22 wrote:

There's definitely a race condition, as this has happened to me too. But I don't have a way to consistently reproduce it. See https://github.com/dolphin-emu/dolphin/pull/10458 which theoretically may fix it (but in practice I haven't confirmed if it does).

Well, I can confirm. I patched with fix above, and it works.
I wonder if I'm lucky, but this bug happens 100% of the time to me.
So I can reproduce this consistently.

Actions #12

Updated by pokechu22 about 2 years ago

One other thing is that I think the underlying issue is that imgui is destroyed while GetImGuiLock is not held - but I ran into difficulties changing the relevant code to acquire that lock (I don't remember exactly why, and I might be misremembering).

Actions #13

Updated by AlexFilar about 2 years ago

Why at least this one-line fix "if (!ImGui::GetCurrentContext()) return;" is not implemented yet? I understand that the underlying race condition is not solved, but at least emulator will no longer crash every time you close a game. Temporary solution is better than nothing.

Actions #14

Updated by AdmiralCurtiss about 2 years ago

Can you test if https://github.com/dolphin-emu/dolphin/pull/11258 works for you? I would assume it does but just in case.

Actions #15

Updated by AlexFilar about 2 years ago

It works. But it looks like locks are useless. It still hits this condition.

Actions #16

Updated by AdmiralCurtiss about 2 years ago

Can you trace this upwards a bit? Why is the state == Running condition true, where does that signal come from?

Actions #17

Updated by AlexFilar about 2 years ago

I am not sure what happens

Actions #18

Updated by AdmiralCurtiss about 2 years ago

Yeah uh no idea. Definitely spooky.

From what I can tell, this has to be something like: There's a call to Core::SetState(Running) that happens shortly before the call to Core::SetState(Stopping), and you're seeing the event from that first call while Core::GetState() already reports the value from the second call.

But here's the thing, where is that call? I've also put a breakpoint there and as far as I can tell the only call to SetState(Running) happens at the start of emulation. So unless that signal is somehow in transit until shutdown (how? is the Qt event thread blocked on your system for the entire emulation, and if yes why?) I don't see where this is even coming from.

Actions #19

Updated by AlexFilar about 2 years ago

Oh, maybe it's "Pause on Focus Loss" setting. It shows a "Do you want to stop?" dialog at exit, I press Yes, then it calls SetState(Running).
If I disable this setting, then there is only one call to SetState(Running) at the start as you say.

Actions #20

Updated by pokechu22 about 2 years ago

I'm pretty sure I've had this issue happen to me with both "pause on lost focus" and "confirm on stop" disabled, but I think that was also with the fifoplayer and not normal games (which means that the shutdown process might be a bit different). Either that or it was something with the Wii shutdown process (where you have to stop emulation twice, with the first one being a "soft" stop that tells the game to shut down, but some games (and in particular homebrew) ignore it).

Actions #21

Updated by AlexFilar about 2 years ago

You said you can't reproduce this crash. What about with "Pause on Focus Loss" setting? Does this setting cause crash only for me? I close with Esc, then press Yes in the "Do you want to stop?" dialog box. Then Dolphin crashes with failed ImGui Assert, because it seems that this dialog box causes focus loss, which tries to pause and resume, and this causes SetState(Running), but ImGui was already destroyed on pressing Yes.

Maybe it's not the missing locks, maybe it's resuming after focus loss after shutdown?

Actions #22

Updated by Billiard26 9 months ago

  • Subject changed from After Playing GameCube Titles,this thing pop-up and any option kills the emulator to ImGui assertion error message on shutdown

Do you still experience this problem?

Actions

Also available in: Atom PDF