https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
s

Sarvesh Sharma

12/21/2020, 8:25 AM
I'm using Touchlab's CrashKiOS to try to view my crashes happening in the KMM module, I'm still not able to view the actual crashes and the stack trace I see on the portal is from Xcode only, i.e., till the KMM interface visible in Xcode. I've located all the dSYMs in the system and added them to the upload script. I'm using the latest version for Crashlytics, i.e., Firebase Crashlytics for the same.
a

Alex Pogrebnyak

12/21/2020, 9:13 AM
I can recommend another multiplatform lib for this - https://github.com/icerockdev/moko-crash-reporting
And one more thing you have to consider - KMM module should be framework
k

kpgalligan

12/21/2020, 2:36 PM
If you're running from Xcode and trying to test crashes, Xcode prevents crashes from happening when you're attached to it. This isn't specific to Kotlin. It's true for Swift/Objc dev as well. You'll need to hit "stop" and run the app directly in the simulator.
An unhandled crash in CrashKiOS will trigger 2 reports. There's the "hard crash" that is the unhandled crash, and a handled crash that presents the stack trace from Kotlin. In future versions we may try to directly instrument the Crashlytics client to generate a single crash, but that's problematic for production apps (IMHO)
s

Sarvesh Sharma

12/21/2020, 7:05 PM
Hey Kevin, thanks for chiming in. So from what I can understand, every time an exception is thrown from the KMM module, we'll be able to get the stack trace from Kotlin, but not for an unhandled exception? Also, instead of generating a single crash, can we give the Kotlin stack trace for the hard crashes as well?
k

kpgalligan

12/21/2020, 10:50 PM
So from what I can understand, every time an exception is thrown from the KMM module, we'll be able to get the stack trace from Kotlin, but not for an unhandled exception?
Kotlin bubbles up exceptions in a manner similar to Java/JVM. Swift and Objc are different and exception bubbling up isn't as ingrained. If you call a Kotlin method from Swift/Objc, whatever happens after that border happens in "Kotlin land" with Kotlin rules. So, if you call code that throws an exception, you can catch it in Kotlin at any point up until it gets to the border of where you called it from Swift/Objc. If it gets to that point, it's "unhandled". By default, what happens then is the Kotlin runtime tells Swift/objc to abort. If you have Crashlytics set up as usual, you'll get an unhandled exception that will basically say Kotlin called abort. It will look something like this
Kotlin provides a default handler for exceptions, which will get called if you set it and you get an uncaught exception. CrashKios at that point is configured to send an additional crash report with the Kotlin symbolication intact. It looks more like this
So, an uncaught exception from Kotlin would trigger 2. reports on Crashlytics. Unless the Crashlytics client has changed, you wouldn't really be able to merge that into one, although it's something we'll look into at some point.
Also, instead of generating a single crash, can we give the Kotlin stack trace for the hard crashes as well?
I'm not sure I'm understanding the questions here. Just want to be clear, "hard crashes" that occurred after a Kotlin call will produce the hard crash record like the first screenshot, and an additional "handled" record with Kotlin info like the second screenshot. You can also catch and report handled exceptions without crashing.
s

Sarvesh Sharma

12/22/2020, 9:39 PM
Thanks a lot for the insights Kevin, resolved my issue.
7 Views