How to debug a crashed app
Hi,
We have our app up and running but from time to time it will crash both on the simulator and the device.
when crashing on the simulator Ti sometimes offer some pointers to where the problem was.
sometimes we just see "the application existed the simulator"…. and we have nothing to work with.
what are the best practices when comes to situation like that ? how to figure out where the problem is ?
also can you provide some pointers on how to better code JavaScript that handles crashes well and gracefully instead of existing the app..
5 Answers
-
For me, the titanium studio gave nothing usefull when the crash happend, I tried to find a call stack but could not find one and what I did find did not provide any insight.
any change of some screenshot showing the help you are getting from Studio ? maybe I am using it wrong.
-
I am able to debug almost anything using titanium studio, the debugger is quite helpful. But what also works, is reading through the lines.. For example, if I am working on android and I cause my simulator completely melt down, I usually see a TON of java kroll errors spit out in the console, but if scroll up and just read through everything I will eventually find some references back to my code. Once this information is attained, debugging is easyPeezy.
Do you have example of the errors you are coming across?
PS jsLint for javascript verification
-
Sure.. I created an error on purpose in my app. See below for console output.
The following lines, are very helpful in finding my error:
E/KrollContext( 296): at script(file:///android_asset/Resources/app.js:221) E/KrollContext( 296): org.mozilla.javascript.EcmaError: ReferenceError: "runjFirst" is not defined. (file:///android_asset/Resources/app.js#221) E/TiJSError( 296): (kroll$1: app://app.js) [4,7995] - In file:///android_asset/Resources/app.js:221,0 E/TiJSError( 296): (kroll$1: app://app.js) [2,7997] - Message: ReferenceError: "runjFirst" is not defined. (file:///android_asset/Resources/app.js#221)
Full Output:
W/ActivityManager( 59): Activity idle timeout for HistoryRecord{43f012b8 com.authtestAndroid.agentgrid/.AuthtestandroidActivity} E/KrollContext( 296): (kroll$1: app://app.js) [595,7962] ECMA Error evaluating source: ReferenceError: "runjFirst" is not defined. (file:///android_asset/Resources/app.js#221) E/KrollContext( 296): org.mozilla.javascript.EcmaError: ReferenceError: "runjFirst" is not defined. (file:///android_asset/Resources/app.js#221) E/KrollContext( 296): at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3784) E/KrollContext( 296): at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3762) E/KrollContext( 296): at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3847) E/KrollContext( 296): at org.mozilla.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntime.java:2235) E/KrollContext( 296): at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1505) E/KrollContext( 296): at script(file:///android_asset/Resources/app.js:221) E/KrollContext( 296): at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854) E/KrollContext( 296): at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164) E/KrollContext( 296): at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426) E/KrollContext( 296): at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177) E/KrollContext( 296): at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175) E/KrollContext( 296): at org.mozilla.javascript.Context.evaluateReader(Context.java:1142) E/KrollContext( 296): at org.appcelerator.titanium.kroll.KrollContext$DefaultEvaluator.evaluateFile(KrollContext.java:105) E/KrollContext( 296): at org.appcelerator.titanium.kroll.KrollContext.evaluateScript(KrollContext.java:306) E/KrollContext( 296): at org.appcelerator.titanium.kroll.KrollContext.handleEvalFile(KrollContext.java:318) E/KrollContext( 296): at org.appcelerator.titanium.kroll.KrollContext.handleMessage(KrollContext.java:217) E/KrollContext( 296): at org.appcelerator.titanium.TiMessageQueue.handleMessage(TiMessageQueue.java:223) E/KrollContext( 296): at android.os.Handler.dispatchMessage(Handler.java:95) E/KrollContext( 296): at android.os.Looper.loop(Looper.java:123) E/KrollContext( 296): at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86) E/TiJSError( 296): (kroll$1: app://app.js) [29,7991] ----- Titanium Javascript Runtime Error ----- E/TiJSError( 296): (kroll$1: app://app.js) [4,7995] - In file:///android_asset/Resources/app.js:221,0 E/TiJSError( 296): (kroll$1: app://app.js) [2,7997] - Message: ReferenceError: "runjFirst" is not defined. (file:///android_asset/Resources/app.js#221) E/TiJSError( 296): (kroll$1: app://app.js) [1,7998] - Source: null I/ALERT ( 296): (kroll$1: app://app.js) [168,8166] Could not retrieve location I/TiRootActivity( 296): (main) [0,0] checkpoint, on root activity resume. context = org.appcelerator.titanium.TiContext@43e512e0 D/dalvikvm( 296): GC_FOR_MALLOC freed 5223 objects / 435000 bytes in 197ms W/TiAnalyticsSvc( 296): (Thread-11) [239,239] Analytics Service Started I/ActivityManager( 59): Displayed activity com.authtestAndroid.agentgrid/.AuthtestandroidActivity: 12306 ms (total 12306 ms) I/ARMAssembler( 59): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x3488a8:0x348964] in 8424074 ns I/TiAnalyticsSvc( 296): (Thread-11) [1578,1817] Network unavailable, can't send analytics W/TiAnalyticsSvc( 296): (Thread-11) [1,1818] Stopping Analytics Service D/dalvikvm( 130): GC_EXPLICIT freed 676 objects / 39008 bytes in 212ms
-
YES, helpfull, but this is android, my iOS app crashes sometimes with just one line "application left the simulator", that is it!
when I try to get device crash logs I get lots of gibberish and the thread number that crashed…not useful..
how about some screenshot of you using Studio to debug? how do you use it to trap crashes ? see the call stack that led to it ? see variable values at each stage ?
maybe running the project in xcode ? but even crashes occurring within an xcode debug session will not break on the exception so I can see what happened..
-
on the Android handset we use this log collector app – to get some insight
https://market.android.com/details?id=com.xtralogic.android.logcollector&hl=en