....warning, long rambling description follows, I'm very confused
about this bug and am not totally sure I'm doing stuff correctly...


I've been able to lock the screen twice with the current
implementation of the app I'm writing (MediaDroid).  It's very
inconsistently (2 out of about 100 runs) and I'm not sure how to
trigger it, so I'm assuming it's some sort of race condition or the
number of threads I'm spawning.

The activity I'm working on loads a gallery of thumbnails from the
sdcard.  I believe I'm using most of the best practices described by
Romain Guy from his Google I/O talk "Make your Android UI Fast and
Efficient".  I've implemented an image cache with SoftReferences
wrapping my Bitmaps and created an Efficient Adapter for the gallery
using the ViewHolder pattern.

What I am doing, which I question, is loading each image via a thread
as it is retrieved from the ImageCache...I pass back a default image
if the bitmap is null, then update the default image in the ImageViews
with the Bitmap is loaded from the sdcard; I'm doing this by posting
to a Handler in the Adapter from the thread that loads the image.

So as you can imagine a number of threads are created, about 25 at a
time, as the user swipes through the image gallery.  Once the user
reaches the end of the gallery, the images are only reloaded if the
garbage collector has collected them due to the SoftReference.  I've
been impressed by how well this worked....until the bug mysteriously
started appearing.  What has happened both times is, all the images in
the gallery show the default images, then I get an ANR and with the
force close or wait option, I hit force close and the ANR dialog
shrinks (but doesn't go away) and the background goes black...then
everything just freezes...here's the logs where I believe things start
to lock up.

  6052        EftImageAdapter  D  load img 
content://media/external/images/thumbnails/27
  6052        EftImageAdapter  D  load img 
content://media/external/images/thumbnails/24
  6052        EftImageAdapter  D  load img 
content://media/external/images/thumbnails/25
  6052        EftImageAdapter  D  load img 
content://media/external/images/thumbnails/20
  6052        EftImageAdapter  D  load img 
content://media/external/images/thumbnails/19
  6052        EftImageAdapter  D  load img 
content://media/external/images/thumbnails/18
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
   60         ActivityManager  W  Timeout of broadcast BroadcastRecord
{43398278 android.intent.action.SERVICE_STATE} -
receiver=android.os.binderpr...@4351e850
   60         ActivityManager  W  Receiver during timeout: ResolveInfo
{433dbad0 com.android.mms.transaction.SmsReceiver p=0 o=0 m=0x108000}
   60                 Process  I  Sending signal. PID: 6137 SIG: 9
   60         ActivityManager  I  Start proc com.tmobile.myfaves for
broadcast com.tmobile.myfaves/.receivers.PhoneStateReceiver: pid=6178
uid=10008 gids={3003}
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
  6178               dalvikvm  I  Debugger thread not active, ignoring
DDM send (t=0x41504e4d l=38)
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
  6052   urfaceComposerClient  W  lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x41f240a0, state=00000043 (was 00000043)
   60           WindowManager  W  Key dispatching timed out sending to
com.mgm.android.mediadroid/com.mgm.android.mediadroid.ImagePicker
   60           WindowManager  W  Dispatch state: {{KeyEvent{action=1
code=82 repeat=0 meta=0 scancode=139 mFlags=8} to Window{4328c380
com.mgm.android.mediadroid/com.mgm.android
                                  .mediadroid.ManageAlbumsActivity
paused=false} @ 1252709278176 lw=Window{4328c380
com.mgm.android.mediadroid/com.mgm.android.mediadroid.ManageAl
                                  bumsActivity paused=false}
lb=android.os.binderpr...@4339b398 fin=false gfw=true ed=true tts=0
wf=false fp=false mcf=Window{432e41f8 com.mgm.and
                                  roid.mediadroid/
com.mgm.android.mediadroid.ImagePicker paused=false}}}
   60           WindowManager  W  Current state:  {{null to Window
{432e41f8 com.mgm.android.mediadroid/
com.mgm.android.mediadroid.ImagePicker paused=false} @ 1252709307050
lw=Win
                                  dow{432e41f8
com.mgm.android.mediadroid/com.mgm.android.mediadroid.ImagePicker
paused=false} lb=android.os.binderpr...@432e93c0 fin=false gfw=tr
                                  ue ed=true tts=0 wf=false fp=false
mcf=Window{432e41f8 com.mgm.android.mediadroid/
com.mgm.android.mediadroid.ImagePicker paused=false}}}
   60         ActivityManager  I  ANR (application not responding) in
process: com.mgm.android.mediadroid
   60         ActivityManager  I  Annotation: keyDispatchingTimedOut
   60         ActivityManager  I  CPU usage:
   60         ActivityManager  I  Load: 4.32 / 4.01 / 3.69
   60         ActivityManager  I  CPU usage from 5618ms to 64ms ago:
   60         ActivityManager  I    system_server: 1% = 0% user + 0%
kernel
   60         ActivityManager  I    kondemand/0: 0% = 0% user + 0%
kernel
   60         ActivityManager  I    zygote: 0% = 0% user + 0% kernel
   60         ActivityManager  I   +<pre-initialized>: 0% = 0% user +
0% kernel
   60         ActivityManager  I   +<unknown>: 0% = 0% user + 0%
kernel
   60         ActivityManager  I  TOTAL: 3% = 1% user + 1% kernel
   60         ActivityManager  I  Removing old ANR trace file from /
data/anr/traces.txt
   60                 Process  I  Sending signal. PID: 6137 SIG: 3
   60                 Process  I  Sending signal. PID: 6128 SIG: 3

If I press on the screen I get nothing on the device, but in the logs
I get

   60           WindowManager  W  No window to dispatch pointer action
0
   60           WindowManager  W  No window to dispatch pointer action
1
   60           WindowManager  W  No window to dispatch pointer action
0
   60           WindowManager  W  No window to dispatch pointer action
1


and I have to power down the device.

So if the number of threads is the problem I'm thinking of loading all
the bitmaps when the app is first initiated, probably using the
AsyncTask class.  A question I have though about this is that the docs
say that you can only call execute() once...what's happens if some of
my Bitmaps are garbage collected??  Do I then call individual threads
to reload?  I've looked through some of the Google apps, Shelves and
Photostream, but they don't seem to be using Bitmaps wrapped in
SoftReferences.

Any suggestions on any of this would be greatly appreciated...sorry
for the super long post, but again, I'm not even sure if I'm touching
on the bug.

THANKS!!
- michael
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to