I am investigating ways to improve performance in EditText, specifically in regards to load times. When loading large documents of a few thousand words or more, calling setText can freeze the UI for several seconds on some of my test devices and emulators.
In response, I have explored several possible solutions, none of which produce satisfactory results. I have tried to split large documents by paragraph, and load each paragraph into its own RecyclerView or ListView row. RecyclerView was completely hopeless due to a problem that causes jerky scrolling. ListView provided great, almost immediate, load times, and pretty good scrolling (although not as a good as one EditText block) but there is an issue where EditText blocks inside rows lose focus when selected. I have also attempted to update an EditText in sections from onProgressUpdate in an AsyncTask, hoping that the user could interact with the text as it loads in sections, but load times are largely unaffected.
The most promising avenue I have explored relates to changing the following element in AndroidManifest.xml:
android:hardwareAccelerated="false"
I got the idea after watching the following segment from this YouTube clip on the Google Developers channel. When I switched on GPU Profile rendering, I discovered that the orange bar (representing "process time") was rocketing every time setText was called. When I switched off hardware acceleration, setText performance increased massively, although other areas (like scrolling) became much worse.
What I would like to understand is - why is this happening? Also, is there a way that I can use this information to further increase performance? Can I toggle hardware acceleration off and on again programatically simply?
It's worth mentioning some devices, like a Nexus 7 2013 running API 22, don't suffer any issues whatsoever when calling setText on large documents, whereas others really struggle with hardware acceleration on. I just want to understand what's going on better so I can attempt to fix it! Thanks.
EDIT:
Here is a link to a GitHub Repository for anyone to download one of my sample test apps to replicate the problems I listed above. I also have three videos I posted on the site demonstrating these issues, which I shall mirror below:
I have made three video demonstrations that show this app running on a
Huawei Honor Holly running KitKat
4.4.2 with the hardwareAccelerated attribute set to true in the
AndroidManifest, then with the same phone with the same attribute
set to false, and a separate Nexus 7 (2013) running Lollipop
5.1 with hardware acceleration enabled. GPU Profiling is on in each case.
Honor Holly - Acceleration
On
Honor Holly - Acceleration
Off
Nexus 7 (2013) - Acceleration
On
Related
CSS' mix-blend-mode seems to fail on Android 9:
Chrome
Webview in Cordova (also Chrome in that case, probably)
It works on:
Chrome on Android 8
Firefox on Android 9
I initially experienced the issue with an SVG element, but I am also able to reproduce it with some simple divs.
A very simple code example:
https://codepen.io/walmink/pen/YoJRqa
I tried to run the example below and get the expected result on a Nexus 5 running Android 8 (left), but it fails on a OnePlus 6 phone running Android 9 (right) (see image). I've had other users (of a game of mine that uses mix-blend-mode) report the same issue on a OnePlus 7 and a Google Pixel 3a XL running Android 9.
It also seems to work fine on any desktop browser I've tried. On Safari, it will blend with the background as well unless you add isolation: isolate, but at least the blending still happens.
Thank you for tracking down that Chrome issue! I've been debugging this all day but missed that one. I'm on a OnePlus 6t. Someone else wasn't able to reproduce on a Pixel 2, but glad to hear it is in fact happening on other devices.
I have a workaround, which I'll also address in that Chromium thread, soon.
Option 1: Force hardware acceleration on the blended element, using something like transform: translate3d(0,0,0);
Option 2: On the blended element, add a will-change property, set to pretty much anything. will-change: opacity; for example, would suffice. This forced re-paint seems to be enough to kick the blend-mode back into gear.
Now, this fixes the problem... but causes another. If you have to do any scrolling more than about one more page length, the blended element will eventually get cut off, and will remain invisible for the rest of the page.
This behavior (or similar) is described here:
https://bugs.chromium.org/p/chromium/issues/detail?id=798148
This one sounds almost identical, but but is marked as fixed.
https://bugs.chromium.org/p/chromium/issues/detail?id=992398 This one also sounds similar, but they've identified as being related to the max size of a layer, which is fairly large (some 8000px). Whereas the behavior you'll find with this workaround, is more like 2000px, or roughly 200% of the height of the viewport (hard to test).
Unfortunately this cut off content behavior is very consistent... That Pixel 2 user I mentioned before, that couldn't reproduce the initial blend-mode issue, was seeing this cut off once the workarounds were applied.
You said you're making a game though, so hopefully there's not much scrolling involved?
Also, for what it's worth, you may find the screen blend mode is exempt from all this and may still work without any workarounds.
You can test with this https://codepen.io/chasebank/pen/wvwWGxd The workarounds are commented out in the .box element.
Good luck!
my first android game it's almost done, and I'm on the way to publish it on the play store.
Today I tested it on some friends phone and it worked on all except for a samung a5. On this phone the meshes flicker, apper and disapper and look deformed. This when playing game where I use a lot of frame buffer, in the main menu where there is a simpler animation everything look right.
The game is developed with libGdx and use some custom shader. I've tested it on 8 other different device without no issue (excepect for low frame rate on samsung galaxy tab s4).
I ask yours advise:
1) what should I start to check to find the problem with a5?
2) do you think I should delay the publication until the bug it's solved ora I should publish it excluding A5 ( or maybe all devices with similar GPU) from compatibility list?
My big problem is that at the moment I don't have the device with me (it's the personal phone of a friend of mine...) and probably I will have it for only a limited amount of time, so I want to be preparated to avoid to lock the device for too much time to my friend.
Thanks to all!
First, I'd make sure you don't have any OpenGL errors - add calls to glGetError and validate frame buffers and shader programs, you can do this without the device and adding extra asserts like this is always worthwhile (assuming you don't already have them). Next, try using the tools provided by the GPU manufacturer. In your case the snapdragon profiler. To minimize the time you'll be using your friends device, get the tools installed ahead of time and if you have access to another Qualcomm device, then use that to familiarize yourself with the software. With luck the cause of problem might become immediately obvious. If not, then it's just a binary search of disabling parts of your code until you narrow it down to a particular shader/draw call, then examine/tweak that to figure out what bit is going wrong.
That's a tough call. If it's a driver bug, then it might only occur on particular revisions. Some A5 devices might work if they're on different versions of Android from your friends device. That said, the A5 is relatively recent and Samsung/Qualcomm drivers tend to be pretty solid IME, so it's more likely an error in your code that happens to only be exposed on certain devices. Personally I would delay release unless your release strategy is timing sensitive, from the limited data you have, your game doesn't work on >10% of devices.
Just wanted to share an experience I had to see if anyone came across such issue, if they found the cause and more importantly how they fixed it.
The problem is pretty simple: while debugging native code on a Nexus 6, which as the Adreno 420 GPU, eglSwapBuffer could crash under certain circumstances when using Android 5.1 (5.0 worked perfectly).
Since I could not repro it I am unable to tell you what went wrong. According to the documentation, elgSwapBuffer calls internally glFlush; and so if I call glFlush before calling eglSwapBuffer all of a sudden it works perfectly.
My guess is that the driver does not flush properly thus crashing when swaping the buffers.
Any comments on this?
Cheers,
D
I'm having the same problem and I can reproduce it. It happens obviously because it runs out of stack memory due to deep nested loops in the rendering process.
Android Lollipop 5.1: Fatal signal 11 (SIGSEGV), code 2, fault addr 0x9e985ff8 in tid 4093 (RenderThread) / when using lot of nine patch graphics
I've already reported it to the google issue tracker:
https://code.google.com/p/android/issues/detail?id=163100
Update: Meanwhile I found a way to work around this issue. It's definitely not a long time solution, but for the moment, it's just the best available to stop my apps from crashing.
I disabled GPU rendering for particular graphic layers. It slows the drawing down a bit, but not significant.
So the nightmare is over for now, but I still think, this issue must be fixed on the driver itself. It cannot be that something that worked perfect with 5.0.2 and below, immediately stops to work with 5.1.
I have seen some weird behavior on the N6 as well, and while I cannot rule out app bugs, it looks to me like the Adreno driver is to blame.
Specifically, in landscape mode, our GLSurfaceView only renders one half of it's content, but occasionally flickers all of it. And with certain scenes being rendered there is intermittent flickering. In a case of extra weirdness, I have seen one half of the screen completely freeze, stuck on app content, even after returning to the launcher via the home button. It appears kind of like it would if it used multi stream transport and one of the streams was getting lost.
I developed and tested an app on Android 3.2, it interacts with the SQLite database and show the results on the screen. I don't have animations or anything fancy. What I do have is a lot of ListViews to show data to the user.
The database for the app is very big, with somes tables having more than 300k rows. We tried to use AsyncTask in every interaction with the database, but there are some points we still have to optimize the performance.
The problem is that the company updated some of the tablets to Ice Cream Sandwich and the app is much slower than it was on Honeycomb. I loaded the same code, with the same db, in two devices, one running ICS and the other with Honeycomb. The app performed much better in the 3.2 device. I also tried using <uses-sdk android:minSdkVersion="14" /> but it didn't do better.
Is there anything I could do to optimize the performance on the 4.0? I also would love to know why this happened and if there's anything that could have caused that (some component or class that doesn't work that well on 4.0).
Thanks!
UPDATE: I found the solution for the main screen of my app. I was presenting a fragment that worked as a horizontal list, it was a HorizontalScrollView that loaded a huge list of data and created a lot of LinearLayout to be presented inside the ScrollView. I found a widget of a HorizontalListView and used it to load my list. Just that made the app faster. But I didn't find the answer to why it was slower on the ICS.
I also tried profiling the app, but it is a very hard thing to do, there's lot of information. I'll probably still do that in the next weeks to speed up the application. Thank you for all the answers and comments!
My guess is it is related to hardware acceleration which is default enabled for ice cream sandwich. Hardware acceleration is nice but it sometimes comes with a performance decline.
There is another interesting read about android hardware acceleration by Dianne Hackborn on google+ I'd recommend you to look at.
We're developing a custom Android application built for a specific Android -- formerly the Samsung Galaxy Tab 2 -- and I was pretty happy with the way it looked.
However, we've changed phones to the Nexus 7, and now a Text View that used to look fine blinks rapidly -- it's seizure inducing. My application updates the text a few times a second, but that's not new and we never had this problem with the Samsung.
Has anybody experienced something similar, or otherwise have a suggestion?? My original suspicion that the Samsung had more processor power is, I'm pretty sure, incorrect. Should I look into some of the Nexus' configuration details concerning rendering the GPU??
It's going to be annoying if have to get rid of this software feature, but I might have to if I can't improve the look.
It's not a great answer, but it does work for me if I set up my code to only update the text view every other trip through the draw loop. If anyone else has a different suggestion I'd certainly prefer to try something else, but this at least works.