Slow Performance with Android

Hello!

First of all, I know what you’re probably thinking, and I want to say right off the bat that I have read the optimization page, I am using Unlighted material, I have no physics implementation (that I know of), and I have turned off verbose logging. That aside, on to my post:



For the past several weeks, I have been looking into various engines for Android/Desktop development. So far I have tried 3, including jME, and I would rush straight into the game I am attempting to make with jME as it fits my needs very well except that I am getting a poor framerate on the Android version of my program.



Now, my program is really simple, and a test case I’ve been using for testing out engines - it consists of an ogre-xml-turned-j3o model that contains, according to the scene viewer, ~1.8k vertices and ~1k triangles. That’s it. That, against a black background with no lighting and no GUI (although I did try Nifty which made the fps plummet even more). Oh, the model is animated with a single, simple, skeletal animation that loops. With this setup I get 29 fps and that simply does not seem right. For the record, I have an Motorola Atrix 4G. My modeler, who has a Galaxy Note I believe, gets about the same (30 fps). Thinking that perhaps there was a weird sort of vsync going on, I added another model, hoping that the framerate would stay around 30, but alas, it did not, and instead dropped to 20. I did as much of the optimizations from the wiki page as I could and verbose logging was turned off for those fps numbers.



Is there anything I can do to increase performance? I can supply source code, and I admit that, being a jME3 newbie, I might be doing something wrong, but to my knowledge I am simply loading a model, creating a(n unlit) material, setting a texture, applying the material, and then making an animation controller for the model and setting the animation, so I don’t feel like my code is the problem. However, if it will help, I will be more than happy to provide.



As a point of reference, I tried libgdx, and while I feel it is ultimately not the best choice for this relatively simple project, I was able to get a lot more triangles on the screen (albeit not animated at that point in time) and maintain 60 fps, so I feel that it is likely not my phone.



Anyway, sorry for the long post, thanks in advance!



tl;dr: I get really low performance on Android with a simple ~1k triangle animated model. I have already tried optimizing and turning off verbose logging, and I do not use lit materials or physics. Any advice?

I seem to be able to handle quite a few objects, physics, skybox etc and maintain 60fps on my HTC sensation. I have not tried animations, so I guess that is the killer atm, try lower the amount of vertices for the model that you are animating and see what happens

Yeah, I’d also think that if anything it would be the animation as googles “Java VM” dalvik is painfully slow. Everything else (rendering, physics) happens on GPU or natively. Try disabling the animation, start out with a simple box and see if you have any other issues (also try other profiles in the android harness).

Emulation is slow, but on my “not the fastest” Samsung Galaxy Mini, my little test runs quite good, using that free ninja animation and little landscape.

what android version are you using?

@larda said:
Emulation is slow

VM != emulation

Thanks for the answers, I’ll test out whether it’s the animations asap.

If it is, what recourse do I have? Does jME have support for non-skeletal animation that I have thus far been unable to find? In theory that should be faster on android atm, right? Or am I misunderstanding the cause of the decrease in fps?

EDIT: After having disabled animations - that is, not even creating a controller or channel, I get the same fps as before :confused:

Seeing as it is not a problem with animation apparently, or at least with having animation enabled, I am going to post the code I use in case it is a coding problem:



Thus far my only code is in simpleInitApp() of my main class which extends SimpleApplication except for:

[java]

Spatial dummy;

[/java]

which is an instance variable of my main class atm.



All of the rest of the code (aside from initialization stuff such as app.start()) is in simpleInitApp():

[java]

flyCam.setMoveSpeed(5f);



cam.setFrustumPerspective(45, (float)cam.getWidth()/(float)cam.getHeight(), .01f, 200000);



dummy = assetManager.loadModel("Models/dummy/dummy.j3o");

Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");



Texture tex_ml = assetManager.loadTexture("Models/dummy/dummy.png");

mat.setTexture("ColorMap",tex_ml);



dummy.setMaterial(mat);



rootNode.attachChild(dummy);



dummy.setLocalTranslation(-3f,0,-5f);



setDisplayFps(true);

setDisplayStatView(true);

[/java]

When I used the Unshaded material, I was able to get a fairly high detail model (the Teapot) to run at 60 fps on my device. Generally the more complex the material, the lower fps becomes. E.g. full blown lighting shader is 20 fps, whereas lighting shader with vertex lighting is 40 fps. It seems that to get the best performance, one should optimize the shader(s) used by jME3.

I’m using Unshaded material and assigning it to the model correctly, right?



Why is my model which is about 1k polygons making my phone chug at 30 fps? :S Even non-animated :confused:

That’s strange, with unshaded you should have better perfs.

What do you have exactly in your dummy.j3o?



btw, i don’t think is the cause of the issue, but this is a really bad frustum setting

[java]

cam.setFrustumPerspective(45, (float)cam.getWidth()/(float)cam.getHeight(), .01f, 200000);

[/java]

Read this for more info http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

Thanks for the reference!

From the link: “Beginners frequently place zNear at a very short distance because they don’t want polygons close to the eye to be clipped against the near plane - and because it isn’t obvious why you’d want to do anything else.” Exactly me! >.< I’ll be sure and read through it, thanks again!



dummy.j3o is converted from an ogre-xml .scene which included a .mesh.xml, a .skeleton.xml, a .material, a .png, and the .scene. In the Scene Manager, it has an Armature, a ‘Hemi’ (not entirely sure what that is), and a Camera.



Thanks!



EDIT: I increased the near clip and oddly enough, that increased the fps by 5-7 on the phone :open_mouth: however, I still feel like it should run faster than it does. On another note, in the program, the stats view shows ~1.5k Triangles and ~2.8k Vertices. Why is this less (EDIT: more) than in the scene viewer?

“Hemi” is a light from blender… I guess it’s just a node once in JME, it should be harmless, but it’s also useless. You can remove it.

Same for the camera.



Could you upload your model? the mesh.xml and skeleton.xml.

I’ll work on uploading the model - what’s the best way?

uh…upload it on what ever file hosting site.

http://www.mediafire.com/?9z6bsbuno2t68l4



A heads up, I changed the name of the model in the example code I posted. It’s actually called ‘mrflex’ and the only animation he does is called ‘my_animation’ and it’s a quickly thrown together deal.

mhhh…something is wrong…and I have this with Oto too

i have constant GCing occuring

[java]

GC_FOR_MALLOC freed 938K, 62% free 3606K/9287K, external 5594K/6615K, paused 27ms

D/dalvikvm( 3118): GC_FOR_MALLOC freed 938K, 62% free 3606K/9287K, external 5594K/6615K, paused 29ms

D/dalvikvm( 3118): GC_FOR_MALLOC freed 954K, 62% free 3606K/9287K, external 5594K/6615K, paused 30ms

D/dalvikvm( 3118): GC_FOR_MALLOC freed 941K, 62% free 3606K/9287K, external 5594K/6615K, paused 27ms

D/dalvikvm( 2927): GC_EXPLICIT freed 8K, 50% free 2712K/5379K, external 1625K/2137K, paused 590ms

[/java]

seems it comes from the SkeletonControl.

I see so would it be any skeleton or just those specific skeletons? Is there any way to do non-skeletal animation?



Thanks for all of your help!

No there is no way, I’m looking into it, I’ll post updates as soon as i have.