I wrote a metronome and used a KK phone for testing purpose during developement. Now that the app seems ready, I tested it on every Android/CyanogenMod version I could get on my test device (from GB to MM). The app is reliable and can't be crashed by normal use on JB and newer but exhibit and strange behaviour on ICS and older (see belove). Since Android is retro compatible and the min-sdk=9 in manifest (and my app is only using lvl API 1) I looks weird to me.
Details: I have a big start/stop button that toggle the main loop. The main loop produce the "tics" (through audioTrack) and is run in a separated task. A flag is used in the main activity to keep the current state (started or stopped) so that you can't "start" twice or "stop" twice, only do start/stop/start/stop/etc... cycles. The main loop, the task and the AudioTrack are set or unset accordingly.
Problem:
If I smash the start/stop several times in ICS (and older), app is closed without the Toast The application Metronome as stopped unexpectidly etc...
.
Here is the logcat wich doesn't tell much to me:
<-- Application launched -->
I/ActivityManager( 247): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.arnaud.metronome/.Metronome bnds=[83,242][157,321] } from pid 347
D/dalvikvm( 247): GC_EXTERNAL_ALLOC freed 205K, 45% free 4761K/8583K, external 2482K/2497K, paused 50ms
I/ActivityManager( 247): Start proc com.arnaud.metronome for activity com.arnaud.metronome/.Metronome: pid=919 uid=10045 gids={}
D/szipinf ( 919): Initializing inflate state
D/dalvikvm( 919): GC_EXTERNAL_ALLOC freed 47K, 51% free 2685K/5379K, external 0K/0K, paused 28ms
W/System.err( 919): java.io.FileNotFoundException: /data/data/com.arnaud.metronome/files/structures (No such file or directory)
W/System.err( 919): at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
W/System.err( 919): at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
W/System.err( 919): at java.io.FileInputStream.<init>(FileInputStream.java:80)
W/System.err( 919): at android.app.ContextImpl.openFileInput(ContextImpl.java:432)
W/System.err( 919): at android.content.ContextWrapper.openFileInput(ContextWrapper.java:152)
W/System.err( 919): at com.arnaud.metronome.StructureContainer.loadFromInternal(StructureContainer.java:201)
W/System.err( 919): at com.arnaud.metronome.Metronome.onCreate(Metronome.java:81)
W/System.err( 919): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
W/System.err( 919): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
W/System.err( 919): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
W/System.err( 919): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
W/System.err( 919): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
W/System.err( 919): at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 919): at android.os.Looper.loop(Looper.java:130)
W/System.err( 919): at android.app.ActivityThread.main(ActivityThread.java:3835)
W/System.err( 919): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 919): at java.lang.reflect.Method.invoke(Method.java:507)
W/System.err( 919): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
W/System.err( 919): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
W/System.err( 919): at dalvik.system.NativeStart.main(Native Method)
W/InputMethodManager( 919): Ignoring onBind: cur seq=66, given seq=65
I/ActivityManager( 247): Displayed com.arnaud.metronome/.Metronome: +674ms
<-- Application fully launched. Commencing spamming the button -->
D/dalvikvm( 919): GC_FOR_MALLOC freed 243K, 50% free 2841K/5575K, external 162K/543K, paused 16ms
D/AudioHardwareMSM7X30( 175): value of device and enable is 6 1
D/AudioHardwareMSM7X30( 175): msm_route_stream(PCM_PLAY, 5, 15, 1)
D/AudioHardwareMSM7X30( 175): addToTable (dec_id 5, dev_rx 6, dev_tx 65535, type 1, active 1)
D/dalvikvm( 919): GC_CONCURRENT freed 270K, 49% free 3010K/5831K, external 162K/543K, paused 3ms+2ms
D/dalvikvm( 547): GC_EXPLICIT freed 6K, 47% free 3350K/6279K, external 2481K/3099K, paused 26ms
D/dalvikvm( 919): GC_CONCURRENT freed 472K, 51% free 2973K/6023K, external 162K/543K, paused 1ms+2ms
D/dalvikvm( 919): GC_CONCURRENT freed 434K, 51% free 2973K/6023K, external 162K/543K, paused 2ms+2ms
D/dalvikvm( 919): GC_CONCURRENT freed 434K, 51% free 2973K/6023K, external 162K/543K, paused 2ms+2ms
D/dalvikvm( 919): GC_CONCURRENT freed 434K, 51% free 2974K/6023K, external 162K/543K, paused 2ms+3ms
D/dalvikvm( 919): GC_CONCURRENT freed 434K, 51% free 2974K/6023K, external 162K/543K, paused 2ms+2ms
D/dalvikvm( 919): GC_CONCURRENT freed 434K, 51% free 2974K/6023K, external 162K/543K, paused 2ms+2ms
D/dalvikvm( 919): GC_CONCURRENT freed 348K, 50% free 3060K/6023K, external 162K/543K, paused 2ms+2ms
D/dalvikvm( 919): GC_FOR_MALLOC freed 434K, 53% free 2845K/6023K, external 162K/543K, paused 32ms
D/dalvikvm( 919): GC_CONCURRENT freed 173K, 49% free 3103K/6023K, external 158K/543K, paused 2ms+2ms
D/dalvikvm( 919): GC_FOR_MALLOC freed 433K, 53% free 2888K/6023K, external 162K/543K, paused 18ms
<-- Crash start here -->
I/DEBUG ( 914): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 914): Build fingerprint: 'SEMC/ST17i_1249-6227/ST17i:2.3.4/4.0.2.A.0.42/j_b_3w:user/release-keys'
I/DEBUG ( 914): pid: 919, tid: 932 >>> com.arnaud.metronome <<<
I/DEBUG ( 914): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 312e9000
I/DEBUG ( 914): r0 312e9000 r1 00000080 r2 00000000 r3 317f1a50
I/DEBUG ( 914): r4 312e9000 r5 312e9000 r6 00000000 r7 317f1a50
I/DEBUG ( 914): r8 6904cb94 r9 ffffff92 10 00000000 fp 000003e8
I/DEBUG ( 914): ip 690610bc sp 317f1a18 lr 6fd11724 pc 6fd113fc cpsr 200f0010
I/DEBUG ( 914): d0 643a64696f72646e d1 6472656767756265
I/DEBUG ( 914): d2 0000000000000000 d3 0000000000000000
I/DEBUG ( 914): d4 0000000000000000 d5 0000000000000000
I/DEBUG ( 914): d6 0000000000000000 d7 0000000000000000
I/DEBUG ( 914): d8 000000003b9aca00 d9 0000000000000000
I/DEBUG ( 914): d10 3fb8129d00000000 d11 0000000000000000
I/DEBUG ( 914): d12 0000000000000000 d13 0000000000000000
I/DEBUG ( 914): d14 0000000000000000 d15 0000000000000000
I/DEBUG ( 914): d16 0000000000000000 d17 3ff0000000000000
I/DEBUG ( 914): d18 3fc5555555555549 d19 bf4b3f057997ac2a
I/DEBUG ( 914): d20 3e707186c2887fc1 d21 be5ae5839fe26830
I/DEBUG ( 914): d22 bc5abb2580000000 d23 3de5d93a5acfd57c
I/DEBUG ( 914): d24 0000000000000000 d25 ffffffffffffffff
I/DEBUG ( 914): d26 0000000000000000 d27 ffffffffffffffff
I/DEBUG ( 914): d28 0100010001000100 d29 4049000000000000
I/DEBUG ( 914): d30 4049000000000000 d31 3ff0000000000000
I/DEBUG ( 914): scr 20000010
I/DEBUG ( 914):
I/DEBUG ( 914): #00 pc 000113fc /system/lib/libc.so (pthread_mutex_lock)
I/DEBUG ( 914): #01 pc 00011720 /system/lib/libc.so (__pthread_cond_timedwait_relative)
I/DEBUG ( 914): #02 pc 0002d7b8 /system/lib/libmedia.so
I/DEBUG ( 914):
I/DEBUG ( 914): code around pc:
I/DEBUG ( 914): 6fd113dc e3a02001 ebfffe82 e1a00005 e8bd87f0
I/DEBUG ( 914): 6fd113ec 00035fc4 e92d47f0 e2504000 0a000019
I/DEBUG ( 914): 6fd113fc e5946000 e5947000 e2166903 1a000017
I/DEBUG ( 914): 6fd1140c e5945000 e1a02004 e2055a02 e1a00005
I/DEBUG ( 914): 6fd1141c e3851001 ebffed67 e3500000 13856002
I/DEBUG ( 914):
I/DEBUG ( 914): code around lr:
I/DEBUG ( 914): 6fd11704 e1a03007 e1a02006 e2011001 e1a00004
I/DEBUG ( 914): 6fd11714 ebfffd9a e1a04000 e1a00005 ebffff32
I/DEBUG ( 914): 6fd11724 e374006e 03a0006e 13a00000 e8bd81f0
I/DEBUG ( 914): 6fd11734 e304cdd3 e3043240 e92d4010 e341c062
I/DEBUG ( 914): 6fd11744 e1a0e002 e24dd008 e340300f e1a0200d
I/DEBUG ( 914):
I/DEBUG ( 914): stack:
I/DEBUG ( 914): 317f19d8 00000000
I/DEBUG ( 914): 317f19dc 00000000
I/DEBUG ( 914): 317f19e0 00000000
I/DEBUG ( 914): 317f19e4 0000ee6b
I/DEBUG ( 914): 317f19e8 0000ee6b
I/DEBUG ( 914): 317f19ec 6fd0fe54 /system/lib/libc.so
I/DEBUG ( 914): 317f19f0 00000000
I/DEBUG ( 914): 317f19f4 00000000
I/DEBUG ( 914): 317f19f8 00000000
I/DEBUG ( 914): 317f19fc 00000000
I/DEBUG ( 914): 317f1a00 00000000
I/DEBUG ( 914): 317f1a04 3b9aca00
I/DEBUG ( 914): 317f1a08 00000000
I/DEBUG ( 914): 317f1a0c 3b9aca00
I/DEBUG ( 914): 317f1a10 00000000
I/DEBUG ( 914): 317f1a14 6904cb94 /system/lib/libmedia.so
I/DEBUG ( 914): #00 317f1a18 ffffff92
I/DEBUG ( 914): 317f1a1c 312e9000
I/DEBUG ( 914): 317f1a20 00000000
I/DEBUG ( 914): 317f1a24 317f1a50
I/DEBUG ( 914): 317f1a28 6904cb94 /system/lib/libmedia.so
I/DEBUG ( 914): 317f1a2c ffffff92
I/DEBUG ( 914): 317f1a30 00000000
I/DEBUG ( 914): 317f1a34 6fd11724 /system/lib/libc.so
I/DEBUG ( 914): #01 317f1a38 312e9000
I/DEBUG ( 914): 317f1a3c 312e9004
I/DEBUG ( 914): 317f1a40 317f1af0
I/DEBUG ( 914): 317f1a44 fffffffe
I/DEBUG ( 914): 317f1a48 6904cb94 /system/lib/libmedia.so
I/DEBUG ( 914): 317f1a4c 6902d7bb /system/lib/libmedia.so
D/dalvikvm( 919): GC_FOR_MALLOC freed 434K, 53% free 2888K/6023K, external 162K/543K, paused 31ms
D/dalvikvm( 919): GC_CONCURRENT freed 173K, 52% free 2931K/6023K, external 158K/543K, paused 2ms+12ms
I/BootReceiver( 247): Copying /data/tombstones/tombstone_00 to DropBox (SYSTEM_TOMBSTONE)
W/AudioTrack( 919): obtainBuffer timed out (is the CPU pegged?) 0x17c230 user=00010554, server=000079e0
I/DEBUG ( 914): debuggerd committing suicide to free the zombie!
I/DEBUG ( 944): debuggerd: Jun 15 2012 20:09:09
D/dalvikvm( 247): GC_FOR_MALLOC freed 533K, 43% free 4922K/8583K, external 870K/1382K, paused 33ms
I/WindowManager( 247): WIN DEATH: Window{2b270d18 com.arnaud.metronome/com.arnaud.metronome.Metronome paused=false}
I/ActivityManager( 247): Process com.arnaud.metronome (pid 919) has died.
D/Zygote ( 174): Process 919 terminated by signal (11)
<-- App is closed here, We are now back to the launcher -->
W/InputManagerService( 247): Got RemoteException sending setActive(false) notification to pid 919 uid 10045
D/AudioHardwareMSM7X30( 175): AudioStreamOutMSM72xx::standby()
D/AudioHardwareMSM7X30( 175): Deroute pcm out stream
D/AudioHardwareMSM7X30( 175): deleteFromTable, type 1
D/AudioHardwareMSM7X30( 175): updateDeviceInfo: E rx_device 6 and tx_device 11
D/AudioHardwareMSM7X30( 175): No active voicecall/playback, disabling cur_rx 6
D/AudioHardwareMSM7X30( 175): value of device and enable is 6 0
D/AudioHardwareMSM7X30( 175): No active voicecall/recording, disabling cur_tx 11
D/AudioHardwareMSM7X30( 175): value of device and enable is 11 0
D/AudioHardwareMSM7X30( 175): updateDeviceInfo: X cur_rx 6 cur_tx 11
I am trying to subscribe to f-droid and could update the gitlab if someone wants to have a closer look.