1

I have a pretty big app that I am working on. Sometimes when I start it on 2.3 devices, the UI thread gets somehow stuck. I don't think it is one of my own tasks, but I just cannot figure out what it is. Is there any way that I can figure out what exact task is currently running in the UI Thread?

More info: I'm running a Runnable on a Handler that uses the main Looper at some point, but run() never gets executed in those cases. I also get an ANR when I touch the screen then. I assume it must be related to the memory in some way because when I remove one of the background images, it feels like it gets stuck less. I do not get an OOM exception though.

Edit

I enabled logging for the main Looper. The last task that gets dispatched has what=1004. This is definitely not from me.

Looper: >>>>> Dispatching to Handler{406cbec0} null: 1004
SimonSays
  • 10,867
  • 7
  • 44
  • 59
  • Are you updating the UI from a secondary thread? – Cata Dec 08 '14 at 19:58
  • Not that I would know of. I enabled strict mode, I think that would notify me. – SimonSays Dec 08 '14 at 19:59
  • Well in my opinion you either do something heavy on the main thread or some networking/db calls or you are updating the UI from a secondary thread but then the app would crash in most of the cases. If you need more help, please post some code of your activity here :) – Cata Dec 08 '14 at 20:07
  • If this happens only on one screen, post the activity/fragment code. That will help get an answer to your question. – Flynn81 Dec 08 '14 at 20:09
  • As I said, the app is pretty big and i would not know which parts of the code to post. There is no heavy lifting on the UI thread though. I suspect some internal Android UI building method or so. – SimonSays Dec 09 '14 at 00:02

1 Answers1

0

Sorry for posting as answer (Not enough points for comment) but I believe naming your AsyncTasks and Threads and then using DDMS or any other Android profiling tool could possibly help solve your problem.

By figuring out the most performance/time consuming methods and threads, or possibly something that is overloading the memory (Examine the heap using DDMS).

Take a look at the following links:

http://developer.android.com/tools/debugging/ddms.html http://developer.android.com/tools/debugging/debugging-tracing.html

Sorry if this wasn't any help.

Display name
  • 1,761
  • 2
  • 14
  • 16
  • The problem is that I've exceeded the dex method count and cannot run the app on older Android versions without stripping it first with proguard. So memory dump or method profileing pretty much is no option. – SimonSays Dec 09 '14 at 00:00