i'm trying to fix an issue with mesen's netplay. After a while of playing online with someone the game will bring up an error and disconnect without crashing. Here is a link of the issue i opened on github.

I looked into the source files and i found a file called frmMain.cs. Here at the very top there is a class frmMain with multiple methods out of which one called StartEmuThread().
Here is a chain with the definition and the relevant references for this method:
StartEmuThread() definition
StartEmuThread() reference
Run() import from external dll
Run() export
Run() definition
It seems that the crash happens when trying to run InteropEmu.Run() which is called by StartEmuThread(). I tried removing line 692 from frmMain.cs but that just makes the emulator not start anymore, it just shows up the ui with a black screen.
I placed a breakpoint on StartEmuThread() and InteropEmu.Run() in visual studio to see if they get accessed only once when crashing or multiple times. Apparently StartEmuThread() gets accessed every time the emulator pauses/unpauses using Esc key and every time you load a save state. The if statement however inside StartEmuThread() doesn't get triggered.
I also looked at the method that references StartEmuThread() which is called _notifListener_OnNotification(). Inside here there is a switch with a case for GameInitCompleted and here is the StartEmuThread() method.
GameInitCompleted is defined as an enum in a file called INotificationListener.h and is referenced in multiple files but i think the most relevant is GameServerConnection.cpp and also in InteropEmu.cs.
Code: Select all
private void StartEmuThread()
{
if(_emuThread == null) {
_emuThread = new Thread(() => {
try {
InteropEmu.Run();
_emuThread = null;
} catch(Exception ex) {
MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
_emuThread = null;
}
});
_emuThread.Start();
}
UpdateMenus();
}
If anyone has any ideas i would love to hear them out.
Also does anyone know what the notation Mesen.GUI.Forms.frmMain.<StartEmuThread>b__215_0() mean?
I know that those are namespaces and frmMain.StartEmuThread() is a method of frmMain but why is it written like that? And what is the b__215_0 number? I searched for it in the source files but it's not written anywhere.
Thanks