Memory Access Violation in Screensaver

Blitz3D Forums/Blitz3D Programming/Memory Access Violation in Screensaver

Fuller(Posted 2006) [#1]
I just got my Dragon Screensaver on my computer. I left for awhile and came back to a black screen and when I shook the mouse, a "Memory Access Violation" warning box was there. I have tried to make multiple screensavers and all of them have the same problem. What would cause this?


b32(Posted 2006) [#2]
Try compiling the screensaver in debug mode, it might give a more clear error message. Have you ran the program as a common (non-screensaver) .exe ?


Fuller(Posted 2006) [#3]
Yes I tried to compile the screensaver in Debug mode but it gives me the same error. It works fine in .exe


b32(Posted 2006) [#4]
Maybe it is the device that has gone lost ? Try compiling the program in windowed mode. In w98, the problem was, that a new instance of the screensaver was started every minute. I don't know if xp solved this. It might be useful to determine at what point of the program the error occurs.


Fuller(Posted 2006) [#5]
Oh, Yeah I heard about that somewhere. I'll try it when I get home today.


jfk EO-11110(Posted 2006) [#6]
quote:
In w98, the program was, that a new instance of the screensaver was started every minute

Really? Not in Win98se AFAIK.

However, it may also be a problem with the access paths, when it works as EXE but doesn't work as SCR from a screensaver call.
You should call the following line before you access files:

changedir systemproperty$("appdir")

Note: this won't work when stared within the IDE, needs to be compiled EXEs or SCRs.


Boiled Sweets(Posted 2006) [#7]
so what exactly is the code doing when you "shake the mouse"?


b32(Posted 2006) [#8]
@jfk, i just renamed my (delphi) .exe to .scr, and encountered this problem. I don't know if this was w98 first or second edition, actually.


Fuller(Posted 2006) [#9]
However, it may also be a problem with the access paths, when it works as EXE but doesn't work as SCR from a screensaver call.
You should call the following line before you access files:

changedir systemproperty$("appdir")


I have changedir systemproperty$("appdir")

[quote] so what exactly is the code doing when you "shake the mouse"? [/qoute]

Until Getkey()<>0 or Getmouse()<>0


I tried compiling it to .scr in windowed and debug mode and a strange thing happened, the screensaver loads fine and renders the scene for just a second then it quits by itself. No warning, no black screen. I kept the task manager up to make sure multiple copies weren't coming up.

I tried It on my other computer and it still doesn't work.

This is supposed to be my friend's post-birthday present, so I'm really frustrated.

Thanks


Boiled Sweets(Posted 2006) [#10]
send me the code and I'll fix it for you.

I have written several commercial screen savers using Blitz3d and I have not experienced this problem.

To take a look at one of mine screen savers go here

www.boiledsweets.com/Vorboils

It is a robust heavy duty application.


jfk EO-11110(Posted 2006) [#11]
BTW did you think about to sell a license for some kind of screensaver for blitz3d framework? I'd probably buy one. I still can't handle the api-embeded stuff like password, settings, preview etc. correctly. (nasty black flashing popup windows)


Boiled Sweets(Posted 2006) [#12]
Fuller,

please accept my apologies for what might look like a hijack of your thread. It is not intended to be a hijack just spreading my huge screen saver writing experience hopefully for the benefit of you + others.

jfk EO-1110,

there should be no need for black flashing windows. The config stuff is best handled by some other GUI language like VB. Also this means the API stuff is easier to handle to. The way my Blitz savers work is like this...

.SCR is actually a renamed VB .EXE, the VB handles all the horrid WinApi stuff and registers that the saver is running etc. It also does the config stuff. This then calls the Blitz .EXE. In my opinion this is the best of both worlds. The neat thing about a VB as the front end is that you can run a series of images (animation) in the preview window so actually looks like it's running in the preview window. Also Innosetup is in my opinion a fair better installer.

Failing that use the Blitz MAX screen saver example in the code archives, it even runs in the preview window!
Please try Vorboils and see what I mean.


jfk EO-11110(Posted 2006) [#13]
ok, I see. VB isn't my thing, I even haven't a compiler installed. But maybe you could make some kind of generic framework, so a blitz programmer could add the screensaver exe and maybe some script based parameter settings.

Maybe this could be a useful third party product for blitz3d owners.

I used Innosetup some time ago. I also had a Gui editor that made it easier. I was using Clickteam installer because it allowed me to install a SCR as the current screensaver easily. I have no idea how to do that with Innosetup, and if it's possible at all.


Fuller(Posted 2006) [#14]
No need for apology, I sent the code to you and am thankful for your help.


Boiled Sweets(Posted 2006) [#15]
jfk,

to install a screen saver with innosetup is easy...

"{sys}\rundll32.exe"; Parameters: "desk.cpl,InstallScreenSaver {sys}\MyScreenSaver.scr"

I could knock up a generic framework but you would still need to code the various options you wanted. Have you taken a look at the Vorboils configuration. Please do so and you'll see what I mean.

The problem is to amount of work to create a framework -- I would like to justify it by charing a small fee, I think the demand would be very small.

You could use the BlitzMax framework (in the code archives) to avoid a lot of these problems but then obviously your ss will only be 2d.


jfk EO-11110(Posted 2006) [#16]
I meant something like a script based options screen, with a variable number of parameters that could be saved to a file by the VB part, so the blitz part can read it.

Anyway, I patched my blitz EXE so now it will be hidden by default and only use ShowWindow if it's not a settings call, a password call or a preview call from the OS. Settings can be accessed when the saver is running.

I watched the screenie from your settings GUI, currently I'm surfing on linux so I can't run it but I think I remember that screensaver.


Boiled Sweets(Posted 2006) [#17]
fuller not received email...


jfk EO-11110(Posted 2006) [#18]
I just realized it may be not so easy to make a dynamic GUI interface in VB that is based on a script or cfg file. Labels, gadget-type, number of elements etc. would have to be dynamic. Not sure if you can click this together with the interface clicky tools of VB as I remember it.

And BTW thanks for the Innosetup hint. I just found another reason why not to use the clickteam installer: when the user selects an other screensaver then your screensaver will vanish from the list of savers.


Fuller(Posted 2006) [#19]
Hmm... I sent the e-mail. Darn that AOL. well here's the download link:

http://s7.quicksharing.com/v/5679337/Dragon_ScreenSaver.zip.html

Its in zip form


Boiled Sweets(Posted 2006) [#20]
I get no MAVs here! Works fine.


Fuller(Posted 2006) [#21]
Did you leave it on for a long time? hmmm... Does your computer have auto turnoff or standby feature on? What is your operating language? WindowsXP?

Thanks for helping, I really appreciate it.


Boiled Sweets(Posted 2006) [#22]
No I didn't leave it for a while.

I noticed that in your loop you do a copy entity but never free the new copy of the entity! You hide it, perhaps you should delete it. Also I would eliminate all the particles stuff. If it doesn't crash with that commented out then you know the problem is there.

XP PRO SP2.


Fuller(Posted 2006) [#23]
Ok, im trying that out...

It's never crashed on start up, just after 10 min or so.


Fuller(Posted 2006) [#24]
I changed the hideentity's and got rid of the particles, but now it loads, renders once, then shuts down with no error message...

Kinda like what happened when I compiled it in windowed and debug mode to .scr

I can't imagine whatever's wrong with the screensaver.


jfk EO-11110(Posted 2006) [#25]
You really have to isolate the problem.

Make a simple dummy screensaver, containing nothing but Waitkey():

waitkey()
end

Then add the components of your screensaver one by one and see if it still works.

Sometimes isolating a bug is the hardest part in the entire programming job.


Boiled Sweets(Posted 2006) [#26]
I'll try a few things...


Fuller(Posted 2006) [#27]
Boiled Sweets - Thanks for all the help you've been giving me.

JFK - I've made multiple screensavers and tried isolating components of all of them, but to no avial. I'm beginning to think it is a hardware issue, even though I have tried it on multiple computers.


Boiled Sweets(Posted 2006) [#28]
I simply changed the HideEntity to FreeEntity. Hasn't crashed yet...


Fuller(Posted 2006) [#29]
I'll try it out here.


Fuller(Posted 2006) [#30]
Now its not loading, like before:

I changed the hideentity's and got rid of the particles, but now it loads, renders once, then shuts down with no error message...

Kinda like what happened when I compiled it in windowed and debug mode to .scr



Fuller(Posted 2006) [#31]
Well... I've tried all I an think of. Any ideas?


PatrickS(Posted 2007) [#32]
"Any ideas?"

If it can help you or others... I just started to learn B3D
and I had an error (Memory Access Violation)
that was occuring only when windows xp
was executing the screensaver .src
(in the screensaver setting window:
right click on the wall paper -> properties -> screensaver)
even if the .exe and .src worked very well.

The problem was the Path for my images (or similar ressources).

If your B3D file (.bb) is at:
->C:\xxxxxxxxxxxxxxxxxxxxxxxx
When you hit RUN in B3D:
->SystemProperty("appdir")
will return:
->C:\Program Files\Blitz3D\bin

SystemProperty("appdir")
return the current path of the .exe file.

I tried this:
=========================
If Right(SystemProperty("appdir"),12) <> "Blitz3D\bin\"
ChangeDir SystemProperty("appdir")
End If
=========================
then everything worked well.


Fuller(Posted 2007) [#33]
Ok, I'll try that.

(I still haven't solved this in three months LOL)
(I gave up in a couple weeks...)