{ "id": "171409", "key": "TIMOB-25906", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "20115", "name": "Release 7.3.0", "archived": false, "released": true, "releaseDate": "2018-08-17" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-05-04T07:59:05.000+0000", "created": "2018-03-27T08:04:53.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "mainthread", "try-catch" ], "versions": [], "issuelinks": [ { "id": "56514", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "171025", "key": "TIMOB-25747", "fields": { "summary": "iOS: Modal error dialog not shown when using main-thread", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "56515", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "171603", "key": "TIMOB-26007", "fields": { "summary": "iOS: Refactor RSOD", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } }, { "id": "56535", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "171665", "key": "TIMOB-26048", "fields": { "summary": "Windows: Refactor RSOD", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } } ], "assignee": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-07-05T18:11:07.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "According to the documentation I should get an exception when I try to parse invalid XML with Ti.XML.parseString, but instead the \"catch\" handler is not called. So either this is a bug or the docs are wrong.\r\n\r\n{code:javascript}\r\ntry {\r\n var doc = Ti.XML.parseString(\"some invalid XML\");\r\n} catch (ex) {\r\n // On iOS we never get here\r\n console.log(\"Exception\");\r\n}\r\n{code}\r\n\r\n*EDIT by [~hknoechel]*: Updating ticket to focus on exceptions on the main thread. The underlaying issue is that we currently do not throw native exceptions (using {{@throw}}) when running on main-thread. While this does not crash the app, it still limits the functionality of developers, so it should be fixed. ", "attachment": [], "flagged": false, "summary": "iOS: Native exceptions not thrown when using run-on-main-thread", "creator": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "environment": "SDK 7.1.0.GA\r\nMac OS High Sierra, 64bit\r\nNode 8.9.1\r\niOS", "comment": { "comments": [ { "id": "435957", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Quick question: In the title you mention iOS, in the environment Android. Where is this happening? Tested on iOS and it indeed does not call the exception, but also does not crash, it simply logs it:\r\n\r\n{code:js}\r\nvar win = Ti.UI.createWindow({ backgroundColor: '#fff' });\r\n\r\nvar button = Ti.UI.createButton({\r\n title: 'Trigger'\r\n});\r\n\r\nbutton.addEventListener('click', function() {\r\n try {\r\n var doc = Ti.XML.parseString(\"some invalid XML\");\r\n } catch (ex) {\r\n // On iOS we never get here\r\n console.log(\"Exception\");\r\n }\r\n});\r\n\r\nwin.add(button);\r\nwin.open();\r\n{code}\r\n\r\n[~vijaysingh] Looking in the source, it might be related to the main-thread vs kroll-thread safety. Can you take a look?", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-03-27T08:51:33.000+0000", "updated": "2018-03-27T08:58:28.000+0000" }, { "id": "435964", "author": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "body": "Sorry my mistake: It's happening on iOS, I haven't tested it on Android.", "updateAuthor": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-03-27T10:35:06.000+0000", "updated": "2018-03-27T10:35:06.000+0000" }, { "id": "435965", "author": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "body": "I have checked it again and the reason my app crashes is that I did not check the \"doc\" variable. This was null, so trying to get doc.documentElement causes the app to crash, not the parsing of invalid XML.\r\n\r\nThere is still a bug though or the documentation should be adjusted.\r\n\r\nA simple solution is to check for the result. ", "updateAuthor": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-03-27T10:43:04.000+0000", "updated": "2018-03-27T10:43:04.000+0000" }, { "id": "436013", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": " On Kroll thread it is working fine. Problem is with main thread. I'll look in this.", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-03-28T08:28:04.000+0000", "updated": "2018-03-28T08:28:04.000+0000" }, { "id": "436017", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "If I see in code in TiBase.m file -\r\n\r\n{code:java}\r\nvoid TiExceptionThrowWithNameAndReason(NSString *exceptionName, NSString *reason, NSString *subreason, NSString *location)\r\n{\r\n if (TiExceptionIsSafeOnMainThread || ![NSThread isMainThread]) {\r\n NSDictionary *details = [NSDictionary dictionaryWithObjectsAndKeys:subreason, kTiExceptionSubreason, location, kTiExceptionLocation, nil];\r\n @throw [NSException exceptionWithName:exceptionName reason:reason userInfo:details];\r\n } else {\r\n NSString *message = [NSString stringWithFormat:@\"%@. %@ %@\", reason, (subreason != nil ? subreason : @\"\"), (location != nil ? location : @\"\")];\r\n NSLog(@\"[ERROR] %@\", message);\r\n }\r\n}\r\n{code}\r\n\r\nIf we are on main thread here, it will not throw exception. Only it will log the error. If I remove the condition it is working fine. Need to dig out more why this condition was required.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-03-28T09:55:58.000+0000", "updated": "2018-03-28T10:04:51.000+0000" }, { "id": "436025", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR - https://github.com/appcelerator/titanium_mobile/pull/9966\r\n\r\nTest case from TIMOB-5337 -\r\n\r\n\r\n{code:js}\r\nvar tab1, tab2, win;\r\nvar tabs = Ti.UI.createTabGroup();\r\ntabs.addTab(tab1 = Ti.UI.createTab({\r\n title: 'Click here (1)',\r\n window: win = Ti.UI.createWindow({\r\n rightNavButton: Ti.UI.createButton({\r\n title: 'Launch Popover',\r\n url: 'what'\r\n })\r\n })\r\n}));\r\n\r\nvar contentWindow = Ti.UI.createWindow({\r\n title: 'Test crash popover'\r\n});\r\ncontentWindow.add(Ti.UI.createLabel({\r\n text: \"It's not easy being green.\"\r\n}));\r\n\r\nwin.rightNavButton.addEventListener('click',\r\n function() {\r\n Ti.UI.iPad.createPopover({\r\n contentView: Ti.UI.iOS.createNavigationWindow({\r\n width: 250,\r\n height: 100,\r\n window: contentWindow\r\n })\r\n }).show({\r\n view: win.rightNavButton\r\n });\r\n });\r\ntabs.addTab(tab2 = Ti.UI.createTab({\r\n title: 'Click here',\r\n window: Ti.UI.createWindow({\r\n url: 'what'\r\n })\r\n}));\r\ntabs.open();\r\n\r\nfunction cycle() {\r\n tabs.setActiveTab(0);\r\n win.rightNavButton.fireEvent('click');\r\n tabs.setActiveTab(1);\r\n}\r\n\r\nwin.addEventListener('open', cycle);\r\nsetInterval(cycle, 1000);\r\n{code}", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-03-28T12:06:33.000+0000", "updated": "2018-03-28T12:33:04.000+0000" }, { "id": "439019", "author": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-07-05T18:10:49.000+0000", "updated": "2018-07-05T18:10:49.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }