1. Check out our app, Forums for Android! Download and leave feedback here!

ANR on drawPicture()???

Discussion in 'Application Development' started by ab11, Dec 1, 2010.

  1. ab11

    ab11 New Member
    Thread Starter
    5

    Dec 1, 2010
    1
    0
    5
    I have an application which displays a series of custom views in a LinearLayout. The LinearLayout is in a ScrollView. The custom views draw a picture, when their onDraw method is called. Generally this works fine. But occasionally the application causes an ANR on a drawPicture() call. Based on log statements, I'm positive that it is the drawPicture() method which is hanging, and producing the ANR. This is confusing, because the drawPicture() usually takes a few milliseconds.

    This is very confusing and frustrating. Any help would be greatly appreciated.

    The contents of traces.txt and my logcat are below:


    DALVIK THREADS:
    "main" prio=5 tid=3 NATIVE
    | group="main" sCount=1 dsCount=0 s=N obj=0x2aac2250 self=0x84d00
    | sysTid=412 nice=0 sched=0/0 cgrp=unknown handle=2130112448
    at android.graphics.Canvas.native_drawPicture(Native Method)
    at android.graphics.Canvas.drawPicture(Canvas.java:1404)
    at com.MyView.onDraw(PDFPageView.java:100)
    at android.view.View.draw(View.java:6534)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
    at android.view.View.draw(View.java:6537)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
    at android.view.View.draw(View.java:6537)
    at android.widget.FrameLayout.draw(FrameLayout.java:352)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
    at android.view.View.draw(View.java:6537)
    at android.widget.FrameLayout.draw(FrameLayout.java:352)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
    at android.view.View.draw(View.java:6537)
    at android.widget.FrameLayout.draw(FrameLayout.java:352)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
    at android.view.View.draw(View.java:6537)
    at android.widget.FrameLayout.draw(FrameLayout.java:352)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1849)
    at android.view.ViewRoot.draw(ViewRoot.java:1349)
    at android.view.ViewRoot.performTraversals(ViewRoot.java:1114)
    at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4325)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    at dalvik.system.NativeStart.main(Native Method)

    "AsyncTask #1" prio=5 tid=17 WAIT
    | group="main" sCount=1 dsCount=0 s=N obj=0x2e4262b0 self=0x351ab8
    | sysTid=420 nice=10 sched=0/0 cgrp=unknown handle=3480528
    at java.lang.Object.wait(Native Method)
    - waiting on <0x195468> (a java.lang.VMThread)
    at java.lang.Thread.parkFor(Thread.java:1535)
    at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
    at sun.misc.Unsafe.park(Unsafe.java:317)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
    at java.lang.Thread.run(Thread.java:1096)

    "Binder Thread #3" prio=5 tid=15 NATIVE
    | group="main" sCount=1 dsCount=0 s=N obj=0x2e3e9cc0 self=0x191798
    | sysTid=419 nice=0 sched=0/0 cgrp=unknown handle=1738736
    at dalvik.system.NativeStart.run(Native Method)

    "Binder Thread #2" prio=5 tid=13 NATIVE
    | group="main" sCount=1 dsCount=0 s=N obj=0x2e3e9c00 self=0x1a7510
    | sysTid=418 nice=0 sched=0/0 cgrp=unknown handle=1792360
    at dalvik.system.NativeStart.run(Native Method)

    "Binder Thread #1" prio=5 tid=11 NATIVE
    | group="main" sCount=1 dsCount=0 s=N obj=0x2e3e9b40 self=0x1aae60
    | sysTid=417 nice=0 sched=0/0 cgrp=unknown handle=1738512
    at dalvik.system.NativeStart.run(Native Method)

    "JDWP" daemon prio=5 tid=9 VMWAIT
    | group="system" sCount=1 dsCount=0 s=N obj=0x2e3e82a0 self=0x1b82a0
    | sysTid=416 nice=0 sched=0/0 cgrp=unknown handle=1792208
    at dalvik.system.NativeStart.run(Native Method)

    "Signal Catcher" daemon prio=5 tid=7 RUNNABLE
    | group="system" sCount=0 dsCount=0 s=N obj=0x2e3e81e8 self=0x1b9420
    | sysTid=415 nice=0 sched=0/0 cgrp=unknown handle=1791968
    at dalvik.system.NativeStart.run(Native Method)

    "HeapWorker" daemon prio=5 tid=5 VMWAIT
    | group="system" sCount=1 dsCount=0 s=N obj=0x2d68c4c8 self=0x1b9968
    | sysTid=413 nice=0 sched=0/0 cgrp=unknown handle=1792792
    at dalvik.system.NativeStart.run(Native Method)


    This is the logcat output:

    W/WindowManager( 53): Key dispatching timed out sending to com.mypackage/com.mypackage.MyActivity
    W/WindowManager( 53): Dispatch state: {{KeyEvent{action=1 code=82 repeat=0 met
    a=0 scancode=229 mFlags=8} to Window{4387d7f8 Keyguard paused=false} @ 129122478
    0532 lw=Window{4387d7f8 Keyguard paused=false} lb=android.view.ViewRoot$W@4387d4
    08 fin=false gfw=true ed=true tts=0 wf=false fp=false mcf=Window{4392eb90 com.mypackage
    s/com.mypackage.MyActivity paused=false}}}
    W/WindowManager( 53): Current state: {{null to Window{4392eb90 com.mypackage
    s/com.mypackage.MyActivity paused=false} @ 1291225159009 lw=Window{4
    392eb90 com.mypackage/com.mypackage.MyActivity paused=false} lb=an
    droid.os.BinderProxy@4392e9b8 fin=false gfw=true ed=true tts=0 wf=false fp=false
    mcf=Window{4392eb90
    com.mypackage/com.mypackage.MyActivity paused
    =false}}}
    I/ActivityManager( 53): ANR in process: com.mypackage
    (last in com.mypackage)
    I/ActivityManager( 53): Annotation: keyDispatchingTimedOut
    I/ActivityManager( 53): CPU usage:
    I/ActivityManager( 53): Load: 0.71 / 0.81 / 0.44
    I/ActivityManager( 53): CPU usage from 19028ms to 19ms ago:
    I/ActivityManager( 53): com.mypackage: 34% = 34% user + 0% kernel / f
    aults: 24 minor
    I/ActivityManager( 53): system_server: 2% = 1% user + 0% kernel / faults: 8
    minor
    I/ActivityManager( 53): com.android.phone: 0% = 0% user + 0% kernel
    I/ActivityManager( 53): adbd: 0% = 0% user + 0% kernel / faults: 72 minor
    I/ActivityManager( 53): TOTAL: 38% = 36% user + 2% kernel
    I/ActivityManager( 53): Removing old ANR trace file from /data/anr/traces.txt
    I/Process ( 53): Sending signal. PID: 514 SIG: 3
    I/dalvikvm( 514): threadid=7: reacting to signal 3
    I/dalvikvm( 514): Wrote stack trace to '/data/anr/traces.txt'
    I/Process ( 53): Sending signal. PID: 53 SIG: 3
    I/dalvikvm( 53): threadid=7: reacting to signal 3
    I/dalvikvm( 53): Wrote stack trace to '/data/anr/traces.txt'
    I/Process ( 53): Sending signal. PID: 96 SIG: 3
    I/dalvikvm( 96): threadid=7: reacting to signal 3
    I/dalvikvm( 96): Wrote stack trace to '/data/anr/traces.txt'
    I/Process ( 53): Sending signal. PID: 223 SIG: 3
    I/dalvikvm( 223): threadid=7: reacting to signal 3
    I/dalvikvm( 223): Wrote stack trace to '/data/anr/traces.txt'
    I/Process ( 53): Sending signal. PID: 140 SIG: 3
    I/dalvikvm( 140): threadid=7: reacting to signal 3
    I/dalvikvm( 140): Wrote stack trace to '/data/anr/traces.txt'
    I/Process ( 53): Sending signal. PID: 120 SIG: 3
    I/dalvikvm( 120): threadid=7: reacting to signal 3
    I/dalvikvm( 120): Wrote stack trace to '/data/anr/traces.txt'
    I/Process ( 53): Sending signal. PID: 172 SIG: 3
    I/dalvikvm( 172): threadid=7: reacting to signal 3
    I/dalvikvm( 172): Wrote stack trace to '/data/anr/traces.txt'
    I/Process ( 53): Sending signal. PID: 175 SIG: 3
    I/dalvikvm( 175): threadid=7: reacting to signal 3
    I/dalvikvm( 175): Wrote stack trace to '/data/anr/traces.txt'
    I/Process ( 53): Sending signal. PID: 94 SIG: 3
    I/dalvikvm( 94): threadid=7: reacting to signal 3
    I/dalvikvm( 94): Wrote stack trace to '/data/anr/traces.txt'
    W/WindowManager( 53): No window to dispatch pointer action 1
    W/WindowManager( 53): No window to dispatch pointer action 1
    W/WindowManager( 53): No window to dispatch pointer action 0
    W/WindowManager( 53): No window to dispatch pointer action 1
    D/dalvikvm( 53): GC freed 12498 objects / 629776 bytes in 174ms
     

    Advertisement

Share This Page

Loading...