Folks,
Some time ago, following
@atilim 's
request, I added Crittercism crash logging to my app under development. Imagine my surprise when I found nothing in the logs following several "crashes". This was, of course, because these crashes I'd experienced weren't actually caused by real exceptions at all but rather they were "just" Lua errors. Unfortunately, in such circumstances Gideros just prints a stack trace to the console and then exits normally. Nothing get's sent to Crittercism for later perusal.
Recently, I got down to sorting this out and I've now written a plugin that allows you to detect Lua crashes *and* get hold of the Lua stack trace when things went wrong. You can find full details and a download link for the plugin in this blog article:
http://bowerhaus.eu/blog/files/luacrashlogging.htmlAs you'll see if you read the article, I found that neither Crittercism nor BugSense are suitable for this purpose and I opted for Crashlytics. This is no bad thing, since it turns out that Crashlytics is now
completely free to use.
Here's a short (two-line) stack dump that shows how it appears in the Crashlytics dashboard (newlines are replaced by *** markers):
Note that the plugin, as it stands, is written for iOS. However, there's nothing in there that should preclude an easy port to Android. If anyone manages to do this, please let me know.
best regards
Comments
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
http://support.crashlytics.com/knowledgebase/topics/18948-crashlytics-sdk-for-android
They've recently been bought by Twitter. I guess the Android SDK will be there soon if it isn't already.
best regards
Hopefully it will be sooner rather than later.
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
Thanks a lot for this. I set it up according to your instructions, but the crash report doesn't contain the lua backtrace.
I created a button with an onClick function that tries to run unknownFunctionCall(). I installed the app to my device and clicked the button. It generated a crash report, but under 'more details' it just shows LUASTACK as blank, and Log as : 0 * null
The main exception trace is:
0 stackeralpha -[Crashlytics crash] + 1145559
1 stackeralpha
BhCrashlytics.mm line 75
exit
2 stackeralpha std::_Rb_tree, std::_Select1st >, StringId::ltstr, std::allocator > >::_M_erase(std::_Rb_tree_node >*) + 82
3 stackeralpha
giderosapi.mm line 772
ApplicationManager::drawFrame()
4 stackeralpha
ViewController.m line 155
-[ViewController drawFrame]
5 QuartzCore CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long) + 160
6 QuartzCore CA::Display::IOMFBDisplayLink::callback(__IOMobileFramebuffer*, unsigned long long, unsigned long long, unsigned long long, void*) + 64
7 IOMobileFramebuffer IOMobileFramebufferVsyncNotifyFunc + 154
8 IOKit IODispatchCalloutFromCFMessage + 192
...
16 UIKit UIApplicationMain + 1120
17 stackeralpha
main.m line 12
main
Any ideas?
0 00:00:07:70 $ clicking crash button
but still no Lua stack trace. Exact code I'm using is:
BhCrashlytics uses two regexes in a function called distillLuaStackTrace() to strip out the crap before the real stack trace and to shorten the contents of each line (so that they are more readable in the Crashlytics dashboard). However, I'm truly hopeless at regex so it's very likely that my attempt doesn't work correctly in all cases and this function might be stripping out everything.
Things to try:
1) Try removing the call to that function so that the whole file gets sent up to Crashlytics. See what you can see in the dashboard. If something gets there that will indicate that the regex is at fault.
2) Try using a tool like iExplorer or i-FunBox to explore the file system on your device after a crash occurs and look at the contents of stdout.txt in your apps /Documents directory. Do this after the app has crashed but before restarting (otherwise the file will get wiped). This will tell you if the stack trace is being written to the file and might explain why the regex is failing if it is.
Let me know how you get on.
best regards
EDIT: I have changed this question from the original in the light of more information.
I'm trying to use the above crash reporting solution to find a bug in my application. I have a reproducible Lua crash but it doesn't get a stack dump with it. In this case I'm seeing a slightly different sort of exit message in the log than I normally do. It says:
Lua panicked and quit: /Users/bower/Documents/Apps/Gideros/XCode/Universal/spinoff/spinoff/assets/Library/BhHelpers.lua:942: bad argument #2 to 'format' (string expected, got userdata)
I haven't seen this "panicked and quit" exit before. Is there any reason why Gideros doesn't create a stack trace in this case.
Best regards
best regards
FWIW, I'm testing this by creating an archive release build and pushing that to my device.
One possibility; are you encrypting the Lua files when exporting the project? If so, try turning that option off. Also, just check that you are using the latest version of Gideros, I thought I remembered something about the encryption being changed in this respect in this version. Ah, here it is, from the 2012.9.10 release notes:
"Change: While exporting, Lua bytecodes are not debug stripped to get better error descriptions"
I'm using the Crashlytics dumps with encryption turned on and it seems okay with Gideros 2012.9.10.
Best regards
Thus such reporting error, however (at least on Android) these kind of errors are also provided by Gideros, thus may not be included in crash reports on themselves.
Probably need some more sophisticated regex to anticipate these kind of situations also. Maybe looking for keywords stack and lua?
With 400.000+ downloads of Game42, I've received quite many crashes from Critterism but honestly don't have enough clue to fix the bugs.
Okay, I'm a pusher, not an implementer )
https://play.google.com/store/apps/developer?id=My+name+is+Originality
I assume that you can't understand the Crittercism crash reports because they don't include a Lua stack trace? I know Crashlytics isn't available for Android yet but couldn't you try to adapt the stuff I did above and upload the error stacks to a website (either yours or a third party BAAS). So, what I'm saying is, continue to use Crittercism for raw crashes and then something else for the (probably more common) Lua crashes.
Before I came across Crashlytics I started working on this. I was going to use the Collections support (like a database) of Moai Direct cloud services. But since Crashlytics came along and did what I needed I didn't carry on with that idea. Anyone else want to pick up the ball and create a generic Lua crash reporting service for both IOS and Android?
Best regards
@fxone: no no, I just meant the total downloads was more than 400K. It's already back to Paid so not that many downloads per day. But still, it's been in top 100 paid in Board game category in US and some other countries
@bowerandy: I meant Game42 on iOS (actually the Android versions for Samsung phones and tablets have just arrived on Samsung store too ). But yes some solution that support both iOS and Android would be very helpful for many people.
Likes: fxone
see: http://www.crashlytics.com/blog/its-finally-here-announcing-crashlytics-for-android/
Fragmenter - animated loop machine and IKONOMIKON - the memory game
best regards
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: SinisterSoft
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Not sure what might be happening but here are a few ideas:
1) You won't get a Crashlytics log entry if the player is running under Xcode. Stuff only gets sent up to Crashlytics if you have launched the player (or your app) directly on a real device. I also suspect it may not work in the iOS simulator. It certainly won't work using the Gideros desktop player.
2) Sometimes Lua quits without calling exit(). I'm not sure when this happens but it is rare. Try adding "undefinedSymbol()" to your main.lua and see if this causes a log. If it doesn't try running the player (on a real device) under Xcode and put a breakpoint at that exit(status) function in BhCrashlytics.mm. If it's not getting there I'm a bit stumped.
best regards
Thanks for your reply. I will check this out.