2 Instances of Torque Game Crashes?
by John Vanderbeck · in Torque Game Engine · 03/18/2004 (5:38 pm) · 14 replies
If I try to run two instances of our game on the same machine (even if both are in seperate directories) the second instance always crashes before or right around the time the main Torque window should pop up.
Has anyone else experienced this? Does anyone have any ideas on it?
It would sure be easier if I could run two instances for testing.
Has anyone else experienced this? Does anyone have any ideas on it?
It would sure be easier if I could run two instances for testing.
#2
03/18/2004 (6:42 pm)
Release mode is what I was running and it was consistant. I'll try running a debug build and see if I see anything odd. I'm very very tired though after coding about 30 hours straight so I might not be able to do any coherant debugging tonight :)
#3
03/18/2004 (7:22 pm)
There used to be some code in the engine that would stop two instances of RELEASE builds from being run at the same time. Two instances of debug builds will usually run fine
#4
03/18/2004 (7:38 pm)
A quick and dirty test, debug ran both ok. At least until I tried to connect to the other one then it went to hell in a handbasket :p
#5
03/18/2004 (9:04 pm)
Hmmmm... That's weird... I can rn two instances of release or debug and connect fine. I can't remember making any changes to the engine that'd allow me to do it when other people can't...
#6
Hey John, this may be the cause of your issue located in game/main.cc:
And, if you're running on windows, we have the following in winWindow.cc:
So, if I understand what is happening above correctly, you may only have a single release version of the TGE running on Windows. As a debug version is allowed multiple instances, I don't see why you couldn't change the above to also allow multiple release instances.
[EDIT]
Note: This is from a two week old HEAD version. YMMV
[/EDIT]
- LightWave Dave
03/19/2004 (2:10 pm)
Greetings!Hey John, this may be the cause of your issue located in game/main.cc:
ConsoleFunction( createCanvas, bool, 2, 2, "(string windowTitle)"
"Create the game window/canvas, with the specified window title.")
{
AssertISV(!Canvas, "cCreateCanvas: canvas has already been instantiated");
#if !defined(TORQUE_OS_MAC) // macs can only run one instance in general.
#if !defined(TORQUE_DEBUG) && !defined(INTERNAL_RELEASE)
if(!Platform::excludeOtherInstances("TorqueTest"))
return false;
#endif
#endif
Platform::initWindow(Point2I(800, 600), argv[1]);
// create the canvas, and add it to the manager
Canvas = new GuiCanvas();
Canvas->registerObject("Canvas"); // automatically adds to GuiGroup
return true;
}And, if you're running on windows, we have the following in winWindow.cc:
bool Platform::excludeOtherInstances(const char *mutexName)
{
gMutexHandle = CreateMutex(NULL, true, mutexName);
if(!gMutexHandle)
return false;
if(GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(gMutexHandle);
gMutexHandle = NULL;
return false;
}
return true;
}So, if I understand what is happening above correctly, you may only have a single release version of the TGE running on Windows. As a debug version is allowed multiple instances, I don't see why you couldn't change the above to also allow multiple release instances.
[EDIT]
Note: This is from a two week old HEAD version. YMMV
[/EDIT]
- LightWave Dave
#7
03/20/2004 (6:44 am)
John: I have been experiencing the same. I'm using Release and it is always crashing when opening up the second instance. Multiple dedicated servers work great though.
#8
03/20/2004 (6:46 am)
Ok so if this is intentional, it isn't handled very cleanly. I'll have to fix that. I don't want some weirdo deciding to run two instances and just getting a vanilla crash. That will cause support problems :)
#9
03/20/2004 (10:22 am)
An error message to handle it would be more clean IMO :)
#10
03/20/2004 (3:34 pm)
Someone add an error message. :)
#11
In any case we chose a different route and removed the code preventing more than one instance. If someone wants to run mutliple instances, we can't think of any reason to stop them. Is there some reason we aren't seeing?
03/20/2004 (3:45 pm)
Well it goes deeper than that. The code properly exits if there is already an instance, yet the game still "crashes". So the big problem is that something doesn't get cleaned up properly.In any case we chose a different route and removed the code preventing more than one instance. If someone wants to run mutliple instances, we can't think of any reason to stop them. Is there some reason we aren't seeing?
#12
03/20/2004 (10:18 pm)
Not really, unless you have a copy in the background they forget about, then find they're running three copies of the game at once. ;)
#13
07/19/2006 (8:51 am)
Did anyone resolve a clean solution for this?
#14
Basically you want to open up common\client\canvas.cs and make sure that if the call to createCanvas fails you return immediately instead of trying to exec the gui files.
And then where initCanvas is being called you want to check if the Canvas object exists, after calling initCanvas. If it doesn't, you return immediately. In my project I actually have it call quit(), otherwise it will just sit there and do nothing.
07/19/2006 (10:40 pm)
I do have this fixed in a project of mine. I know for a fact that the fix is on SVN, but I'm not sure if that build is available to anyone yet.Basically you want to open up common\client\canvas.cs and make sure that if the call to createCanvas fails you return immediately instead of trying to exec the gui files.
And then where initCanvas is being called you want to check if the Canvas object exists, after calling initCanvas. If it doesn't, you return immediately. In my project I actually have it call quit(), otherwise it will just sit there and do nothing.
Associate Kyle Carter
I've occasionally had this problem, but just as often had it work.