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 / Detecting Video Flush

Author
Message
GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 29th Dec 2011 06:12
So for awhile I have been running my games in window mode and telling people "just don't CTRL+ALT+DELETE and you should be fine. But, I am on the verge of releasing one to the open public and want to add some kind of video recovery routine.

The actual recovery routine is done, now the problem is detecting when it needs to run. I had always thought that "screen invalid()" would fire when/while this occurs, but it also fires when you unfocus and refocus the window.

Does anyone have a fail-safe way to determine if your media was trashed?
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 29th Dec 2011 08:20
At the start of your code, load a 1px image.

Every loop, check for the existence of this image. If it doesn't, the screen has lost focus and reload everything.

My signature is NOT a moderator plaything! Stop changing it!
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 29th Dec 2011 14:45
Quote: "The actual recovery routine is done, now the problem is detecting when it needs to run. I had always thought that "screen invalid()" would fire when/while this occurs, but it also fires when you unfocus and refocus the window."


Technically you need to reload whenever the screen loses/regains focus, according to directx docs. (As you noticed, in practice this often isn't the case)


GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 29th Dec 2011 15:13
Quote: "Every loop, check for the existence of this image. If it doesn't, the screen has lost focus and reload everything."


If it was that easy, I wouldn't be posting here! The "image exist(x)" will still return 1 even after the image is gone. It is as if the "image exist" flag is set to 1 when you load an image, 0 when you delete the image, and then not checked at all between the two. If we could get a new optional parameter to "image exist" that forces DBPro to actually check for the image instead of just assuming. I could be wrong though.

Quote: "Technically you need to reload whenever the screen loses/regains focus, according to directx docs. (As you noticed, in practice this often isn't the case)"


I wonder why... It doesn't make sense to reload all your media every time the window loses focus. It just seems so unnecessary. My program is actually a tool that helps you play another game, and so you are constantly alt-tabbing between the two. Reloading all the images each time focus changes is definitely not an option.

Any other ideas?
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 29th Dec 2011 15:36
Quote: " If we could get a new optional parameter to "image exist" that forces DBPro to actually check for the image instead of just assuming. I could be wrong though."


Unfortunately, DBP wouldn't know. The only indication DBP gets is from the directx, a signal to reload the media before using it.

http://msdn.microsoft.com/en-us/library/windows/desktop/bb174714(v=vs.85).aspx

There may be a bug in screen invalid if you can alt-tab and everything still works, but dbp returns true for that function. I don't know for sure.


MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 29th Dec 2011 19:52
I need to keep track of this as I will be needing this solution... Hi Jer... Hi All

GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 29th Dec 2011 19:55
Quote: "There may be a bug in screen invalid if you can alt-tab and everything still works, but dbp returns true for that function. I don't know for sure."


If you run in windowed mode, and simply click your desktop behind your app, and then your app again, it fires a "screen invalid()", even when your media is completely safe in that situation. That is why you cannot just blindly reload when "screen invalid" says to.

I am going to look into IanM's window callback functions, see if they return anything useful when media is lost.
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 29th Dec 2011 20:53
Yeah, I'm watching this one too for a solution.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 29th Dec 2011 21:37
Could someone else run this code and tell me what happens when they CTR+ALT+DEL while it is running? You will need the Matrix DLLs to compile it.



Thanks!
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 29th Dec 2011 21:52
I am curious about the official plugins such as STYX and Enhancements pack... any users on here found anything in them? [please refrain from saying oh STYX is blablah... you know who you are haha]

I intend to pickup on the official add-ons minus a few... and then eventually as I undestand them I will jump into IanM's and the other ones like Bonds?

Isnt there a thread with a compilation of available community plugins? its hard to even consider using them as they are splatterred across the forum... just what I feel...

I still think there must be an easy way to flush the data on purpose meaning every object ID and soundID etc gets cleared... no? and then you can just reload from the beginning... but anyhoo I shall continue to keep an eye on this thread for future posts... thanks all.

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 29th Dec 2011 22:13 Edited at: 29th Dec 2011 22:35
Quote: "It doesn't make sense to reload all your media every time the window loses focus. "

I just ran a few tests (only with a single image) in windowed mode and got a few interesting results. Try this (you'll need to load in your own image) and then change its focus in all of the ways you can think of:



In what situations does "Image Loaded" equal 1? I only found two, when using ctrl+alt+del and swapping from an application running in fullscreen.

Edit- Forgot to mention something. You'll need to close and run the application again once "Image Loaded" equals 1 because once it equals 1, it always equals 1.

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 29th Dec 2011 22:55
Hodgey NICE!

but your edit... care to elaborate on that? a little clearer...

thanks

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 29th Dec 2011 23:30
Quote: "but your edit... care to elaborate on that? a little clearer..."

Yeah, it's a bit unclear. Basically, once it's set to one, it won't go back to zero so it'll only show that the image has been loaded once. So if you want to try all of the methods that trigger the loading image code, then you'll need to close and restart the program for each method. Hope that's a little clearer.

GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 29th Dec 2011 23:34
Quote: "Yeah, it's a bit unclear. Basically, once it's set to one, it won't go back to zero so it'll only show that the image has been loaded once. So if you want to try all of the methods that trigger the loading image code, then you'll need to close and restart the program for each method. Hope that's a little clearer"


On my machine here at work (and BTW, I didn't just say that), I ran your program changing the "Image_Loaded = 1" to "inc Image_Loaded". For some reason, I get different results on this computer than I do on the two at my house. My results here mimic yours, where it only reloads when it actually needs to.

Maybe it has something to do with the application I alt-tab into at home, or windows 7, or some unknown factor yet discovered ...

Expect a reply when I get home and can run these same projects there. It would be nice if someone would post something before then so I don't get called out for double posting. :p
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 29th Dec 2011 23:35 Edited at: 29th Dec 2011 23:36
Valentine to the preventing double post aid... EDIT Tun da da daaaa!

Quote: "Hope that's a little clearer"


Clearly it was

EDIT

Forgot my A-TEAM jingle

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 29th Dec 2011 23:46
Quote: "Maybe it has something to do with the application I alt-tab into at home, or windows 7, or some unknown factor yet discovered ...
"

I'm currently running windows 7, I don't know if it works on vista/xp (if your using either). Do you use any 3D objects, worlds, etc? I haven't yet tried this with 3D stuff.

Mistrel posted some more in depth info on this right here.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Dec 2011 00:38 Edited at: 30th Dec 2011 00:39
This code works fine for me:



I've tested it both by using alt+tab from fullscreen exclusive mode and by locking the screen when in windowed mode. It still recreates the image successfully. The important thing is to check immediately after the "sync".

The matrix1 commands are only used to make a red image, you can use "load image" instead just as well.

[b]
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 30th Dec 2011 00:45 Edited at: 30th Dec 2011 00:53
does this work for sign out and in to user account? [switching accounts] all my apps crash when this happens...

just remembered that now...

EDIT

Typo

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Dec 2011 01:56 Edited at: 30th Dec 2011 02:02
Yes, that's what I meant by "lock screen" (I'm on XP and AFAIK it doesn't have a separate lock screen from the switch user page, at least with my settings anyway...)

[b]
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 30th Dec 2011 02:12
hmm... perhaps I can implement this into my current app as it will be useful if someone wants to lock the system while its running...

GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 30th Dec 2011 03:38
Quote: "I just ran a few tests (only with a single image) in windowed mode and got a few interesting results. Try this (you'll need to load in your own image) and then change its focus in all of the ways you can think of:"


OK, So I set this same type of scenario up with my game and it works about 50% of the time. Half of the time it runs the reloading function (which logs to a text file so I can tell when this happens) The other half of the time, it crashes due to invalid media, and my log files state that the last "media check" was fine. It seems like when you are CTRL+ALT+DEL, whether or not it crashes is based on where it was in the execution. Your example script works fine because it is so short, but put that examlpe to use in a full game and see if it has the same results.

I am still going to try to find a better solution, i.e., one that works for me.
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 30th Dec 2011 03:39 Edited at: 30th Dec 2011 03:42
Sorry for double post but...

function makeimage(id)
make image id, 32, 32

draw to image id
cls 0xFFFF0000
set current bitmap 0
endfunction

throws an error... do I need any special plugin?

nevermind... I do not use matrix utils at present... is there no other method?

EDIT

GIDustin NICE ONE NO DOUBLE POST LOL WILL READ YOUR POST NOW...

EDIT

I too will be looking into this...

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 30th Dec 2011 04:00
Quote: " but put that examlpe to use in a full game and see if it has the same results."

It's been a while since I've worked on it but try out my WIP. The game is neither large nor finished but let me know if you can crash it because it's supposed to survive all of the alt+tabs and ctrl+alt+del and any other focus changing situations.

I will admit though, I sort of cheat. I reload all media, not just the media necessary for that particular part of the program. It's inefficient but it minimizes the risk and because I don't have many images, the reloading is almost instant.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Dec 2011 12:58
Quote: "nevermind... I do not use matrix utils at present... is there no other method?"


Quote: "The matrix1 commands are only used to make a red image, you can use "load image" instead just as well."


Quote: "Your example script works fine because it is so short, but put that examlpe to use in a full game and see if it has the same results."

Hmm, I thought the device could only be lost during a sync. As long as you have manual sync enabled it should work. There is also some code that DBPro runs at the end of all loops except for "for" loops which does some stuff, maybe the device can be lost there as well, in which case you would need to check at the start of the loop.

[b]
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 30th Dec 2011 13:07 Edited at: 30th Dec 2011 13:35
Quote: "Quote: "The matrix1 commands are only used to make a red image, you can use "load image" instead just as well.""


I thought I read that smewhere... will retry...

EDIT

No luck... can not figure out that function...

also had a play around with STYX with mixed results..
I am coming to a conclusing... that minimising the window may actually [well hide wndow] overcome this issue...

I have posted this up on my blog so I am determined to get a fix for this...... ooo thinking abuout it... I think the fix was tat the app becomes busy... and then becomes locked... hmm is there a way to keep an app busy and perform a check for active window while keeping busy?

will continue to work on this... but soooo hungry right now...

Time for some hot chocolate [belgian hot choc that is] and some maderia cake ^^ sadly no custard...

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Dec 2011 14:23
SCREEN INVALID only returns a 1 when the application gets focus back - I don't know whether a CTRL-ALT-DEL would necessarily remove focus. In addition, it's a read-once function - as soon as you read it, it gets reset back to zero (it's like the MOUSEMOVEX/MOUSEMOVEY functions in that regard).

Basically, unless you are using a fullscreen-exclusive display, this function is pretty much useless as it stands.

There is nothing in my plug-ins that detects the loss of the DirectX device, but I can certainly add something...
1. Provide the equivalent of the SCREEN INVALID function.
2. Provide a callback during SYNC.
3. Both of the above.
4. Something else... suggestions?

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 30th Dec 2011 14:29
well... I believe its an issue in both windowed and non windowed apps...

Can you try to make it so that basically... it just does not crash? not bothered about reloading stuff... just dont want the app to crash...

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Dec 2011 14:39
What would be nice is if there was a way to associate an image with its source, so that it can be automatically recreated. For example, a version of "load image" that saves the filename so that when the image is lost, it will automatically be reloaded again, and a version of "make image" that saves the dimensions and format so it can be recreated.

[b]
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Dec 2011 15:12
Quote: "well... I believe its an issue in both windowed and non windowed apps..."

Simply hanging focus won't lose your media (or at least, that's my experience). Switching to/from fullscreen-exclusive (either your app, or another app) may lose the media, switching to a different desktop (as CTRL-ALT-DEL does and as screensavers do) may lose your media.

Quote: "Can you try to make it so that basically... it just does not crash?"

Not without fairly wide and deep changes to the core of DBPro. All I'm planning on doing is allowing you to detect the loss of media, then you can either reload it or deal with the problem in some other way (recreate the media some other way, or delete the media eg DELETE IMAGE etc).

GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 30th Dec 2011 18:20 Edited at: 30th Dec 2011 18:30
Quote: "hat would be nice is if there was a way to associate an image with its source, so that it can be automatically recreated. For example, a version of "load image" that saves the filename"


That is essentially what I did. Same with Sprites, bitmaps, etc.

IanM: Is it true that this loss of media can happen at any time during your execution, or only after a sync? If it can happen at any time, a callback is probably best (providing your callback function can execute immediately when the problem is detected). If it is only after a sync, than a "screen invalid" type of function would work.

Edit: Also, this is what I have noticed:
screen invalid fires on app focus gain/loss, even if media is not lost.
Media is lost when CTRL+ALT+DEL on any OS
Media is lost when UAC appears on Vista and 7
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Dec 2011 19:20
Yes, UAC would trigger the problem too. Screensavers (on the later OSs), CTRL-ALT-DEL, and UAC all create an alternate desktop to display upon, ie they take over the display. Powersave also results in the loss of the device.

Quote: "Is it true that this loss of media can happen at any time during your execution, or only after a sync?"

It's my belief that this can only happen during a SYNC, as that's when the 'Present' method of the DX Device is called, and it's that that detects and reports the loss.

If that is the case, then you don't need to pepper your code with checks, and I can simply trigger the callback at the end of the SYNC process if you set it.

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 30th Dec 2011 19:28
Ian... you got a good point there... what if while window active equals zero... what if we go to a non syncing loop or even an while endwhile??

Argh can not make my point but hope you get my... erm point haha

GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 3rd Jan 2012 06:59
Quote: "All I'm planning on doing is allowing you to detect the loss of media, then you can either reload it or deal with the problem in some other way"


Ian,

Will it take long to create this? I am just wondering if I need to attempt a temporary solution in the meantime or just wait it out.

And thanks a bunch for looking at this!
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 3rd Jan 2012 07:05
Quote: "What would be nice is if there was a way to associate an image with its source, so that it can be automatically recreated. For example, a version of "load image" that saves the filename so that when the image is lost, it will automatically be reloaded again, and a version of "make image" that saves the dimensions and format so it can be recreated."


Some kind of media management system would be nice. You could also alter the loading routines to simply make a copy of a piece of media if it's already loaded into memory.



Support a charitable indie game project!
GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 22nd Feb 2012 17:33
Ian,

Just checking to see if there is any progress on this. I am about to start a rather large project for the company I work for and I am hoping I won't have to explain to them all the different things they need to avoid (screensaver, UAC, etc) or else it will crash the program.

Thanks!
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 22nd Feb 2012 20:19 Edited at: 22nd Feb 2012 20:20
Quote: "i have a question for ianM"



The screen invalid..... does the application only crash when it hits the sync command? or does it crash on the spot where it finds that your trying to access media that doesnt exist?

If it crashes on the spot this realy makes it a major pain in the arse....

Id hafta type this before every line

if object exist(x)=1 then position object x,x1,y1,z1
if texture exist(x)=1 and object exist(y)=1 then texture object x,y

this is too painfull and should be corrected in the darkbasic programming language to just do nothing if it dont exist rather then crash.


Hopefully this is not the case....

Hopefully i would only need to call on screen invalid once just before the sync line

Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 3rd Jun 2012 18:36
Hi. I've just encountered this problem too and am looking for some kind of a fix. Anyone had any luck yet?

Anigma
13
Years of Service
User Offline
Joined: 25th Mar 2011
Location:
Posted: 8th Jun 2012 03:01
I'd like to see this fixed also.

FYI, this problem prevented a game I wrote in DBP a couple years ago from being published and as a result it was completely rewritten in another game programming tool. If you've ever sat and wondered why there are few if any games written in DBPro that actually hit store shelves or online portals, this is a big reason right here. If your game won't survive a windows screen lock it will get no further than QA.

It would be great to see this fixed because I believe in DBPro and TGC's products and would love to make a successful retail title created with them. Until a solution to this problem is found though, it's just a dream.

-Anigma

It compiled! Ship it!
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 8th Jun 2012 07:42
Yeah this is a huge issue.

zeroSlave
14
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 8th Jun 2012 09:41 Edited at: 8th Jun 2012 09:42
Not to beat a dead horse and kick it through a ghost town, but I also think a solution to this would be pretty great.

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 8th Jun 2012 13:21
Well there's a bugs thread.

GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 8th Jun 2012 21:32
Quote: "Well there's a bugs thread."


It was already mentioned in the "Top 3" bugs thread, and I just posted an example ZIP so hopefully it will get looked at.
Todd Riggins
19
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 9th Jun 2012 05:35 Edited at: 9th Jun 2012 05:40
Hi,

I've created A solution with a DeviceLost.dll that you can check out over here in the DLL TALK forum:

http://forum.thegamecreators.com/?m=forum_view&t=197641&b=18&p=0

It uses the internal "Device Lost" callback functions from DBPro itself and return results in related commands. This will help in letting you recover from a lost device state and to reload your resources at that time.

ExoDev.Com - A Game Development Tools Website! Featuring: XBOX360 CONTROLLER LIBRARY
Non Sequitur M
15
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 11th Jun 2012 21:40
Well, dangit... I was going to load as much media as I could during my program's main loading screen to cut down on loading times throughout the rest of the game. There goes that idea!

I totally forgot about this issue. I'm going to do some tests. I might have an idea... Will post when I've ran my tests.

-Amo
Non Sequitur M
15
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 12th Jun 2012 22:17
Sorry for the double post... This is too big for an edit, lol.

Warning:_______________________________
The things you need knowledge of for this method are:
Shell Programs
Shared Memory
Mutexes
_________________________________________

I've found a solution in the form of a shell program. If you load all the image data into a shell, execute your main program with it, and then hide it so that it is always running, you can pipe the data to your main program which will do all of the math, input, and screen stuff. Even if the main program loses focus, the shell will always maintain the image data's position in the graphics card's memory. Since the main program only grabs the info each frame when needed, the graphics are never lost!

It's a complex little process, and since I'll be using it in my copyrighted game, I don't feel that I want to post the actual code. So, here is a basic idea just to get you started:

In the shell program, you load the data, and then dump the image info into a shared memory location(mutexes are highly recommended here), execute the main exe, and then hide the shell.


In the main program, you pull the info from the shared memory and load this info as the image each frame that it is needed.


I've tried everything I could think of to trip my code, but since the image data is safely stored, you can't lose the graphics, and since the data is loaded each loop, there is no serious skip or delay in frames(As long as you have enough power in your comp. I'm running on a 4 year old laptop, and it ran fine!).

Here are the only limitations I could think of:

You need a faster computer to accomplish this smoothly, although most modern comps nowadays have enough power to do this.

You have to cut down on the frames displayed, because you have to load the data each loop. Shouldn't be a problem as long as you clock your frames to a reasonable rate like 30-60fps. Clock your frames people!!! 100-200+fps is not needed! Lol.

If the shell crashes you're SOL! All your data will be lost, and the main game will crash because it cannot find the appropriate data. Although, this is expected of crashes, right?

That's it, unless you don't use mutexes, because another program could dump data into your shared memory, causing graphics to be glitched.

Also, I forgot to mention... I am using Advanced Sprites and Matrix 1. Highly recommended plug-ins.

Anyway, hope this helps as there are some high level concepts here. Lol.

-Amo
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 13th Jun 2012 05:36
That seems like an awful length to go to, to fix a problem that (I perceive) shouldn't exist in the first place.

Non Sequitur M
15
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 13th Jun 2012 09:09 Edited at: 13th Jun 2012 09:11
Well, shell scripting is a very good idea anyway, so why not adapt it to this purpose as well? They are useful for debugging, data manipulation, and memory management(among other things).

And, yes, the problem shouldn't exist, but sadly, it does. And, it doesn't just affect DB. It also affects other languages as well. It appears to me that it's a hardware/firmware issue, not a software issue.

Besides, controlling mutexes isn't that hard, you just have to make sure to grab an empty sector with enough space, and make sure you read and write parallel variables to and from the same ranges.

-Amo
Anigma
13
Years of Service
User Offline
Joined: 25th Mar 2011
Location:
Posted: 14th Jun 2012 21:40
Quote: "Id hafta type this before every line

if object exist(x)=1 then position object x,x1,y1,z1
if texture exist(x)=1 and object exist(y)=1 then texture object x,y

this is too painfull and should be corrected in the darkbasic programming language to just do nothing if it dont exist rather then crash.


Hopefully this is not the case....

"


Nope. It IS the case. You will crash at whatever line you are at when you try to access or manipulate an object or image that no longer exists. It's a major pain.

What DBPro really needs is error trapping. If you could trap the error then you could go to a subroutine that would reload all your media and then return to where the error occurred so DBPro could pick up where it left off.

Without this, the only option you have is as you described above, checking that each image, sound, object, etc exists EVERY time you use it. Knowing this before you start a major project isn't too bad, you can simply code for it as you go, but finding this out when you are done with coding and in the QA stage with a major portal is devastating. It took me 3 months to rewrite the game in another product which handles screen flushes out of the box. A "professional" software development product (in other words, a product with "professional" in the name) should be robust enough to deal with this without burdening the programmer with this sort of thing. But, alas, it's easier said than done and I recognize that.

Just keep it in the back of your mind when coding - that an object or image or sound could be here one line and gone the next - and write your code accordingly. For my project, I'll be checking an error flag on each sync. I will set it to 0 and as I check each object or image for existance, I will set it to one if the object or image doesn't exist. If the error is 0 when I reach the sync, we're good. If not, forget the sync, jump to the load objects subroutine and then repeat the game loop. And of couse the load objects subroutine will need to check if they already exist or not, since some of them may have survived the flush (it's happened to me before). So frustrating....

-Anigma

It compiled! Ship it!
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 14th Jun 2012 23:41
Very interesting info on this. I don't really understand everything about it but in theory, would it be possible for the flush to occur between a check and a command? So for example with this line:

if object exist(x)=1 then position object x,x1,y1,z1

is it actually safe? Because what if the flush occurred after

if object exist(x)=1

and before

then position object x,x1,y1,z1

? Wouldn't this mean that the crash would still happen?

GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 14th Jun 2012 23:44
Lucas,

With an earlier build of DBP, I had the following code crash on me:


It commonly crashed on the line that pasted the image stating the image wasn't found.

Recently Todd Riggins suggested a decoy image that you check each loop, and if it doesn't exist you reload everything. For some reason that seems to work now...

Login to post a reply

Server time is: 2024-05-20 04:55:55
Your offset time is: 2024-05-20 04:55:55