Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Application crash on workstation lock

Author
Message
JDforce
19
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 20th Jan 2007 00:36
Making a test with another engine, I have just discovered that my DarkBasic / DBpro /gdk / FPSC apps crash in these cases:

- Workstation locked by the user.
- Press ctrl-alt-delete to show the logon dialog and then do anything. This is when welcome screen is disabled.
- Screen saver needs a password. Smartly enough, dbpro seem to prevent screensaver activity, but if I test a screen saver while running a windowed dbpro app, bizzare thing happen.
- Sometimes when minimize window, then restore, or when in full screen mode another app show a message, like messenger or outlook.

The fact is that I need some applications to be able to survive the logon window, because some users leave their machine to lunch, for instance, and if the logon screen pops up at that time, my game will be crashed when the user returns. This does not happen to Solitaire or MineSweeper,as well as many games using directX.

What can I do to correct it?

May the 3d force B with U
Jack LOL
17
Years of Service
User Offline
Joined: 4th Aug 2006
Location: Near the CPU Close to the graphic card
Posted: 20th Jan 2007 00:48
Weird problems..
I dont know why do u need ppl to keep playing after they log off..

(forgive my english) lol?! xD
JDforce
19
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 20th Jan 2007 01:01
Not logged off, of course. That would close all programs.

Many people play and they have to leave the PC for a while. At office I always press winkey-L to lock my workstation, since anyone could peek into your private info.
If am in the middle of a flight simulation and nature calls me, I have to go... But want my game right where I left, either Flight sim or solitaire, or in this case, a game I want to sell.

In my home PC, XP home is configured as default, so that the welcome screen shows up automatically after certain time has passed without activity, indicating the current logged on user. You click the user and return to where you were.

So, there IS the possibility of the logon screen being shown without actually logging off.

May the 3d force B with U
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Jan 2007 01:02
It's an issue with DirectX, not DBPro. You can code around it, but it's usually not worth the effort. I did it once with a very simple piece of code and ended up making a 20 line program over 200 lines in size ... and that still didn't deal with everything.

Basically, when the display changes (resolution, switch desktop etc) DirectX will release *all* of the display surfaces, vertex lists, textures etc so that they can be reused. It's the responsibility of your application to detect this and to reallocate all of those resources and repopulate them, ie. recreate display bitmap, set camera characteristics, lighting, loading objects and more.

JDforce
19
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 20th Jan 2007 01:20
IanM,
I know is an inside DirectX problem, and that is precisely my question, how can I control the problem within darkBasic? Can darkBasic deal with it?
What I discovered with the other engines is that some pass, some fail.

IMO, the no-guess level that is achieved using high level languages like DarkBasic pro, should have included some of this failsafe functionality. Take truevision3d, for instance. Their apps return perfectly in the case of a Workstation lock. For dx8 and dx9. Code added: zero, and their engine instruction set is at very high level.

I think it is worth the effort to have programs that can be all day on. My users prefer them. Imagine losing your flight simulator session, or freecell or solitaire game just because you were ten minutes in the bathroom and the logon screen pops up. I am at high tech level, same as you, but our market, our users typically not. I can reason a solution, and they probably can but..They just use the programs and grade them. A crashing program is usually not the preferred one.

May the 3d force B with U
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Jan 2007 12:53
In simple terms, you can use the SCREEN INVALID() function to detect when the resources have been lost.

Here's a very bare-bones example of things in action:


You'll need to add a few other things at the very least though:
- The program will continue to run at full-speed in background, so you'll need to detect when this has happened and cause your program to sleep properly and use no system time.
- Track the position and orientation of all game objects yourself or they'll all be reset when you restore things.

There are probably some other things too that I've either forgotten or not hit myself, but I'll be willing to help out a little if needs be.

JDforce
19
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 21st Jan 2007 04:25
IanM,
I think I get the idea, you are very kind. I did a little test earlier today, and made a program in Delphi to detect the WM_DISPLAYCHANGE windows message, and this only occur when actually changing the resolution, either from the display control panel or if some app request it.
The Winlogon events, like ctrl-alt-del (SAS), workstation lock and others, do not notify anything, but it is possible to interact with the master Winlogon process via a special dll that can be done specially for this.
But, fortunately DBpro has the display invalid function. Am not completely clear on how to recreate not only the object handles but their "status" in the game, but your code is a good starting point.
Probably we can help others on making stable and "all day desktop" games, so they are more sellable.

Well, thanks, and for sure I will ask something in the process..

Julio

May the 3d force B with U
MExe
17
Years of Service
User Offline
Joined: 11th Jan 2007
Location:
Posted: 21st Jan 2007 20:46
OH - MY - GOD.

This is simply terrible.

I think that if you don't plan WELL your application, only the function to store and re-store the application situation when alt-tab is hit would take days...

Well, at this point I don't know if I will allow the application to be altabbed or to lose focus... is it possible to make a DBP application to never lose focus, even if a istant messenger window pops up to tell you that somebody is online?
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Jan 2007 22:37
Yes, although I can't be sure it'll survive an alt-tab, especially if running in fullscreen-exclusive mode.

There are a few commands/functions in my utility plug-in number 13 - HAS FOCUS() and GRAB FOCUS that might help you. Play around with them and see.

JDforce
19
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 22nd Jan 2007 14:55 Edited at: 22nd Jan 2007 15:06
IanM,
With all due respect, about your comment that it is a DirectX issue and not a DBpro issue...
I did a research thru the weekend, and I can't agree with that. The fact is that the job of any game engine is to prepare high level instructions in order for the developer to avoid the countless planning, instructions (and hours of work) he could spend by using a low level language.
This DirectX device loss is not a problem, but simply it has been the way it works. It is well advertised by DirectX developers, and is something that engine developers must deal with.
DirectX itself IS a multimedia engine, and if you use it for making games, you should stick to its rules or it will fail.

The screen invalid() function is useful, but it is only a detector. Dbpro should implement other utilities to help us to keep the game working in such common conditions.

In the usual developer environment, it never will happen, but someday, as happened to me, you distribute a game and the first thing that the user note is that the game crashed. So, it is a important issue, with echoes everywhere.

Do you know all FPSC games have that flaw too? Just because it is done on top of DbPro, which lacks that sort of recovery. And why FPSC has not implemented it? probably because the core engine has not a easy way of fixing it. Like a snow ball... it grows from the core. In this case, Lee has underestimated the problem... twice.

All professional games I have tested do not crash in the conditions mentioned. If we are to make games with dbpro, they shouldn't crash that easy, at the clients PC, it is. Do you think you can tell the customer that it is not your game fault but DirectX fault? If so, all games in the world would do so.

Using c++ it is easy to recover from a DirectX surface loss, as explained in this article with downloadable c++ code and compiled executable:
http://www.codesampler.com/dx9src/dx9src_6.htm

May the 3d force B with U
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Jan 2007 15:14
Yes, it's easy to recover from surface loss, and DBPro does that with a little help from you. What DirectX doesn't do is to recover what was stored within that memory - and that was a deliberate design decision - DirectX does not preserve the data your program has given it and expects your program to resupply that data.

A general recovery system can be done automatically - I've done it. I've even managed to hunt down a more complete example I played with in the past. It's not difficult - it just needs a little preparation and attention to detail.

I'll clean up the code and post it a little later when I get back from work.

JDforce
19
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 22nd Jan 2007 16:26
Excellent. Thank you.

May the 3d force B with U
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Jan 2007 21:01
Here's that code for you to play with:



It contains just the basics - if you need to reload object, reload and reapply textures, create lights etc, then that's stuff you'll need to add in by extending and adding to the UDT's and adding in code to deal with it.

JDforce
19
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 23rd Jan 2007 05:35
I tested the code, and that is precisely what is needed to recover. This code never crashed in all my tests. Great. Thank you.

One thing though, I would substitute the GetForegroundWindow with FindWindow, that needs the caption text and the class as parameters. For some funny reason, the class for DBpro apps is the caption + "12345".
You just need a windows analyser to get that information.

Since I tested on fullscreen and windowed mode, I commented the line where the mouse is reset to a fixed position, and it still worked fine.

It would be a great addition to FPSC, since sadly that games crash, at least in my PC.

Thanks again.

JD

May the 3d force B with U
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Jan 2007 14:43
Actually, I meant to use GetActiveWindow - you don't need the name for that, and there's only one active window attached to the DBPro process/thread.

Olby
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 23rd Jan 2007 23:42
Thanks Ian for such a nice peace of code. I was into this some time ago also, but gave up when I found out what a headache it is to store all object positions, rotations, etc.

AMD Sempron 3.1+ Ghz, 512MB Ram, ATI R9550 256MB Ram, Sound Blaster Live!, WinXP SP2, DirectX 9.0c, DBP 6.2
http://www.myspace.com/producerolby
Gamers for sale
18
Years of Service
User Offline
Joined: 19th Nov 2005
Location: Some where beneath the elements
Posted: 23rd Jan 2007 23:49
Quote: "JDForce
I know is an inside DirectX problem, and that is precisely my question, how can I control the problem within darkBasic? Can darkBasic deal with it?
What I discovered with the other engines is that some pass, some fail. "


Yes this seems to be a problem handling a problem in dark basic code. One suggestion is try using windows api for returning if a screen saver kicks in or it goes to the login screen. Then It would just be a matter of figuring a way to idle the app by hiding the window or something so the graphics aren't messed up.

I would suggest using window api to get a jump start on it!

JDforce
19
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 24th Jan 2007 14:32
From the Windows API, it is possible to detect if the screen resolution has been changed or if the screen saver is started. The winlogon events, due to security reasons are implemented via a "winlogon notification package", which is basically a dll that you have to make, and set it to interact between winlogon events and your program.
Since we are talking of speed, and anyway you have to recreate objects and status inside darkbasic, the screen invalid() function is much faster and precise, not to mention efficient and easy to implement.

This comment is based on this recent experience and tests done on both methods, external and internal detection.

May the 3d force B with U
JDforce
19
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 24th Jan 2007 19:09
IanM,
Do you have any idea of how this problem could be solved when using some plugins, specially like DarkPhysics?

Am not sure of the link between physics objects and DX-dbpro objects, because if the plugin creates a handle to the object, recreating it could disrupt the link between the visual object and the physics one.

Just thinking.

May the 3d force B with U
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Jan 2007 19:35
I don't have DarkPhysics so I can't experiment I'm afraid.

I would guess that as long as the objects that are linked to physics-object exist when you update the physics simulation that everything will just work, at least if it is coded in anything like the same way as the ODE plug-in was.

JDforce
19
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 24th Jan 2007 19:43 Edited at: 25th Jan 2007 04:23
Ok. I will do some tests and post results.

Thanks,

Julio

EDIT: Your code creates objects in memory. I have just realized that I would have to load all my X files, textures, sounds, and everything, every time a Winlogon or similar event causes this problem. Is there a way to keep everything in memory, like saving to stream? It probably would require not only to have a dll that handles streams, but to DBpro to be able to load from memory.

May the 3d force B with U
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 25th Jan 2007 07:43
Can't you just run the game in fullscreen windowed mode? That way, you can minimize, press CTRL-ALT-DELETE with not problem. I tested it with a screensaver and it worked great as well.

If you force the user to fun fullscreen exclusive, then you lock up the computer anyway, and they can't use IMs or anything.


Come see the WIP!
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Jan 2007 14:00
Quote: "but to DBpro to be able to load from memory"


Memblocks will cover most things, but they are a pretty scarce resource. You could take a look at my memory banks plug-in, the first plug-in of the utility pack, and plug-in 18 which allows you to load a DBO object from a memory bank. More commands can be added to that in future if it helps.

Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 25th Jan 2007 14:52 Edited at: 25th Jan 2007 14:53
Quote: "Can't you just run the game in fullscreen windowed mode? "


try and set the gamma for any windowed 3d application...

--Mike
Olby
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 27th Jan 2007 13:15
...and compiling games with fullscreen windowed mode is just not a professional way, because Lee lots of years ago explained how does the windowed mode works and it actually is lowering the picture quality a lot. Also message boxes and other things that we dont need to see while playing games are popping up. Try and run your game in FSEX and see how crisp graphics are, just like HL2 or other modern games.

AMD Sempron 3.1+ Ghz, 512MB Ram, ATI R9550 256MB Ram, Sound Blaster Live!, WinXP SP2, DirectX 9.0c, DBP 6.2
http://www.myspace.com/producerolby

Login to post a reply

Server time is: 2024-04-25 14:30:28
Your offset time is: 2024-04-25 14:30:28