Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog

ShiVa3D

Return to Google Android

How to catch an unexpected crash

Google Play Store, Amazon Kindle, Nook, and so many more

How to catch an unexpected crash

Postby freezer » 01 Aug 2012, 15:50

Hi,

Just testing an app on Android and I got an unexpected crash. The sounds however continued playing. Is there a way to catch this so I can check for any cleanup?

Cheers


*** In addition I couldn't find anything in process's, so it had to be a full system restart.
freezer
Gold Boarder
Gold Boarder
 
Posts: 216

Re: How to catch an unexpected crash

Postby error454 » 03 Aug 2012, 01:39

Did you check logcat?
error454
Platinum Boarder
Platinum Boarder
 
Posts: 670
Location: Portland, OR USA

Re: How to catch an unexpected crash

Postby dbladez » 03 Aug 2012, 03:31

Best bet is logcat in the command prompt.

cd C:Androidandroid-sdk_r18-windowsandroid-sdk-windowsplatform-tools

adb logcat -c

adb logcat -d > logcat4.txt

To clear log: adb logcat -c
To dump to file: adb logcat -d > logcat1.txt

So use.

adb logcat -c

Then run the app, then after it crashes, type in the command prompt.

adb logcat -d > logcat1.txt

then inside

C:Androidandroid-sdk_r18-windowsandroid-sdk-windowsplatform-tools

or whatever directory you have your sdk under will be the logcat1.txt, open and check that and see where/why it crashed.

Hope that helps.
User avatar
dbladez
Platinum Boarder
Platinum Boarder
 
Posts: 682
Location: Ontario, Canada

Re: How to catch an unexpected crash

Postby freezer » 03 Aug 2012, 20:07

Cheers!

I have alogCat installed on this phone. Then I set a filter to the games process ID (4096 in this case), only warnings and above are logged. Also some repetitive crud has been removed.

Code: Select all
E( 4096* 4426) AudioFlinger could not create track, status: -12  (AudioTrack)
E( 4096* 4426) Error creating AudioTrack  (SoundPool)

Currently sound works fine for level 1, but after that anything which was looping doesn't play at all???



Code: Select all
E( 4096* 4096) enter process activity msg= 102  (ActivityThread)
E( 4096* 4096) exit process activity msg= 102  (ActivityThread)
E( 4096* 4096) enter process activity msg= 109  (ActivityThread)
E( 4096* 4426) call to OpenGL ES API with no current context (logged once per thread)  (libEGL)
E( 4096* 4096) exit process activity msg= 109  (ActivityThread)
E( 4096* 4096) enter process activity msg= 119  (ActivityThread)
E( 4096* 4096) exit process activity msg= 119  (ActivityThread)


The OpenGL one... in a couple of places certain huds aren't destroyed (done on leave state), and then show up when another is displayed. (Never had this issue before!)
*** concerning the GL error
It's a known WebView issue. We're on it :) Note that this error will not cause an application to crash. Your problem lies somewhere else.

http://stackoverflow.com/questions/8824082/call-to-opengl-es-api-with-no-current-context


Code: Select all
E( 4096* 4096) Dispatching touchevent to com.android.internal.policy.impl.PhoneWindow$DecorView@2feb0f30 touchevent action is 0 X= 242.45045 Y=723.38403  (ViewRoot enter )
E( 4096* 4096) Dispatching touchevent to com.android.internal.policy.impl.PhoneWindow$DecorView@2feb0f30  (ViewRoot exit )
E( 4096* 4096) Dispatching touchevent to com.android.internal.policy.impl.PhoneWindow$DecorView@2feb0f30 touchevent action is 2 X= 240.91109 Y=723.126  (ViewRoot enter )
E( 4096* 4096) Dispatching touchevent to com.android.internal.policy.impl.PhoneWindow$DecorView@2feb0f30  (ViewRoot exit )
E( 4096* 4096) Dispatching touchevent to com.android.internal.policy.impl.PhoneWindow$DecorView@2feb0f30 touchevent action is 2 X= 237.83235 Y=723.9002  (ViewRoot enter )



Code: Select all
E( 4096* 4101) rececive IME message viewRoot = Handler{2feb5d20}  (ViewRoot)
E( 4096* 4096) IME finished event: seq=1 handled=false event=KeyEvent{action=0 code=4 repeat=0 meta=0 scancode=158 mFlags=8}  (ViewRoot)
E( 4096* 4096) Dispatching key KeyEvent{action=1 code=4 repeat=0 meta=0 scancode=158 mFlags=8} to com.android.internal.policy.impl.PhoneWindow$DecorView@2feb0f30  (enter ViewRoot)
E( 4096* 4096) Sending key event to IME: seq=2 event=KeyEvent{action=1 code=4 repeat=0 meta=0 scancode=158 mFlags=8}  (ViewRoot)
E( 4096* 4096) Dispatching key KeyEvent{action=1 code=4 repeat=0 meta=0 scancode=158 mFlags=8} to com.android.internal.policy.impl.PhoneWindow$DecorView@2feb0f30  (exit ViewRoot)
E( 4096* 4101) rececive IME message viewRoot = Handler{2feb5d20}  (ViewRoot)
E( 4096* 4096) IME finished event: seq=2 handled=false event=KeyEvent{action=1 code=4 repeat=0 meta=0 scancode=158 mFlags=8}  (ViewRoot)


Looks like there's more going wrong that I thought.

Also the logs are a lot shorter than they should be, but that's probably something to do with me switching between apps.
Last edited by freezer on 03 Aug 2012, 22:24, edited 1 time in total.
freezer
Gold Boarder
Gold Boarder
 
Posts: 216

AUDIOFLINGER

Postby freezer » 03 Aug 2012, 20:33

Code: Select all
E( 4096* 4426) AudioFlinger could not create track, status: -12  (AudioTrack)
E( 4096* 4426) Error creating AudioTrack  (SoundPool)


Some threads are indicating that this is about having too many channels in SoundPool. So why is it fine on the first level.

Is there a way to force garbage collection (or clear SoundPool)




DOCS: (i'll update as I find, still not found a list of status codes (probably an ENUM somewhere in the source though))

http://www.netmite.com/android/mydroid/development/pdk/docs/audio_sub_system.html

SOURCE:
http://www.netmite.com/android/mydroid/2.0/frameworks/base/libs/audioflinger/
http://www.netmite.com/android/mydroid/2.0/frameworks/base/libs/audioflinger/AudioFlinger.h
http://www.netmite.com/android/mydroid/2.0/frameworks/base/libs/audioflinger/AudioFlinger.cpp

http://www.netmite.com/android/mydroid/2.0/frameworks/base/include/utils/Errors.h
status -12 may be "FAILED_TRANSACTION"



http://www.scribd.com/doc/67054989/Android-Sound-Tips
3. Problems with sound

a. Sound missing
AudioFlinger has an AudioMixer that can maximum support 32 sound tracks on eachplayback thread. So if there are too many sounds to play at the same time, you willreceive “No more track name” error message and some sounds may be ignored.
Figure 5: Each playback thread can support 32 sound tracks.

Another reason of sound missing is that you use SoundPool and play sound right afterload it. SoundPool has an underlying thread that takes care of loading and playingsound. So, load method may return before the sound is completely decoded and if you start it at that time, you will receive “Sample is not ready”.

b. Game lagging
MediaPlayer is slow and using them regularly may lag game. SoundPool will fix thisproblem. But SoundPool has a limitation of memory and cannot load large or toomany files.

c. Lost all sounds and crash
As previously mentioned, mixing MediaPlayer with SoundPool may cause missing allsounds and then crash. When creating SoundPool, you must indicate the maximumnumber of channels. Because of the limitation of AudioMixer, if this number isgreater than 32, SoundPool will reduce it to 32. But SoundPool really doesn’t knowhow many sound tracks have been kept by MediaPlayer and others and causes “Nomore track name” error. After that, sound will be lost one by one.So, you must limit both number of MediaPlayer’s instances and number of SoundPoolchannels. I suggest 2 MediaPlayer (1 for BGM, 1 for VFX) and about 20 SoundPoolchannels.



COMPARISON WITH PULSE AUDIO
http://arunraghavan.net/2012/01/pulseaudio-vs-audioflinger-fight/


SOUNDPOOL
http://developer.android.com/reference/android/media/SoundPool.html
freezer
Gold Boarder
Gold Boarder
 
Posts: 216

Re: How to catch an unexpected crash

Postby freezer » 03 Aug 2012, 22:30

Concerning audio, I only use 16 samples in total.
All are ensured to be stopped after use.


I'm going to guess the following function won't keep the sample in the SoundPool, but just in RAM or similar.
http://www.stonetrip.com/developer/doc/api/application-forceResourceToStayLoaded

EDIT:
Just realising that there is only kResourceTypeSoundBank, and my soundbank is not destroyed (just a single scene in the BG).
freezer
Gold Boarder
Gold Boarder
 
Posts: 216


Return to Google Android