I use LibGDX for rendering a game. I discovered a strange issue on Samsung S3. When touching a screen FPS goes down and animation jumps.
On other devices the app works smoothly. Touch callback is very fast and shouldn't affect a performance.
For adding touch support I use
Stage stage = new Stage(new FitViewport(Gdx.graphics.getWidth(),
Gdx.graphics.getHeight()));
Gdx.input.setInputProcessor(stage);
Could you please advice what might be the root of the issue?
Posting the answer in order to help others..
When enabling Show Touches setting in Developer Options be aware that it might decrease FPS of your game. It was my case.
Related
this question is a general question.I just wanted to know if there is any way through.I am having a very low refresh rate display android device due to which all the animations are getting lagged.I am needing a scaling animation which shrinks and grows of which i am having code but the issue is the smoothness.Is there any possible way that i can make my animation smoother for scaling animation or any way which shows like the animation appears smoother?>
Thanks in advance.
I have faced a similar issue with abrupt animations. Actually, the problem is not with the refresh rate of the device, the application might not be using the full hardware capabilities of the Android device, so not much can really be done
Also add the following line in the application tag of the manifest android:hardwareAccelerated="true" to ensure HW acceleration is used
I implement linear animation for lot of objects on SurfaceView and found the following issue: on Samsung S4 and S3 the animation is quirky, but FPS is near 60. On other devices works perfectly.
After I disabled hardware acceleration in Manifest it worked much better, but sometimes the screen is flickering.
Please advice where might be the root of problem. Thanks!
upd: as for code - I don't create any objects in realtime but reusing the ones from object pools.
When I use AdMob in my activity it is slowing down all my other view animations, introducing artifacts on them and so on. Did anyone have this and was able to somehow solve it?
UPDATE: I have a really old Nexus 7 with Android 4.4.2 and it was running everything perfectly smooth. Then I upgraded it to Android 4.4.4 and it started to show that crappy performance + artifacts. What could have changed there in this small update from 4.4.2 to 4.4.4??
We have had this issue on a couple of our games. The problem in our case was as follows.
The game itself had a bunch of layers to accommodate all the animations, and the Ad later was on top of the game layers, this messed up the renderer as it had to cater for the ad while rendering the scene. We had to hide the ad during game play to ensure full speed animation. An alternative was to adjust the size of the animation layers to ensure that they did not overlap the ad layer, but we did not go that route as our home grown framework did not support that.
Hope that helps.
I am working on an Android custom graph view that uses Canvas#drawLines and a paint object that has antialiasing turned on. My view has hardware acceleration turned on. Occasionally when I pinch zoom in/out, some of the lines in my graph will appear disjointed and they sort of taper off into a gradient. If I change to software layer or disable antialiasing, the issue goes away. Is this a bug with drawLines or does someone have an idea of what might be going on?
The first image exhibits the issue, the second image was moved slightly and demonstrates how the graph looks most of the time, with fully joined lines.
(image demonstrates issue)
(image showing how graph should look - still couple minor gaps)
I think this post by Romain Guy answers some of your question: http://android-developers.blogspot.com/2011/03/android-30-hardware-acceleration.html
Essentially, anti-aliasing is not supported by drawLines when hardware acceleration is turned on. Also remember that hardware acceleration won't always be 'better' for your app. If what you are drawing can be accelerated, your app will benefit from it, but for certain operations it might be worse.
I believe that explains why your lines appear disjointed when hardware accelerated. I'm not too sure it explains why it works when you turn anti-aliasing off, though. I'd imagine it would appear disjointed even with anti-aliasing off, but clearly that is not the case!
Try forcing a refresh after the resize gestures.
Have a look at my old Accelerometer Toy app. (Yeah, it REALLY need updating...) If you don't see the problem with that app then I can probably help.
(I tried to stuff the question with keywords in case someone else has this issue - I couldn't find much help.)
I have a custom View in Android that contains an LED bargraph that displays levels received via socket communication. It's basically just a clipped image. The higher the level, the less clipped the image is.
When I update the level and then invalidate the View, some devices seem to "collect" multiple updates and render them in chunks. The screen visibly hesitates for say 1/10th of a second, then rapidly paints multiple frames, and then hesitates again. It looks like it's overwhelmed and dropping frames.
However, when changing another UI control on the screen, the LED bargraph paints much more frequently and smoothly. I'm thinking Android is trying to help me by "collecting" multiple invalidations and then doing them all at once. Perhaps by manipulating controls, I'm "increasing" my frame rate simply by giving it "more to do" so it delays less between actual paints.
Unlike animation (with smooth transitions) I want to show the absolute latest value as quickly as possible. My data samples aren't faster than 10-20fps anyway.
Is there an easy way to "force" a paint at certain points, or is this a limit of how Views work? Should I be implementing this in a SurfaceView instead? (I have not played with that yet... want advice first.) Thanks in advance for suggestions.
(Later that same day...)
Update: I found a page in the Docs that does suggest implementing my widget as a SurfaceView is the way to go:
http://developer.android.com/guide/topics/graphics/2d-graphics.html
(An hour after that...)
SurfaceView seems overkill for what I want to do. The best-practice method is to "own" the whole canvas, but I have already developed the rest of my controls and layouts and they work well. It must be possible to get some better performance with what I have, especially since interacting with the UI makes the redraw speed satisfactory.
It turns out SurfaceView was the way to go. I was benchmarking on an older phone which didn't help. (The frame rate using a standard View was fine on an ASUS eeePad). I had to throw away some code, but the end result is smoother and faster with SurfaceView. Further, I was able to re-use more code than I expected and actually dramatically simplified my multitouch handling code (since everything I want to touch is in the same SurfaceView.
FYI: I'm still only getting about 15fps on Droid X, but half of the CPU load appears to be data packet processing. The eeePad is doing almost 40fps now -- and my data rate is only 20 samples/sec.
So... a win I guess. I want the Droid X to run better, but it flies on a real tablet.