Quantcast
Viewing all articles
Browse latest Browse all 8068

Using Sound objects in Android app causes Java Exception and Crash on App Exit

I'm developing a mobile android app that creates several Ti.Media.Sound objects on startup and uses them to play sound effects... I use the sound objects in a straightforward way (I call stop() and play() on them during the app's execution). When the main window of the app closes, the app often crashes with an "Unfortunately ... has quit" dialogue message and this appearing in the terminal log output:

[WARN]  dalvikvm: threadid=28: thread exiting with uncaught exception (group=0xb1a18ba8)
[ERROR] TiApplication: (Timer-28) [46093,46093] Sending event: exception on thread: Timer-28 msg:java.lang.IllegalStateException; Titanium 3.2.3,2014/04/22 10:17,b958a70
[ERROR] TiApplication: java.lang.IllegalStateException
[ERROR] TiApplication:  at android.media.MediaPlayer.isPlaying(Native Method)
[ERROR] TiApplication:  at ti.modules.titanium.media.TiSound$2.run(TiSound.java:516)
[ERROR] TiApplication:  at java.util.Timer$TimerImpl.run(Timer.java:284)
[DEBUG] Window: Window is closed normally.
When I fire up ddms, the output there looks like this:
05-10 17:47:20.185: E/SoundPool(373): error loading /system/media/audio/ui/Effect_Tick.ogg
05-10 17:47:20.185: W/AudioService(373): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
05-10 17:47:20.185: E/SoundPool(373): error loading /system/media/audio/ui/Effect_Tick.ogg
05-10 17:47:20.185: W/AudioService(373): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
05-10 17:47:20.185: E/SoundPool(373): error loading /system/media/audio/ui/Effect_Tick.ogg
05-10 17:47:20.185: W/AudioService(373): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
05-10 17:47:20.195: E/SoundPool(373): error loading /system/media/audio/ui/Effect_Tick.ogg
05-10 17:47:20.205: W/AudioService(373): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
05-10 17:47:20.205: E/SoundPool(373): error loading /system/media/audio/ui/Effect_Tick.ogg
05-10 17:47:20.205: W/AudioService(373): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
05-10 17:47:20.205: E/SoundPool(373): error loading /system/media/audio/ui/KeypressStandard.ogg
05-10 17:47:20.215: W/AudioService(373): Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg
05-10 17:47:20.215: E/SoundPool(373): error loading /system/media/audio/ui/KeypressSpacebar.ogg
05-10 17:47:20.215: W/AudioService(373): Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg
05-10 17:47:20.245: E/SoundPool(373): error loading /system/media/audio/ui/KeypressDelete.ogg
05-10 17:47:20.245: W/AudioService(373): Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg
05-10 17:47:20.245: E/SoundPool(373): error loading /system/media/audio/ui/KeypressReturn.ogg
05-10 17:47:20.255: W/AudioService(373): Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
05-10 17:47:20.255: E/SoundPool(373): error loading /system/media/audio/ui/KeypressInvalid.ogg
05-10 17:47:20.255: W/AudioService(373): Soundpool could not load file: /system/media/audio/ui/KeypressInvalid.ogg
05-10 17:47:20.265: W/AudioService(373): onLoadSoundEffects(), Error -1 while loading samples
05-10 17:47:20.445: W/dalvikvm(2004): threadid=28: thread exiting with uncaught exception (group=0xb1a18ba8)
05-10 17:47:20.475: E/TiApplication(2004): (Timer-28) [46093,46093] Sending event: exception on thread: Timer-28 msg:java.lang.IllegalStateException; Titanium 3.2.3,2014/04/22 10:17,b958a70
05-10 17:47:20.475: E/TiApplication(2004): java.lang.IllegalStateException
05-10 17:47:20.475: E/TiApplication(2004):  at android.media.MediaPlayer.isPlaying(Native Method)
05-10 17:47:20.475: E/TiApplication(2004):  at ti.modules.titanium.media.TiSound$2.run(TiSound.java:516)
05-10 17:47:20.475: E/TiApplication(2004):  at java.util.Timer$TimerImpl.run(Timer.java:284)
05-10 17:47:20.495: E/AndroidRuntime(2004): FATAL EXCEPTION: Timer-28
05-10 17:47:20.495: E/AndroidRuntime(2004): Process: com.plezzus.magnoids, PID: 2004
05-10 17:47:20.495: E/AndroidRuntime(2004): java.lang.IllegalStateException
05-10 17:47:20.495: E/AndroidRuntime(2004):     at android.media.MediaPlayer.isPlaying(Native Method)
05-10 17:47:20.495: E/AndroidRuntime(2004):     at ti.modules.titanium.media.TiSound$2.run(TiSound.java:516)
05-10 17:47:20.495: E/AndroidRuntime(2004):     at java.util.Timer$TimerImpl.run(Timer.java:284)
05-10 17:47:20.795: D/dalvikvm(373): GC_FOR_ALLOC freed 497K, 50% free 6477K/12844K, paused 137ms, total 146ms
05-10 17:47:20.805: I/dalvikvm-heap(373): Grow heap (frag case) to 7.469MB for 1127536-byte allocation
05-10 17:47:20.925: D/dalvikvm(373): GC_FOR_ALLOC freed 31K, 42% free 7546K/12844K, paused 122ms, total 122ms
05-10 17:47:21.215: D/dalvikvm(373): GC_CONCURRENT freed 25K, 41% free 7604K/12844K, paused 9ms+40ms, total 295ms
05-10 17:47:21.295: I/Choreographer(704): Skipped 46 frames!  The application may be doing too much work on its main thread.
05-10 17:47:21.475: W/EGL_emulation(704): eglSurfaceAttrib not implemented
05-10 17:47:22.875: D/Window(2004): Window is closed normally.
This happens maybe 1 out of every 5 times I test the app, and doesn't happen consistently (if I run the app several times and do the exact same thing, it might crash on the 4th, 5th or 6th try). In the past, I've reduced the number of crashes by calling stop() and then release() on all of my Sound objects right before the main window closes, but the crash still happens occasionally. Also, this happens on both a real device and an emulator.

I've tried all the workarounds I can think of... Is there any fix for this?

Titanium SDK version is Titanium 3.2.3 (2014/04/22 10:17 b958a70) on Ubuntu, Android versions I'm testing on are 4.2.2 (emulator) and 4.1.2 (device).


Viewing all articles
Browse latest Browse all 8068

Trending Articles