Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (789)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (864)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Performance Problem on OSX  (Read 1573 times)
0 Members and 1 Guest are viewing this topic.
Offline frizkie

Junior Newbie

« Posted 2012-04-18 18:45:42 »

Hi, I've got a simple 2D game going and it works fine on Windows. I've tried on two machines, both with i5 processors, one quad core, one dual core. They both run at the full 60 frames per second, and everything is smooth. I had someone I know try it on their mac (2010 MBP), and it only manages 5-10 frames per second, and everything is super laggy - the player jumps around, and the game freaks out in general. I also tried it on a 2006 MBP, and I had the exact same results. The 2006 is a dual core, and the 2010 is also dual-core. Here's my code, I don't know if there's something about the hardware that makes it not run, and that my game is just terribly optimized, or if it's the fault of OSX and it's Java.

You can download a compiled JAR and source code here, it's a bit long to post in this thread. Make sure the DATA folder is in the same directory as the JAR when you run it.
Offline lhkbob

JGO Knight

Medals: 32

« Reply #1 - Posted 2012-04-18 22:25:03 »

I tried running it on my i5 MBP and also saw very low performance.

Taking a look into your code, my best bet is that your run loop is buggy and is sleeping way longer than expected.  I replaced it with a simple update/render/sleep loop fixed to 60fps and the FPS counter claimed it was running at 60fps.

Unfortunately, all of the animations were still very slow and laggy, but I started looking into your code and it looks like you have strange time tracking throughout your project.

My best guess is that's what is causing your problem.  OS's report different accuracies with their timer so it's possible that Windows masked these problems.  Similarly, Thread.yield() may behave differently.  I would recommend using as simple a loop as possible, relying on sleep only instead of yield+sleep, and perform your animations based on a standardized delta time based on seconds.

Offline frizkie

Junior Newbie

« Reply #2 - Posted 2012-04-19 00:37:08 »

Thanks for trying it out. It's actually heavily-altered source from a different 2D game, but the odd time keeping method is the way the original writer made game tiles (like the water animation) change each second. Other than that, I use nanoTime exclusively.

I'll look into why it's sleeping so long.


I had a friend try it, and he's running:
2GB Ram
Dual Core 2.1GHz AMD processor
Integrated graphics

It runs at about 35 frames per second, leading me to believe that his computer isn't powerful enough to do some calculations I'm running. I figured that my code is pretty simple, and that a game should have no problem rendering it, but apparently this is not the case.

Is it just terribly optimized code that is causing the problem?
Pages: [1]
  ignore  |  Print  

hadezbladez (2595 views)
2018-11-16 13:46:03

hadezbladez (928 views)
2018-11-16 13:41:33

hadezbladez (2551 views)
2018-11-16 13:35:35

hadezbladez (500 views)
2018-11-16 13:32:03

EgonOlsen (3675 views)
2018-06-10 19:43:48

EgonOlsen (4028 views)
2018-06-10 19:43:44

EgonOlsen (2440 views)
2018-06-10 19:43:20

DesertCoockie (3247 views)
2018-05-13 18:23:11

nelsongames (3293 views)
2018-04-24 18:15:36

nelsongames (4264 views)
2018-04-24 18:14:32
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!