[TIMOB-26369] iOS: unhandledException Ti.App event no longer working.
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Critical |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2018-09-22T15:05:24.000+0000 |
| Affected Version/s | Release 7.3.0 |
| Fix Version/s | Release 7.5.0 |
| Components | iOS |
| Labels | n/a |
| Reporter | Richard Lustemberg |
| Assignee | Hans Knöchel |
| Created | 2018-09-06T10:25:41.000+0000 |
| Updated | 2019-05-01T20:25:45.000+0000 |
Description
When stack traces where added to the display of unhandled exceptions in May 2018, the functionality was removed. I can provide a PR to fix that.
Files that need to be modified:
AppModule.m , line 368
[nc addObserver:self selector:@selector(errored:) name:kTiErrorNotification object:nil];
TiExceptionHandler.m , line 58
- (void)showScriptError:(TiScriptError *)error
{
NSArray<NSString *> *exceptionStackTrace = [NSThread callStackSymbols];
if (exceptionStackTrace == nil) {
[[TiApp app] showModalError:[error description]];
[[NSNotificationCenter defaultCenter] postNotificationName:kTiErrorNotification
object:self
userInfo:error.dictionaryValue];
} else {
NSMutableArray<NSString *> *formattedStackTrace = [[[NSMutableArray alloc] init] autorelease];
NSUInteger exceptionStackTraceLength = [exceptionStackTrace count];
// re-size stack trace and format results. Starting at index = 4 to not include the script-error API's
for (NSInteger i = 4; i < (exceptionStackTraceLength >= 20 ? 20 : exceptionStackTraceLength); i++) {
NSString *line = [[exceptionStackTrace objectAtIndex:i] stringByReplacingOccurrencesOfString:@" " withString:@""];
[formattedStackTrace addObject:line];
}
NSString *stackTrace = [formattedStackTrace componentsJoinedByString:@"\n"];
[[TiApp app] showModalError:[NSString stringWithFormat:@"%@\n\n%@", [error description], stackTrace]];
NSMutableDictionary *errorDict = [error.dictionaryValue mutableCopy];
[errorDict setObject:stackTrace forKey:@"stackTrace"];
[[NSNotificationCenter defaultCenter] postNotificationName:kTiErrorNotification
object:self
userInfo:errorDict];
}
}
Hello, please assign the PR to this ticket. Moving it to engineering. Thanks
Done :)
*Closing ticket.* Verified fix in SDK Version
7.5.0.v20181016071050Tested using the following test case:Able to see:Ti.App.addEventListener('uncaughtException', function(evt) { alert({ // Both iOS and Android: message: evt.message, line: evt.line, // iOS Only: sourceId: evt.sourceId, type: evt.type, sourceURL: evt.sourceURL, backtrace: String(evt.backtrace).substr(0, 100) + '...', // Android Only: title: evt.title, sourceName: evt.sourceName, lineSource: evt.lineSource, lineOffset: evt.lineOffset }); }); throw new Error('Hello, error handler!');This was not visible before this fix. *Test Environment*I'm still seeing this issue in 8.0. It was firing for a while but not it doesn't seem to. Unfortunately I can't seem to reproduce the case where it was firing. Android works fine iOS doesn't