trackError and trackException do not parse call stack correctly
daleswift opened this issue · comments
Description
When using Swift the stack frames are not parsed correctly. There are several issues:
- The app bundle name may include a hyphen, this causes the symbols to get out of alignment
- Method names may include other variations than Objective C methods e.g. Swift mangled names, simple top level methods names, and sometimes a UUID
Repro Steps
Please list the steps used to reproduce your issue.
- Run a Swift app with bundle name like "bug-splat"
- Call Crashes.trackError
- Observe the results
Details
The problem is in the parsing in [MCAExceptionModel loadStackTrace] which is simply breaking up each line of text of the call stack by punctuation characters " -[]+?.," This does not correctly deal with the possible variations in the format of each line
Call stack text can include lines like these:
2 BugSplat 0x0000000100e46dec $s8BugSplat14ViewControllerC21sendErrorButtonTappedyyypFTo + 48,
2 Bug-Splat 0x0000000100e46dec $s8BugSplat14ViewControllerC21sendErrorButtonTappedyyypFTo + 48,
12 UIKitCore 0x0000000107508644 __dispatchPreprocessedEventFromEventQueue + 1880
10 UIKitCore 0x00000001a006a614 875D830B-862C-3992-8C80-3AA14044915D + 1017364
which are not parsed correctly.
As a workaround I am preprocessing the call stack and the using the constructor
- (instancetype)initWithType:(NSString *)exceptionType
exceptionMessage:(NSString *)exceptionMessage
stackTrace:(NSArray<NSString *> *)stackTrace
- Which SDK version are you using?
5.0.3 - Which OS version did you experience the issue on?
iOS 16.4 - Which Xcode version did you build the app with?
Xcode 14.3 - Which Cocoapods version are you using (run
pod --version
)?
Using SPM - What device version did you see this error on? Were you using an emulator or a physical device?
Simulator and iPhone 13 - What language are you using?
Swift - What third party libraries are you using? n/a
Hello and thanks for reaching out to us, we are looking into this issue.
I apologize for the delay, the fact is that if the stack trace generation format does not suit you, then it is possible to send your MCAExceptionModel with a defined stack trace. Therefore, your workaround is an architecturally expected solution. I will close this issue but if you have any additional questions feel free to reopen it.