Today I fixed finally the rendering performance of the map. The map renders in a textview and to get colored tiles I added HTML spans with colors and loaded the whole map as a HTML into the textview. I read on the internet that HTMLÂ in a textview, with many applied styles, has a huge impact on the CPU because the whole content goes through a XML WebKit parser. That’s wasting of precious time we don’t have, so one solution is to use Androids spannable strings instead, which apply only basic styling for a text.
It took me some time to adjust and cleanup the renderer and after a short time I got things up and running again. Unfortunately, there wasn’t a huge performance boost as I expected – from 2 seconds to 0.4 seconds for the whole map. Obviously something else is wrong, so I added log messages with timers for each block of code in the rendering function. There was a huge bug; for every tile I was going through the whole map, reseting all tiles to hidden by default. I added this for FOV purposes, but it was also used when the FOV option is disabled, and after all, it’s called totally at the wrong place. With that fixed now the whole map is rendered in 0.04 seconds.
I’m so glad also that I got rid of this HTML WebKit parser.
