I have a non-PlayStore app for Tablet devices where I have embedded YouTube videos in a FullScreenActivity. Code is pretty standard as per the documentation. However, I find the video playback quite laggy and it keeps buffering. To figure out what's happening, I started measuring things.
Device is Rockchip RK3368, 1GB Ram, 15.6 inch IPS display, 1920x1080, Android 6.0
1) Bandwidth - Have a 50 Mbps connection, face no problem with YouTube in any other device.
2) Memory - The device does have 1 GB memory, it may be less but I have no app other than stock ones installed and when I check for free memory it is generally more than 250 MB.
3) Processing power - It's an 8 core RK3368 CPU, however, after turning 'Show CPU usage' on, I see the device (the number for average cpu usage for time interval 1 minute) goes from about 5 to 20 or higher. This is when everything starts hanging in the tablet. Pressing back button or home button takes many many seconds to even register (that is show the ripple animation).
On closing the activity, the tablet is back to normal in about half a minute.
Turning hardwareAccelerated to true has helped a little but it is still unusable.
Please let me know how to improve the performance.
Please bear with me. I will provide any code/info/run tests if you need. Thanks in advance.
Related
I have an andengine game, which has:
45-50-55 fps on a normal Galaxy S3, the phone temperature is warm.
stable 60 fps on CM11 Galaxy S3 with root in performance mode (maximum cpu frequence = 1400mhz) . With root you can modify the cpu frequence. The phone temperature is almost hot.
40-45fps on my Nexus 6 (without root), but this phone is faster than galaxy s3! The phone temperature is almost cold.
The resolutions of the game are the same!
The main question is: why does my game fps same on the both device? On Nexus6 it should be faster!
The game is: https://play.google.com/store/apps/details?id=com.hattedskull.gangsters
when a cpu is faster but does show less performance then the other cpus, it could be that it uses only 1 of 2,4,8,12 cores. thats just 25% usages, s the cpu stays cold. a single core cpu will always burn at 100%, and gets warm. Multithreading is the solution. that will "force" the cpu to go at 100%, and the game will run faster
I am answering my question, because it is not obvious (for me), so the solution is:
Performance mode: After rooting the phone, I changed the scaling governor (at processor) mode in performance, changing min hz was not necessary. Now the phone are hot, not warm!
Mobil ads bad performance: I switched off all the internet connections (wifi, mobile), therefore the mobile ad disappeared from the game. I use admob in my game, which has not the best performance.
These caused the FPS drops in my game(s)!
I have an OpenGL game for Android. It runs at a good 60fps when the screen is touched. When I release my finger it goes back down to around 30fps. Does the touch event/release raise/lower a thread's priority and if so how can I replicate this to keep it at a constant 60fps. This only seems to be an issue on Galaxy Note 2 so far.
I'll assume you are using onDrawFrame and setRenderMode(RENDERMODE_CONTINUOUSLY).
30 and 60FPS indicates that your implementation of onDrawFrame is called as the device's screen refreshes. Most displays refresh at 60Hz, giving you 60FPS.
It is likely that the Galaxy Note 2 has some power saving feature that limits screen refresh to 30Hz when there are no touches on screen. Check if there's any way to disable this feature.
AFAIK, OpenGL ES does not specify a standard for screen refresh rates, you will need a throttling function to ensure that your game runs/feels the same (i.e. at the same speed) despite differences in FPS.
Yes.
The best way to observe this phenomena is to use systrace with the "freq" tag enabled. You probably need a rooted device, and you definitely need one on which systrace is enabled.
systrace will record changes in the clock frequency for various components. It varies by device, but you can usually get the per-core CPU clocks and GPU memory rate. You will likely see several of them drop significantly at the same time your frame rate drops.
The motivation for doing this is to reduce power requirements and extend battery life. The assumption is that, while your finger is in contact with the screen, you're actively doing something and the device should be as responsive as possible. After a brief period of time, the clocks will slow to a level appropriate for the current workload. The heuristics that determine how long to wait before slowing, and how much to slow down, are tuned for each device.
(This has caused some people to create a thread that just sits and spins on multi-core devices as a way to artificially prop up the CPU clock rate. Not recommended. See also this answer.)
The bottom line is that this isn't a simple matter of adjusting thread priorities. You have to choose between recognizing that the slowdown will happen and adapting to it (by making your game updates independent of frame rate), or figure out some way to fool the device into staying in a higher-power mode when you want smooth animation.
(For anyone who wants to play along at home: build a copy of Grafika and start the "Record GL app" activity. If you drag your finger around the screen all will be well, but if you leave it alone for a few seconds you may start to see the dropped-frame counter rising as the app falls behind. Seen on Nexus 5, Nexus 7 (2013), and others.)
I am making an Android app that plays audio and does heavy amounts of DSP. Using BetterBatteryStats, I've found on the HTC One X that when the screen is off the CPU throttles back to 384 MHz. This speed is too slow for DSP processing I am trying to do.
Is there a way to keep the HTC One X from moving to such a slow speed without keeping the screen on? A partial wake lock does not seem to be cutting it.
I have a song playing continuously in background using an Android MediaPlayer, by continuously I mean it loops forever.
I also have 25-30 short sounds that I play at discrete duration's using SoundPool Class, and they also have to play again and again with the main song.
The sounds are 0.5 second duration each and some of them are 0.7Mb in size, while the average size of a song would be approximately 0.4Mb.
I am able to do this entire thing smoothly on the device I made this app on, then I came to know that SoundPool has problems playing on Dual Core Phones. So I withdrew support for them.
Lately I tested the app on an older device running 2.3.3 and the new problem is that the sounds seem to play properly for first 4-5 cycles, i.e. till the main song plays 4-5 times, then at 6th time, there is a noticeable delay in the playing of sounds, I logged the values of SoundPool.play() and found out that delay is ~(1-2 sec), and this issue is only on lower end phones, why is this happening, I suppose that the problem is caused by the SoundPool class and is not at all an hardware issue since the device I tested it on had ample RAM i.e. 500Mb and a decent 600Mhz processor.
I really need to fix this as I expect my app to run on most devices, except dual core phone for time being.
Also I cannot use MediaPlayer to play my sounds as I do not want to increase CPU overhead and make my app lag more and also I do not know how many sounds I want to play before hand.
Any clue on how to fix this issue and reduce the lag, is most welcome.
Audio / Video playback is usually problematic since there are a lot of hardware / lowlevel software factors involved (there might be specialized decoding hardware on separate chips and/or embedded into the cpu and all of that in combination with software decoders, switching between bluetooth, headphonejack and the 2 speakers you have, a huge software stack from kernel to android system, etc). It is probably the most fragile subsystem of Android devices. A lot of devices have smaller quirks in that area and it isn't directly Mhz / RAM / Dualcore related. And unfortunately you have to live with some of them :(
Your best bet is to experiment with different ways to play / compress your audio. Things like restarting the playback after 5 cycles etc
When running the basic sample:
http://android-developers.blogspot.com/2009/04/introducing-glsurfaceview.html
Add some basic timing using System.currentTimeMillis() or dropping to native code and using clock_gettime(CLOCK_REALTIME_HR, &res) both yield the same results it appears. I tested with both separately.
I always calculate a frame rate of ~56. That is a rough average of 18ms between frames. I realize the timing of frames is not a perfect science (timer accuracy, device doing stuff in the background). I simply let it run doing absolutely nothing, not even a glClear. After an hour this is the results I got which is about the same as letting it run for 1 minutes.
I've tried many things to achieve a true 59/60fps. I'm beginning to wonder if it is my device (HTC Incredible S). Although I have tried Samsung Galaxy S and Nexus S both with the same results. Tablets do not exhibit this behavior at all. On my EEE Transformer and Xoom I get ~16ms a frame consistently.
This leads me to believe VSYNC is the issue and that the vsync on that generation of Android phones is slow. Really VSYNC should be ~16ms. Achieving a true 60fps is unlikely but 59fps should be common.
Has anyone else experienced this? Any tips for disabling vsync? I don't think that is possible. Any tips for gaining control of controlling the "swap" step of rendering?