Blitzmax app works very slow on Windows 8

Community Forums/General Help/Blitzmax app works very slow on Windows 8

Ravl(Posted 2014) [#1]
Both fullscreen or window mode.

I recently updated my system and installed Win8
My game does not use more than 20% processor or 400 mb ram but it moves very, very slow. Can be seen at animations. The pauses between frames are very big.

I found something on forums about Blitz3D and Dx7, but is not the case here.

Any quick tip?

Thanks,
R.


Calibrator(Posted 2014) [#2]
Are only the graphics affected by the slow-down or is everything slower?
Could be a driver-related problem if the latter isn't true.


xlsior(Posted 2014) [#3]
Try switching to use OpenGL, and see if that fixes it -- supposedly windows 8 has a regression in support for DirectX7, and limits the framerate of such apps to ~30fps

If switching to OpenGL or one of the newer DirectX versions runs faster, then this is what's affecting your app.


xlsior(Posted 2014) [#4]
.


Ravl(Posted 2014) [#5]
@xlsior: Switching to GLMax2DDriver did not solve the issue. Also I dont used DX7. I used the DX9 drivers..

@Calibrator: I have my latest drivers installed.
The whole app is slowed down.
I observed a loading time bigger than usual. Also the animations have now bigger pauses between frames. My entire game is like a slow motion one.


GfK(Posted 2014) [#6]
Just written a little test prog to try this out, and everything seems to be fine here?

Graphics 800,600,32

Local px:TPixmap = CreatePixmap(128,128,PF_RGBA8888)
px.ClearPixels($FFFF00FF)
Local img:TImage = LoadImage(px)

While Not KeyDown(key_escape)
	Cls
	'px:TPixmap = GrabPixmap(1,1,1,1)
	DrawImage(img,MouseX(),MouseY())
	Flip
Wend


(Windows 8.1, 6GB RAM, Intel HD4000 integrated GPU (Lenovo Ideapad G580))


Ravl(Posted 2014) [#7]
@GfK: your little test prog is working fine here too.

Also checked my FPS. They are 60-61.

However, my animations are very slow.

At every update I use this to take the game time:

Local GameTime:Float = MilliSecs()


then I pass the value GameTime to all my methods where I need it.

In my animation method I have something similar to this:
				If gameTime > animHintLastCheck + animHintFrameTime
					hintAnimationFrame = hintAnimationFrame + 1
					animHintLastCheck = gameTime

					'irrelevant code here
									
				End If


on other OS is working fine...


GfK(Posted 2014) [#8]
So basically what you're saying, on the strength of that code, is that the Millisecs() timer is running at slower than it should be?

Wait a minute... why do you have gametime:Float, when Millisecs() returns an Int? It probably isn't the cause, but it just struck me as odd.

[edit] Actually I may be onto something there. This laptop has only been on a couple hours and the code below already is demonstrating horrible loss of accuracy in the stored value. Change gameTime to an Int and spot the difference - it's MUCH smoother.

Graphics 800,600,32

Local gameTime:Float

While Not KeyDown(key_escape)
	Cls
	gametime = MilliSecs()
	DrawText gametime,50,50
	Flip
Wend



Derron(Posted 2014) [#9]
Also keep in mind: Millisecs() might return negative values (if your computer is running for 28+days - which is happening more often these days).

Means: adjust your code as a negative value "decreases" so
If gameTime > animHintLastCheck + animHintFrameTime
will be no longer working correctly.


@GfK
Now just explain why this float changes the performance. Shouldnt it just assign a value to a variable in both cases?


bye
Ron


Floyd(Posted 2014) [#10]
Now just explain why this float changes the performance.


A Float has only 24-bit accuracy. So when Millisecs stored in a Float reaches 2^24 it starts to lose precision. 2^24 millisecs is less than five hours.

Imagine floats have three digit ( decimal ) accuracy. The then next number after 2340.0 is 2350.0 and there are no numbers in between.

Watch the equivalent thing happen with 24-bit floats:

' In this example ms simulates a large MilliSecs() value of 172800000.
' This is a 32-bit binary value of    00001010010011001011100000000000.
' Next possible float value is        00001010010011001011100000010000.
' The first and last 1's span 24 bits     ^                      ^

ms = 2 * 24 * 60 * 60 * 1000  ' milliseconds in two days.

' Here are millisecs as an Int and a Float.
' Note the Int can change by 1, but the smallest change to the Float is 16.

For n = 1 To 50
	ms = ms + 1
	msf:Float = ms
	Print ms + "  " + msf
Next



Floyd(Posted 2014) [#11]
Means: adjust your code as a negative value "decreases" so
If gameTime > animHintLastCheck + animHintFrameTime
will be no longer working correctly.

The right way to do this is
If gameTime - animHintLastCheck > animHintFrameTime

This is immune to the "rollover to negative" problem.


Derron(Posted 2014) [#12]
gametime = 10
animHintLastCheck = -10
10 - (-10) = 20 [OK]

gametime = -30
animHintLastCheck = -10
-30 - (-10) = -20 [FAIL]


So you better go with abs(currTime - oldTime):

gametime = 10
animHintLastCheck = -10
abs(10 - (-10)) = 20 [OK]

gametime = -30
animHintLastCheck = -10
abs(-30 - (-10)) = 20 [OK]

Like said, the negative values decrease (think I saw this when users reported some "rollover"-fails like unhandled mouse clicks in my overlayed gui system) - so the further the time advances, the higher the negative value (-1 > -2).

Other options got discussed in multiple threads already. I myself now use a "Time"-class with various functions, eg. returning the time in milliseconds since app-start.


GfK(Posted 2014) [#13]
Floyd's example is to handle the rollover from positive to negative, which will happen once every ~25 days. I don't see the relevance of your example, which seems to insinuate that time runs backwards.


Ravl(Posted 2014) [#14]
changing the float to int did not affect the speed. same issues.

also the Floyd tip did not help me.

I tested the game again today on a Win7 machine and is ok. Only on Win8 seems is slow.


Calibrator(Posted 2014) [#15]
Hmmm...

Even problems with loading times? Generally slow?

Could be a problem with that specific machine then which means a lot more questions...
- Are other BlitzMax programs affected or only this specific game?
- Is the game slow after a fresh reboot with no other programs running?
- Which Windows version are you using? 8 or 8.1 or 8.1 Patch 1?
- 32 or 64 bit Windows?
- Amount of RAM?
- What graphics hardware are you using? Separate card with its own memory or integrated solution that uses system RAM? Which graphics chip?
- How graphics intensive is your game? (= how much RAM does it use that could affect system performance?)
- Did you try to disable your anti-virus software? ("real-time protection")
- How is the virtual memory being handled on your machine? (Windows caring about that or did you set a fixed amount?)


Ravl(Posted 2014) [#16]
The loading times are a little slower than always. On my previous OS (win 7) and on any Win7 machine I tested the loading time is small anyway (a few seconds)

- Are other BlitzMax programs affected or only this specific game?
I do not have any other Blitzmax projects with animation using Millisecs right now (still in devel)
I have a look over the samples and those are running fine. I did not test them all.

- Is the game slow after a fresh reboot with no other programs running?
yes.

- Which Windows version are you using? 8 or 8.1 or 8.1 Patch 1?
Err.. Last one?!

- 32 or 64 bit Windows?
64

- Amount of RAM?
8 Gb

[/b]- What graphics hardware are you using?
GTX 760 Overclocked :D

[b]- How graphics intensive is your game?

:)) https://www.youtube.com/watch?v=PjbR7W4Ka0I

- Did you try to disable your anti-virus software?
I only use default Windows 8 protection :-s

- How is the virtual memory being handled on your machine?
As I said in the previous post:
My game does not use more than 20% processor or 400 mb ram but it moves very, very slow.


Calibrator(Posted 2014) [#17]
This really is a tough one!

So you have a regular, modern Windows machine with standard graphics hardware...

- Which Windows version are you using? 8 or 8.1 or 8.1 Patch 1?
Err.. Last one?!


From what I read the difference between Windows 8 and 8.1 (which is the last one) can be quite drastic so it's always important to be exact here. Personally, I haven't had problems with my BlitzMax game in development on my Win 8.1 machine at all. It's in the Early Cambrian stage, though, so it's certainly not some sort of standard...

- How graphics intensive is your game?
:)) https://www.youtube.com/watch?v=PjbR7W4Ka0I


Ah, of course, you are the Crystals-of-Time-guy... ;-)
So, while it is a graphics intensive game it isn't a graphics hardware (= GPU + memory) intensive game. If anything I'd rule the Geforce out.
While I experienced some slowdowns in my game with older Intel graphics hardware in certain resolutions I never had those with a discrete graphics hardware solution like a Geforce or Radeon card. Both worked extremely well.

The overclocking bit should be completely irrelevant, though.

- Did you try to disable your anti-virus software?
I only use default Windows 8 protection :-s


Which means you are using the Windows Defender software which I believe was called Microsoft Security Essentials under Win7 and earlier.
I haven't had a problem with this in regards to pretty much anything out there and certainly not with BlitzMax or an app compiled by it.

- How is the virtual memory being handled on your machine?
As I said in the previous post:
My game does not use more than 20% processor or 400 mb ram but it moves very, very slow.


While some games require virtual memory to be active - even though they don't use a lot of RAM themselves (by todays standards) - you are OK if you didn't change the default settings (which means Windows cares for virtual memory).

I'm still convinced that it is somehow a problem of your specific machine and I believe many customers would've been angry with the game running badly on their Win8(.1) machines.

I keep thinking about system resources, though, and if the memory and bus thoughput are OK then we have to check if the game gets the full attention of the CPU or is restricted.


My game does not use more than 20% processor or 400 mb ram but it moves very, very slow.

What CPU do you have?
If you have a quadcore CPU a CPU usage of 20% is actually a lot if your program is a single-threaded app. It is, right?

Another thought:
Did you try different Windows compatibility settings for the game by clicking the app icon with the right mouse button and selecting them in the "properties" menu (sorry, I don't have an English version of Windows)?


Kryzon(Posted 2014) [#18]
Did you compile the program on Windows 8 itself, or are you running a build that you made on another system?

Is there are sort of sandbox utility active while you run the game?


Derron(Posted 2014) [#19]
Floyd's example is to handle the rollover from positive to negative, which will happen once every ~25 days. I don't see the relevance of your example, which seems to insinuate that time runs backwards.


The number once reaches its maximum, then the next number is the minimum (the negative value). As time goes by then, this number increases (mathematically, means "Minimum+1")

So for a number with MinMax of (-3, 3) this reads:
0,1,2,3, -3,-2,-1, 0,1,2,3, -3 ...

also see: http://www.blitzbasic.com/Community/posts.php?topic=60215

So my conclusion would be, that "abs" is needed because of the calculations you see in the prior post (-3 - -2 is -1, abs(-3 - -2) is 1, compared like "value > animTimer" which might be 1-3, this wont work then without abs).



@Ravl
Could you check how many times a special loop (a specific animation) is executed during a second? Maybe the problem lies in something else (eg. you mixed"hertz" and "interval").

bye
Ron


TomToad(Posted 2014) [#20]
Did you try reinstalling DirectX 9? When I got my new computer, installed with Windows 8.1, I noticed a lot of games running slowly. Read somewhere that Windows 8 only comes with DX 11 natively and anything 9 or earlier is emulated. Tried installing DX 9.0c from MS site and everything ran much faster.


Ravl(Posted 2014) [#21]
@TomToad:
Cannot start the DX9 installer. tells me I need other OS :D
I tried to use OpenGL anyway and I still have the same issues.

@Derron:
I am planning to have a look at that.

@Calibrator:
yeah I tried with Win7 compatibility and still the same behavior.
I remember back when I develop the game I made a quick test on a Virtual XP machine with no video drivers enabled. Basically that machine was the lowest possible Windows computer ever made. The game ran perfectly :))



I will try to make new test on other Win8 machines to see if this is a problem which only appears on my pc. Although I jsut reisntalled Win8 and the only programs installed are: steam, blitzmax and monkey dev and ides.. :(


skidracer(Posted 2014) [#22]
So your game is running at 60fps and your animation is choppy.

I think you should forget about blaming the OS and revisit what people have said above. You cannot use floats for the purpose of reading the millisecond timer.

The following code

For i=1 To 20
Local ms=MilliSecs()
Local badfloat:Float=ms
Print ms+"  rounds to float with error "+(badfloat-ms)
Delay 5
Next


Produces the following on my macbook which hasn't been powered off for a while and which will I imagine produce choppy animation


87819166 rounds to float with error 2.00000000
87819172 rounds to float with error -4.00000000
87819178 rounds to float with error -2.00000000
87819184 rounds to float with error 0.00000000
87819189 rounds to float with error 3.00000000
87819195 rounds to float with error -3.00000000
87819201 rounds to float with error -1.00000000
87819207 rounds to float with error 1.00000000
87819212 rounds to float with error 4.00000000
87819217 rounds to float with error -1.00000000
87819223 rounds to float with error 1.00000000
87819229 rounds to float with error 3.00000000
87819234 rounds to float with error -2.00000000
87819240 rounds to float with error 0.00000000
87819246 rounds to float with error 2.00000000
87819251 rounds to float with error -3.00000000
87819256 rounds to float with error 0.00000000
87819262 rounds to float with error 2.00000000
87819268 rounds to float with error -4.00000000
87819273 rounds to float with error -1.00000000




Derron(Posted 2014) [#23]
@Gfk
I have to excuse, just wanted to post that I had a chance to check on a notebook:

$ uptime
 18:25:12 up 27 days, 21:49, 30 users,  load average: 2.36, 1.74, 1.26


then I recognized that I made a mistake in my example (I talked about increasing values, but the examples used increasing ones (curr: -30, last: -10 while it should be the opposite). Sorry for the statements I gave earlier in this threads. I mixed "previous" and "current" which made the calculation-failures self-fullfilling.

But at least this keeps being the truth (albeit useless knowledge): the rollover-integer increases its value until it switches to positive again (-3,-2,-1,0,..).

Conclusion: no abs is needed (except you do not know if to "A - B > C" or "B - A > C").


bye
Ron


Ravl(Posted 2014) [#24]
@skidracer:
I already said earlier I changed the value from float to int. the issue is still present.


Derron(Posted 2014) [#25]
Did you have the time to check if your animation-position is changed accordingly or somehow this is skipped sometimes?


bye
Ron


Ravl(Posted 2014) [#26]
@Derron:
I will do this tonight when I go home.

Just an 'update':
The interesting part is that if I make a pause between frames bigger than 500 ms it's working fine. The problem is that my animations need something like 20-25..

Also, just tested the game on a crappy laptop with Windows8 x64 and is working fine :))

What problem it might be is affecting my machine. But could also affect others..


GfK(Posted 2014) [#27]
What I do is use a float for the frame counter - completely removing any dependency on Millisecs(). If you want the animation to run slower, just use a smaller stepsize, i.e.:

Repeat
    frame:+0.1
    If floor(frame) > myImage.frames.length
        frame:-myImage.frames.length 'if you just reset to zero, you MIGHT get a glitch in the anim smoothness
    EndIf
    DrawImage(myImage,x,y,floor(frame)
Forever

(may not work - typed directly into replybox, but you get the idea).


skidracer(Posted 2014) [#28]
Ah, oops sorry about that.

Perhaps you could provide the output of the code anyway.

I took a look at BlitzMax and in blitz.mod there is no code calling timeBeginPeriod which traditionally was always required to get the multimedia timer to perform properly. If you want to try it, change startup() method in blitz_app.c[106] to the following and rebuild module.

static void startup(){
	_mainThread=GetCurrentThreadId();
	timeBeginPeriod(1);	
}


Just to be pedantic, is your animation running slow but smooth, or is it just choppy?


Derron(Posted 2014) [#29]
what about

system.win32.c (used in TWin32SystemDriver)
void bbSystemStartup(){
...
	timeBeginPeriod( 1 );
...
}


Isn't this doing what you suggested or is this something different ?


@animations

He wrote "The pauses between frames are very big." - so I assume they are in sequence, but with the wrong delay. In both cases the chances for a bug in his code is higher than in the BRL code (when used the "common way").
Best of course would be if he could code a sample showing that behaviour - including all needed code and a verified failing on his setup.


bye
Ron


skidracer(Posted 2014) [#30]
Oh good it is there. Thanks Derron, please ignore my post.


Ravl(Posted 2014) [#31]
well, back again.

In these 2 days I made an upgrade to my pc: bought a new proc and a new motherboard.

did not reinstall OS (because I kept my SDD) but I made another test.

Now is working fine.

I will keep in mind your tips regarding the millisecs and I hope there will be no other issues.