Skip to content

Conversation

@denrase
Copy link
Collaborator

@denrase denrase commented Nov 21, 2020

Implementation

I created a debug screen wehere we can record exception and trigger native crashed. For recording, we can throw String, Error and Exception instances. To Reach the screen, long press on the session cookie text in the settings screen while authenticated.

Screenshot_20201122-114646

List of Tests

  • Debug
    • throw Exception instance:

      • Capture with Sentry.captureException
        • Android Device
        • iOS Device
        • Andorid Emulator
        • iOS Simulator
      • Don't capture
        • Android Device
        • iOS Device
        • Andorid Emulator
        • iOS Simulator
    • throw Error instance:

      • Capture with Sentry.captureException
        • Android Device
        • iOS Device
        • Andorid Emulator
        • iOS Simulator
      • Don't capture
        • Android Device
        • iOS Device
        • Andorid Emulator
        • iOS Simulator
    • throw String instance:

      • Capture with Sentry.captureException
        • Android Device
        • iOS Device
        • Andorid Emulator
        • iOS Simulator
      • Don't capture
        • Android Device
        • iOS Device
        • Andorid Emulator
        • iOS Simulator
    • Platform Native

      • Swift
        • Force fatal in native code
          • iOS Device
          • iOS Simulator
      • ObjC
        • Force fatal in native code
          • iOS Device
          • iOS Simulator
      • Kotlin
        • Force fatal in native code
          • Android Device
          • Andorid Emulator
      • Java
        • Force fatal in native code
          • Android Device
          • Andorid Emulator
  • Release
    • throw Exception instance:

      • Capture with Sentry.captureException
        • Android Device
        • iOS Device
      • Don't capture
        • Android Device
        • iOS Device
    • throw Error instance:

      • Capture with Sentry.captureException
        • Android Device
        • iOS Device
      • Don't capture
        • Android Device
        • iOS Device
    • throw String instance:

      • Capture with Sentry.captureException
        • Android Device
        • iOS Device
      • Don't capture
        • Android Device
        • iOS Device
    • Platform Native

      • Swift
        • Force fatal in native code
          • iOS Device
      • ObjC
        • Force fatal in native code
          • iOS Device
      • Kotlin
        • Force fatal in native code
          • Android Device
      • Java
        • Force fatal in native code
          • Android Device

Results

Debug Mode Runs

  • Android
    • No application methods in stacktrace for unhandled String instance: ❌

      • https://sentry.io/organizations/sentry-sdks/issues/2046534370/?project=5428562&query=is%3Aunresolved&statsPeriod=14d
      • Debugger String Instance:
         ════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════
         The following message was thrown while handling a gesture:
         Fatal Exception - String Instance - operatingSystem: android
         When the exception was thrown, this was the stack: 
         #0      _SentryFlutterScreenState._captureException (package:sentry_mobile/screens/debug/sentry_flutter_screen.dart:113:7)
         #1      _SentryFlutterScreenState._createListTile.<anonymous closure> (package:sentry_mobile/screens/debug/sentry_flutter_screen.dart:86:44)
         #2      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
         #3      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1111:38)
         #4      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
         ...
         Handler: "onTap"
         Recognizer: TapGestureRecognizer#deec2
           debugOwner: GestureDetector
           state: ready
        
    • No application methods in stacktrace for unhandled Exception instance: ❌

      • https://sentry.io/organizations/sentry-sdks/issues/2046402940/?project=5428562&query=is%3Aunresolved&statsPeriod=14d
      • Debugger Exception Instance
         ════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════
         The following _Exception was thrown while handling a gesture:
         Exception: Fatal Exception - Exception Instance - operatingSystem: android
         When the exception was thrown, this was the stack: 
         #0      _SentryFlutterScreenState._captureException (package:sentry_mobile/screens/debug/sentry_flutter_screen.dart:113:7)
         #1      _SentryFlutterScreenState._createListTile.<anonymous closure> (package:sentry_mobile/screens/debug/sentry_flutter_screen.dart:86:44)
         #2      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
         #3      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1111:38)
         #4      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
         ...
         Handler: "onTap"
         Recognizer: TapGestureRecognizer#6ebd1
           debugOwner: GestureDetector
           state: ready
           ```
        
    • Application methods in stacktrace for unhandled Exception instance is shown: ✅

      • https://sentry.io/organizations/sentry-sdks/issues/2046432181/?project=5428562&query=is%3Aunresolved&statsPeriod=14d
      • Debugger Error Instance
         ════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════
         The following _Exception was thrown while handling a gesture:
         Exception: Fatal Exception - Exception Instance - operatingSystem: android
         When the exception was thrown, this was the stack: 
         #0      _SentryFlutterScreenState._captureException (package:sentry_mobile/screens/debug/sentry_flutter_screen.dart:113:7)
         #1      _SentryFlutterScreenState._createListTile.<anonymous closure> (package:sentry_mobile/screens/debug/sentry_flutter_screen.dart:86:44)
         #2      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
         #3      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1111:38)
         #4      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
         ...
         Handler: "onTap"
         Recognizer: TapGestureRecognizer#6ebd1
           debugOwner: GestureDetector
           state: ready
        
    • Exception thown in message channel was not reported to sentry mobile: ❌

       E/DartMessenger(12795): Uncaught exception in binary message listener
       E/DartMessenger(12795): java.lang.Exception: Native Crash - Android Kotlin
       E/DartMessenger(12795): 	at io.sentry.sentry_mobile.MainActivity.crashKotlin(MainActivity.kt:26)
       E/DartMessenger(12795): 	at io.sentry.sentry_mobile.MainActivity.access$crashKotlin(MainActivity.kt:9)
       E/DartMessenger(12795): 	at io.sentry.sentry_mobile.MainActivity$configureFlutterEngine$1.onMethodCall(MainActivity.kt:16)
       E/DartMessenger(12795): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
       E/DartMessenger(12795): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
       E/DartMessenger(12795): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
       E/DartMessenger(12795): 	at android.os.MessageQueue.nativePollOnce(Native Method)
       E/DartMessenger(12795): 	at android.os.MessageQueue.next(MessageQueue.java:335)
       E/DartMessenger(12795): 	at android.os.Looper.loop(Looper.java:183)
       E/DartMessenger(12795): 	at android.app.ActivityThread.main(ActivityThread.java:7656)
       E/DartMessenger(12795): 	at java.lang.reflect.Method.invoke(Native Method)
       E/DartMessenger(12795): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
       E/DartMessenger(12795): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
       E/flutter (12795): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method crashKotlin on channel sentry-mobile.sentry.io/nativeCrash)
       E/flutter (12795): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157:7)
       E/flutter (12795): <asynchronous suspension>
       E/flutter (12795): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
       E/flutter (12795): #2      _SentryFlutterScreenState._callCrashNative (package:sentry_mobile/screens/debug/sentry_flutter_screen.dart:173:26)
       E/flutter (12795): #3      _SentryFlutterScreenState._createNativeListTile.<anonymous closure> (package:sentry_mobile/screens/debug/sentry_flutter_screen.dart:110:26)
       E/flutter (12795): #4      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
       E/flutter (12795): #5      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1111:38)
       E/flutter (12795): #6      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
       E/flutter (12795): #7      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:598:11)
       E/flutter (12795): #8      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:287:5)
       E/flutter (12795): #9      BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:259:7)
       E/flutter (12795): #10     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157:27)
       E/flutter (12795): #11     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:362:20)
       E/flutter (12795): #12     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:338:22)
       E/flutter (12795): #13     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:267:11)
       E/flutter (12795): #14     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:295:7)
       E/flutter (12795): #15     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:240:7)
       E/flutter (12795): #16     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:213:7)
       E/flutter (12795): #17     _rootRunUnary (dart:async/zone.dart:1206:13)
       E/flutter (12795): #18     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
       E/flutter (12795): #19     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
       E/flutter (12795): #20     _invoke1 (dart:ui/hooks.dart:265:10)
       E/flutter (12795): #21     _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)
       E/flutter (12795): 
      
    • Kotlin Crash in AsycTask ❌

      • No application methods in stacktrace
    • Java Crash in AsyncTask ✅

      • Application methods in stacktrace
  • iOS
    • Swift Crash ✅
      • Application methods in stacktrace
    • ObjcC Crash ✅
      • Application methods in stacktrace

Release Mode Runs

There wer no dsyms or other files uploaded for symbolication. Just directly run with flutter run --release. So i guess most missind info in stacktraces is because of this

@denrase denrase self-assigned this Nov 21, 2020
@denrase denrase marked this pull request as ready for review November 22, 2020 11:27
@marandaneto
Copy link
Contributor

getsentry/sentry-dart#184 for missing stack traces for unhandled flutter errors

@marandaneto
Copy link
Contributor

for Exception thown in message channel was not reported to sentry mobile, you need to use catchError and capture yourself, maybe we could offer an extension method which already does that, but there's no way to detect this automatically without instrumentation on the client, so it's not a bug at least.

@marandaneto
Copy link
Contributor

marandaneto commented Nov 23, 2020

about Kotlin Crash in AsycTask -> that was a tricky one.

See this:
https://github.com/getsentry/sentry-java/blob/4b8b7d7d11e216153ec7fd2619490894db02ef7e/sentry/src/main/java/io/sentry/SentryStackTraceFactory.java#L40-L44

we filter stack traces from our own package.

if you look at your example, the Java async task class is com.example.sentry_mobile package.
but the MainActivity is io.sentry.sentry_mobile, so it'll be filtered out.

ideally, the solution would be to rename the package, to never start with io.sentry. but rather io.sentrymobile.app or something that bypasses the check mentioned above.

if you think that the package should be called io.sentry.mobile or something like that, we could special case as we did with io.sentry.samples.

@marandaneto
Copy link
Contributor

the 2 iOS issues related to No application methods in stack trace are pretty much the same as the Android ones so #184 fixes it

@marandaneto
Copy link
Contributor

marandaneto commented Nov 24, 2020

related to the EXC_BAD_ACCESS, looks like even on a plain cocoa event (no Flutter), on release mode, also runs into this, I'll get someone into this but looks like a Cocoa SDK issue and not a Flutter one, so not a blocker (for now).

@marandaneto
Copy link
Contributor

@denrase that's all, thanks for doing this, we've fixed the issue that caused most of the missing app's stack traces, they were all related to the same bug.

the iOS bad access one will be investigated by our iOS team.

you need to rename your android package to not start with io.sentry., so you get the app's stack traces for Android.

the message channel exceptions should be used along with catchError as we can't do it automatically.

@marandaneto
Copy link
Contributor

marandaneto commented Nov 24, 2020

@denrase that's all, thanks for doing this, we've fixed the issue that caused most of the missing app's stack traces, they were all related to the same bug.

the iOS bad access one will be investigated by our iOS team.

this is a limitation of the ecosystem
https://developer.apple.com/documentation/xcode/diagnosing_issues_using_crash_reports_and_device_logs/identifying_the_cause_of_common_crashes/addressing_crashes_from_swift_runtime_errors?language=objc
on debug mode, they preserve the error message, but not on release mode.

you need to rename your android package to not start with io.sentry., so you get the app's stack traces for Android.

the message channel exceptions should be used along with catchError as we can't do it automatically.

@denrase
Copy link
Collaborator Author

denrase commented Nov 24, 2020

Nice thanks! Will do the renaming 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants