I am trying out the (latest) Android SDK, and noticed some strange behavior.
I've written a skeletal SurfaceView app: Activity, SurfaceView and a rendering thread. It doesn't actually do any painting, and only writes out the framerate to logcat once a second. When it runs in portrait mode, I get around 60 fps. However, when I flip it to landscape the framerate drops to about 30 fps.
I have also tested it on the LunarLender sample, and got similiar results. All of the testing are done on the emulator, since I don't have a physical device.
What's it all about? I can't seem to find any mentioning to this on Google, have anyone else experienced that? Is it just an emulator quirk or does it apply to physical hardware too?
Guessing here- in landscape mode, is there extra "blank" space on either side of the rendered content? If so there could be an effective increase in the amount of processing just to paint the screen. Don't know if that should account for a 50% decrease in framerate, but it's possible.
Another guess- landscape mode may be deliberately throttled because it's intended primarily for video viewing. No reason to go up to 60fps for 30fps content. Configuration?
Related
A while back I asked this question and #fadden was gracious enough to give me an answer. So, now I have a VirtualDisplay which is using an intermediary Surface that I create and when the SurfaceTexture that backs the Surface receives an onFrameAvailable call, I make OpenGL calls to put draw that texture to an EGLSurface which is created from the Surface generated by the MediaCodec. Phew.
All of this is running in a Service (so it sticks around in the background). It all works, but I'm having some screen flickering occasionally on some devices. The flickering does not carry through to the data sent to the MediaCodec so it seems to be an issue with just the screen. The flickering also causes the "soft buttons" on Nexus devices to disappear/reappear on Nexus devices (but even when the buttons are gone on screen, the soft buttons appear in the output of the MediaCodec.
If I swap out my intermediary Surface so that the VirtualDisplay just outputs to the MediaCodec's input Surface then the flicker happens significantly less (happened one time in 50 or so minutes vs. flickering a few times a second periodically). The flickering also seems to happen in certain apps more so than other apps (Google Maps is a good culprit) or when certain UI appears/disappears in apps.
Anyone have have any ideas on what could cause the flickering in this scenario and only one some devices (that I've seen)? I can post some source code if that would be helpful.
EDIT: So, I've found that, on my Nexus 5x at least, if I go to "Developer Options" and enable "Disable HW Overlays" (the text says "Always use GPU for screen compositing") that the screen flicker goes away. Obviously this is a workaround, but I'd like to fix the issue programatically if at all possible.
We have a native Android webrtc-based voip app. Only in our Android app (as opposed to other platforms), the local camera stream is rotated after being in a call for a while. Usually it takes about 10 seconds. But sometimes more, even as much as a minute.
The remote will get the stream rotated as well, so it's not a rendering issue.
The stream is always rotated 90 degrees clockwise in portrait orientation, but is correct in one landscape orientation and upside down in the other landscape orientation.
After a while, the stream will be rotated back to the correct orientation again (and back to bugged after a while again).
I've tried several revisions ranging from early 8xxx to the latest (9125), all have the same problem. Apprtc demo has the problem as well. I've tested on several different phones (although only Samsung devices) and the problem exists on all of them.
I was faced with the same issue and I didn't found a right solution, but there is a workaround. I found that the reason of the rotation is cpu overuse detection, it leads to changing quality and it seems there is some bug in this functionality in android implementation. So I just added peerConnectionConstraints.optional.add(new MediaConstraints.KeyValuePair("googCpuOveruseDetection", "false"));
and it prevented this rotation.
I was trying to implement a burst mode camera in my app, which can take multiple pictures at the rate of 5-10(or more) snaps per second.
FYI I already saw the previous questions here, here and here - tried and failed with speed. Also the questions are old and there are no comprehensive answers addressing all the concerns like how to manage heap etc.
I would really appreciate if someone can help with useful pointers, best practice or maybe an SSCCE.
Update :
Tried successfully with pulling preview frames # 15+snaps/sec, but the
problem is preview size is limited. On nexus 5 I can get only
1920x1080 which is ~2mp, whereas the full resolution pic possible on
n5 is 8mp :-(
I think a big part of the problem is the question: How does burst mode work in current phones? A couple of blogs point out that Google has confirmed that they will be adding a burst mode API.
I suspect current implementations work by setting exposure time to minimum and calling takePicture in a loop or using Camera.PreviewCallback
I played around with the latter for some computer vision projects and happened to look into writing a burst mode camera using this API. You could store the buffers you receive from Camera.PreviewCallback in memory and process them on a background thread.
If I remember correctly, the resolution was lower than the actual camera resolution, so this may not ideal.
Short of device-specific APIs offered by their manufacturers, the only way you can get a "burst mode" that has a shot of working across devices will be to use the preview frames as the images. takePicture() has no guarantees of when you will be able to call takePicture() again.
I have made an app which works well on iOS but has performance problems on Android. I have noticed that on older devices such as galaxy s2 with a low screen resolution, the app is fine. It only lags on the new hd devices such as the galaxy s4 and nexus 4.
Are high screen resolutions causing the devices to lag?
Does anyone know what I can do to find out how to fix this?
It's really strange because it's only on the new devices.
Not sure why it is happening on the S4 since it has a decent CPU and GPU, but high-density screens will cause lag, especially in Flash-based apps. I ran into the same problems when trying to move from the iPad 2 to the retina displays.
Let's look at it this way, with regards to the iPad issue I had. The iPad 3 bumped the resolution from 1024x768 to 2048x1536. That is 4x as many pixels. Traditionally, Flash has issues rendering vector images. It is good at it, among the best, but it is slow. So rendering a vector object on the iPad 2 was only a 40x40 area to update. On the iPad 3, it is a 160x160 area to update.
Quick tips:
Never use CPU rendering. Stick to Direct (or GPU if you need to, but you lose features with GPU rendering, such as filters)
Decrease the amount of vectors being used and how often you are changing them. You should avoid, at all costs, updating vector objects every frame.
Make sure you are testing a release build (In Flash Builders, Project->Export Release Build...) when testing framerate issues. It is generally much more evident on the iOS side than the Android side, but debug builds do cause lag
Don't set the framerate higher than you have to. As the framerate goes higher, each frame has less time to run the necessary calculations. The lag you notice isn't truly from low framerates (though that doesn't help), but more from dropped frames when a frame takes longer than available to render. 24 is the default, 30 is the standard. 60 is the max and is always nice, but it is completely unnecessary unless you are making a game.
I have several apps in production right now that run just fine on my Nexus 5, which is the same resolution as the S4 with roughly the same hardware, spec-wise. Unless there is a problem with that hardware specifically, you should be able to manage 30fps no problem, if not 60.
use direct render mode it is recommended by adobe.
Description:
My OpenGL game runs fine on phones. However, after a couple of seconds of running on a tablet the 3D rendering goes all green. The 2D overlays (gl) are mostly fine.
This might be triggered by rotation, I can't be sure; no access to a tablet.
A user kindly recording it happening, which I have posted online:
http://www.youtube.com/watch?v=DRfDM673TRA
Questions:
Has anyone seen this before, or know of a possible cause/cure?
Also, can anyone confirm this is is still happening? (BB Rally Lite is free).
Other info:
The game is locked into landscape mode so I wouldn't expect it to do anything on rotation.
Update:
This was a bug in my code.
Tablets have a different default orientation,
which was triggering conditional (bugged) code that never got run on a phone.
The green screen was a result of the bug causing the model's matrix to contain nan (or inf, I can't recall).
If you suffer from a green screen I suggest you start by looking at your matrices.