7

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

PPartisan
  • 8,173
  • 4
  • 29
  • 48
  • You may wish to toss together a small sample app that demonstrates the phenomenon, then link to it from here. – CommonsWare Apr 27 '15 at 23:41
  • @CommonsWare I've added one of my test apps and a few videos of me using said app, to demonstrate the effects of calling `settext()` on a large file, and the effects on switching HW Acceleration on and off. – PPartisan Apr 29 '15 at 16:36
  • 1
    Oh, well, clearly your problem is too much alliteration in your device's name. :-) I'll try to give this a shot and see what I see. – CommonsWare Apr 29 '15 at 16:38
  • I cannot reproduce your problem on an HTC One M7 or a Samsung Galaxy Note 3 (SM-N900), both running 4.4. Both load the text in ~1 second and scroll fine thereafter. My best guess is that the problem is tied to the GPU used by your HHH, as the Mali-400mp2 seems to be [popular on lower-end devices](http://www.phonebunch.com/phone-filter/gpu/mali-400mp2/). I don't have a device with that GPU, though I may pick one up for testing purposes. – CommonsWare Apr 29 '15 at 18:32
  • @CommonsWare Thank you for testing it. It's at least encouraging to know the problem is somewhat isolated. – PPartisan Apr 29 '15 at 18:57
  • 1
    @PPartisan Have you found a good solution to this performance issue? My editor struggles to keep up after only 300 lines, and I see those editing apps with rocking performance after 30k lines, there has to be a simple fix... – Nicolas Dec 25 '16 at 04:10
  • anyone found anything new about this issue? – Alberto M Aug 24 '21 at 13:24

0 Answers0