NativeScript / firebase

Modular Firebase 🔥 implementation for NativeScript. Supports both iOS & Android platforms for all Firebase services.
https://docs.nativescript.org/plugins/firebase-core.html
Apache License 2.0
56 stars 49 forks source link

[Crashlytics] How can we get a better stack trace? #94

Open fpaaske opened 2 years ago

fpaaske commented 2 years ago

As the title asks, is there a better way for us to build the app, or use the Crashlytics plugin, so that we can get a more readable and understandable stack trace?

We build the release like this

ns prepare ios --release --clean --env.production --env.aot --env.uglify

Then perform the archive and upload to AppStore via Xcode.

ns build android --release --clean --env.production --env.aot --env.uglify

Then upload apk to Google Play

I assume most of my issues are connected to the code being minified/uglified, but this is also the recommended way for performance, right?

ns info
✔ Getting NativeScript components versions information...
✔ Component nativescript has 8.2.3 version and is up to date.
✔ Component @nativescript/core has 8.2.5 version and is up to date.
⚠ Update available for component @nativescript/ios. Your current version is 8.2.3 and the latest available version is 8.3.0.
⚠ Update available for component @nativescript/android. Your current version is 8.2.3 and the latest available version is 8.2.4.

This is an example of a recent crash containing a stack trace from an app I'm working on. It is fairly simple to see what is causing the crash, but it's not so easy to see from where it's happening. I assume this is because of the minification process.

We can see it happens in a templateSelector (I guess that method was not minified due to being used in a template?), and that it's the accessing of the templateKey that fails, probably because the list item is null/undefined for some reason. Luckily for us we don't have many of those, so we can go through every one, check them, log more error info and add an NPE guard to avoid the crash.

Unfortunately, this is probably one of the most descriptive error messages we've gotten.

Fatal Exception: NativeScript encountered a fatal error: Uncaught TypeError: Cannot read property 'templateKey' of undefined
 at 
    templateSelector(file:///var/containers/Bundle/Application/E36----3B2/nsapp.app/app/bundle.js:1:290879)
    at _getItemTemplate(file:///var/containers/Bundle/Application/E36----3B2/nsapp.app/app/vendor.js:2:664680)
    at (file:///var/containers/Bundle/Application/E36----3B2/nsapp.app/app/vendor.js:2:667899)

0  CoreFoundation                 0x99288 __exceptionPreprocess
1  libobjc.A.dylib                0x16744 objc_exception_throw
2  NativeScript                   0xdbb70 tns::NativeScriptException::OnUncaughtError(v8::Local<v8::Message>, v8::Local<v8::Value>) + 63 (NativeScriptException.mm:63)
3  NativeScript                   0x45a968 v8::internal::MessageHandler::ReportMessageNoExceptions(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::Object>, v8::Local<v8::Value>)
4  NativeScript                   0x45a7d4 v8::internal::MessageHandler::ReportMessage(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::JSMessageObject>)
5  NativeScript                   0x39b53c v8::internal::Isolate::ReportPendingMessages()
6  NativeScript                   0x2f3d28 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&)
7  NativeScript                   0x2f32dc v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*)
8  NativeScript                   0x146780 v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*)
9  NativeScript                   0x1ff90 tns::ArgConverter::MethodCallback(ffi_cif*, void*, void**, void*) + 171 (ArgConverter.mm:171)
10 NativeScript                   0x111264 ffi_closure_SYSV_inner
11 NativeScript                   0x1141b4 .Ldo_closure
12 UIKitCore                      0x2866c4 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:]
13 UIKitCore                      0x483af0 -[UITableView _updateVisibleCellsForRanges:createIfNecessary:]
14 UIKitCore                      0x2ab8bc -[UITableView _updateVisibleCellsNow:]
15 UIKitCore                      0x17bd10 -[UITableView layoutSubviews]
16 UIKitCore                      0x18bfb4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
17 QuartzCore                     0x40cd0 CA::Layer::layout_if_needed(CA::Transaction*)
18 QuartzCore                     0x33134 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
19 QuartzCore                     0x47a7c CA::Context::commit_transaction(CA::Transaction*, double, double*)
20 QuartzCore                     0x50970 CA::Transaction::commit()
21 QuartzCore                     0x3288c CA::Transaction::flush_as_runloop_observer(bool)
22 UIKitCore                      0x53e198 _UIApplicationFlushCATransaction
23 UIKitCore                      0x7d897c _UIUpdateSequenceRun
24 UIKitCore                      0xe5ec48 schedulerStepScheduledMainSection
25 UIKitCore                      0xe5e410 runloopSourceCallback
26 CoreFoundation                 0xbb414 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
27 CoreFoundation                 0xcc1a0 __CFRunLoopDoSource0
28 CoreFoundation                 0x5694 __CFRunLoopDoSources0
29 CoreFoundation                 0xb05c __CFRunLoopRun
30 CoreFoundation                 0x1ebc8 CFRunLoopRunSpecific
31 GraphicsServices               0x1374 GSEventRunModal
32 UIKitCore                      0x514648 -[UIApplication _run]
33 UIKitCore                      0x295d90 UIApplicationMain
34 NativeScript                   0x114044 ffi_call_SYSV
35 NativeScript                   0x110ac8 ffi_call_int
36 NativeScript                   0xb39dc tns::Interop::CallFunctionInternal(tns::MethodCall&) + 1444 (Interop.mm:1444)
37 NativeScript                   0x7665c std::__1::__function::__func<tns::MetadataBuilder::CFunctionCallback(v8::FunctionCallbackInfo<v8::Value> const&)::$_2, std::__1::allocator<tns::MetadataBuilder::CFunctionCallback(v8::FunctionCallbackInfo<v8::Value> const&)::$_2>, void ()>::operator()() + 849 (MetadataBuilder.mm:849)
38 NativeScript                   0xd6c04 tns::Tasks::Drain() + 1739 (vector:1739)
39 NativeScript                   0xd0fd0 -[NativeScript initWithConfig:] + 64 (NativeScript.mm:64)
40 nsapp                  0x4c44 main + 59 (main.m:59)
41 ???                            0x102e71ce4 (Missing)

Here's a another set other reports that are flat out impossible to understand:

Fatal Exception: NativeScript encountered a fatal error: Uncaught TypeError: number 0 is not a function
 at 

0  CoreFoundation                 0x9904c __exceptionPreprocess
1  libobjc.A.dylib                0x15f54 objc_exception_throw
2  NativeScript                   0xdbb70 tns::NativeScriptException::OnUncaughtError(v8::Local<v8::Message>, v8::Local<v8::Value>) + 63 (NativeScriptException.mm:63)
3  NativeScript                   0x45a968 v8::internal::MessageHandler::ReportMessageNoExceptions(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::Object>, v8::Local<v8::Value>)
4  NativeScript                   0x45a7d4 v8::internal::MessageHandler::ReportMessage(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::JSMessageObject>)
5  NativeScript                   0x39b53c v8::internal::Isolate::ReportPendingMessages()
Fatal Exception: NativeScript encountered a fatal error: Uncaught TypeError: number -62295433 is not a function
 at 

0  CoreFoundation                 0x99288 __exceptionPreprocess
1  libobjc.A.dylib                0x16744 objc_exception_throw
2  NativeScript                   0xdbb70 tns::NativeScriptException::OnUncaughtError(v8::Local<v8::Message>, v8::Local<v8::Value>) + 63 (NativeScriptException.mm:63)
3  NativeScript                   0x45a968 v8::internal::MessageHandler::ReportMessageNoExceptions(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::Object>, v8::Local<v8::Value>)
4  NativeScript                   0x45a7d4 v8::internal::MessageHandler::ReportMessage(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::JSMessageObject>)
5  NativeScript                   0x39b53c v8::internal::Isolate::ReportPendingMessages()
Fatal Exception: NativeScript encountered a fatal error: Uncaught TypeError: object is not a function
 at 

0  CoreFoundation                 0x99288 __exceptionPreprocess
1  libobjc.A.dylib                0x16744 objc_exception_throw
2  NativeScript                   0xdbb70 tns::NativeScriptException::OnUncaughtError(v8::Local<v8::Message>, v8::Local<v8::Value>) + 63 (NativeScriptException.mm:63)
3  NativeScript                   0x45a968 v8::internal::MessageHandler::ReportMessageNoExceptions(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::Object>, v8::Local<v8::Value>)
4  NativeScript                   0x45a7d4 v8::internal::MessageHandler::ReportMessage(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::JSMessageObject>)
5  NativeScript                   0x39b53c v8::internal::Isolate::ReportPendingMessages()

This one seems to come from inside NativeScript, which contains native code, so I guess this is fine to read for you guys :)

Crashed: com.apple.main-thread
0  NativeScript                   0xb85e4 tns::FFICall::FFICall(tns::ParametrizedCall*) + 74 (FFICall.h:74)
1  NativeScript                   0xb3894 tns::Interop::CallFunctionInternal(tns::MethodCall&) + 1383 (Interop.mm:1383)
2  NativeScript                   0x1eaec tns::ArgConverter::Invoke(v8::Local<v8::Context>, objc_class*, v8::Local<v8::Object>, tns::V8Args&, tns::MethodMeta const*, bool) + 79 (ArgConverter.mm:79)
3  NativeScript                   0x71658 tns::MetadataBuilder::InvokeMethod(v8::Local<v8::Context>, tns::MethodMeta const*, v8::Local<v8::Object>, tns::V8Args&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool) + 820 (MetadataBuilder.mm:820)
4  NativeScript                   0x71120 tns::MetadataBuilder::PropertyGetterCallback(v8::FunctionCallbackInfo<v8::Value> const&) + 677 (MetadataBuilder.mm:677)
5  NativeScript                   0x81df14 Builtins_CallApiCallback + 212
6  NativeScript                   0x9020bc Builtins_LdaNamedPropertyHandler + 3132
7  NativeScript                   0x81b818 Builtins_InterpreterEntryTrampoline + 248
8  NativeScript                   0x81b818 Builtins_InterpreterEntryTrampoline + 248
9  NativeScript                   0x81b818 Builtins_InterpreterEntryTrampoline + 248
triniwiz commented 2 years ago

In the newer version of the ios runtime you can get more info about the calls made, I'll check out if it returns the a stack with more info

NathanWalker commented 2 years ago

@fpaaske are you using RadListView? Perhaps could share project package.json - would be curious at versions.

brianrclow commented 1 year ago

@fpaaske This seems to be something that others might wanting as well. I've discussed this a bit on the NativeScript Discord. I created a demo app, added firebase-core and crashlytics then created a situation where the app would crash. The crash report comes through to crashlytics after uploading the .dSYM file, but looks similar to yours where it's not readable as to where in the code caused the crash. I'd be very interested in seeing what could be done to get a more readable crash report.

fpaaske commented 1 year ago

@fpaaske are you using RadListView? Perhaps could share project package.json - would be curious at versions.

@NathanWalker These are the dependencies we've got:

  "dependencies": {
    "@angular/animations": "~13.1.1",
    "@angular/common": "~13.1.1",
    "@angular/compiler": "~13.1.1",
    "@angular/core": "~13.1.1",
    "@angular/forms": "~13.1.1",
    "@angular/platform-browser": "~13.1.1",
    "@angular/platform-browser-dynamic": "~13.1.1",
    "@angular/router": "~13.1.1",
    "@nativescript-community/ui-drawer": "^0.1.1",
    "@nativescript-community/ui-image": "^4.1.7",
    "@nativescript-community/ui-label": "^1.2.8",
    "@nativescript-community/ui-material-bottom-navigation": "~6.2.2",
    "@nativescript-community/ui-material-core": "~6.2.2",
    "@nativescript-community/ui-material-tabs": "~6.2.2",
    "@nativescript-community/ui-pager": "^13.0.33",
    "@nativescript-community/ui-pulltorefresh": "~2.5.0",
    "@nativescript-community/universal-links": "^3.0.0",
    "@nativescript/angular": "13.0.3",
    "@nativescript/appversion": "^2.0.0",
    "@nativescript/camera": "^5.0.2",
    "@nativescript/core": "~8.3.2",
    "@nativescript/firebase-core": "^2.1.0",
    "@nativescript/firebase-crashlytics": "^2.1.0",
    "@nativescript/firebase-messaging": "^2.1.0",
    "@nativescript/firebase-performance": "^2.1.0",
    "@nativescript/firebase-remote-config": "^2.1.0",
    "@nativescript/geolocation": "^8.0.2",
    "@nativescript/imagepicker": "^1.0.2",
    "@nativescript/local-notifications": "^6.0.0",
    "@nativescript/secure-storage": "^3.0.0",
    "@ngx-translate/core": "^14.0.0",
    "moment": "^2.27.0",
    "nativescript-app-shortcuts": "^3.0.0",
    "nativescript-calendar": "^2.2.1",
    "nativescript-clipboard": "2.1.1",
    "nativescript-feedback": "^2.0.0",
    "nativescript-locate-address": "^1.0.3",
    "nativescript-modal-datetimepicker": "^2.1.5",
    "nativescript-phone": "^3.0.3",
    "nativescript-theme-core": "^1.0.6",
    "ns-permissions": "^2.0.0",
    "ns7-swiss-army-knife": "^1.0.0",
    "rxjs": "^6.6.0",
    "zone.js": "~0.11.4"
  }
fpaaske commented 1 year ago

@NathanWalker @triniwiz have you had any time to look into possibilities of making the stack traces more useful?