It's been a delightful (Narrator's voice: it has not been delightful) three days trying to get one little screen update to work. One of the things I needed to get improved was the front loading screen. And, I thought the simplest way to make it not feel like it was just hanging for 10 seconds, was to show what it was doing. Simple. (Narrator's voice: it should have been simple).
So I set up some extra update script, to show what was happening. And it didn't do anything, till it was finished. Ten seconds later. Then it showed that it was in fact, complete. (Narrator's voice: Called it)
That was about two days and twenty three hours ago.
Since then, I've been scratching my head trying to work out why a simple update, that, using logging, was telling me black and blue that it was updating perfectly well, wasn't updating perfectly well at all.
And look, this is once again, one of those "If you know, you know..." things. But it turns out that, yet again (Narrator's voice: There's a lot of swearing not being typed here) Threads aren't as simple as you might think. And in this case, they are, but a particular Android queue that I have set up in my low-priority-background thread... does everything as the highest possible priority. It doesn't make anything like that obvious, it just does. And when I went through the docs (Narrator's voice: You know things are desperate when you start reading those) that it runs the response on the UI thread (That's Android's highest bestest most importantest thread) JUST IN CASE there are some UI updates to perform.
So. Once that penny dropped in my head (Narrator's voice: Like I said, when you know, you know) I was able to solve the update issue, but much more importantly, a whole bunch of other issues that caused lag in the app, that had always been there, but I didn't know why at all. They weren't game breakers, but certainly were noticeable if you were looking for them. And now, by being able to actually push all the background tasks to the background, it's running much better.
No comments:
Post a Comment