{ "id": "171127", "key": "TIMOB-25785", "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-04-23T19:38:56.000+0000", "created": "2018-02-16T12:54:35.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "events", "ios", "json", "regression" ], "versions": [ { "id": "17609", "description": "", "name": "Release 7.0.0", "archived": false, "released": true, "releaseDate": "2017-12-07" } ], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2018-06-26T20:44:34.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": "Here is a code :\r\nalloy.js\r\n\r\n\r\n{code:javascript}\r\nTi.Gesture.addEventListener('orientationchange', function (e) {\r\n Ti.App.fireEvent('_customEvent', e);\r\n});\r\n\r\nTi.App.addEventListener('_customEvent', function () {});\r\n\r\n{code}\r\n\r\nThis triggers an error on orientation change\r\n\r\n{noformat}\r\n[ERROR] : Script Error {\r\n[ERROR] : column = 19;\r\n[ERROR] : line = 13;\r\n[ERROR] : message = \"Invalid type in JSON write (GestureModule)\";\r\n[ERROR] : sourceURL = \"file:///Users/houra/Library/Developer/CoreSimulator/Devices/599E21F7-4A9F-4B60-8864-1CE1485B4360/data/Containers/Bundle/Application/F13B31FA-B6FE-4372-A3FF-AFC5B5E2F1F9/Clean.app/app.js\";\r\n[ERROR] : }\r\n{noformat}\r\n\r\n", "attachment": [], "flagged": false, "summary": "iOS: Sending events that cannot be serialized fail on SDK 7.0.0+", "creator": { "name": "gduthieuw", "key": "gduthieuw", "displayName": "Guile", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "gduthieuw", "key": "gduthieuw", "displayName": "Guile", "active": true, "timeZone": "Europe/Berlin" }, "environment": "iOS 11\r\nSDK7.0.0->7.0.2", "closedSprints": [ { "id": 1028, "state": "closed", "name": "2018 Sprint 09 SDK", "startDate": "2018-04-22T22:53:08.928Z", "endDate": "2018-05-06T22:53:00.000Z", "completeDate": "2018-05-07T00:02:15.883Z", "originBoardId": 114 }, { "id": 1018, "state": "closed", "name": "2018 Sprint 07 SDK", "startDate": "2018-03-25T21:59:36.637Z", "endDate": "2018-04-08T21:59:00.000Z", "completeDate": "2018-04-08T17:55:14.467Z", "originBoardId": 114 }, { "id": 1021, "state": "closed", "name": "2018 Sprint 08 SDK", "startDate": "2018-04-08T17:57:36.122Z", "endDate": "2018-04-22T17:57:00.000Z", "completeDate": "2018-04-22T22:51:19.120Z", "originBoardId": 114 }, { "id": 1008, "state": "closed", "name": "2018 Sprint 06 SDK", "startDate": "2018-03-11T22:18:04.396Z", "endDate": "2018-03-25T22:18:00.000Z", "completeDate": "2018-03-25T21:52:36.683Z", "originBoardId": 216 } ], "comment": { "comments": [ { "id": "434566", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey there,\r\n\r\ndid this work before 7? If so, it actually shouldn't, because you are passing a whole namespace to the event which is a) very very expensive in terms of performance and b) bad for your app scope. The underlaying reason is that an object cannot be stringified which is required to send over the event.\r\n\r\n*EDIT*: I just tested on 6.3.0 and it works, so we will fix it.\r\n\r\nTest-Case:\r\n{code:js}\r\n/**\r\n * This file is used to validate iOS test-cases. It is ran using the Xcode\r\n * project in titanium_mobile/iphone/iphone/Titanium.xcodeproj.\r\n *\r\n * Change the below code to fit your use-case. By default, it included a button\r\n * to trigger a log that is displayed in the Xcode console.\r\n */\r\n\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#fff'\r\n});\r\n\r\nvar btn = Ti.UI.createButton({\r\n title: 'Trigger'\r\n});\r\n\r\nbtn.addEventListener('click', function() {\r\n var validObject, validArray, invalidObject, invalidArray;\r\n\r\n validObject = {\r\n nl: null,\r\n num: 123,\r\n str: 'tirocks',\r\n arr: [null, 123, 'tirocks', { num: 123, str: 'tirocks' }],\r\n obj: {\r\n nl: null,\r\n num: 321,\r\n str: 'skcorit'\r\n }\r\n };\r\n\r\n validArray = [null, 123, 'tirocks', { nl: null, num: 123, str: 'tirocks' }, [null, 123, 'tirocks', { num: 123, str: 'tirocks' }]];\r\n\r\n invalidObject = {\r\n tiGesture: Ti.Gesture,\r\n proxy: Ti.UI.createLabel({ text: 'Whoops' }),\r\n num: 123,\r\n str: 'tirocks',\r\n arr: [123, 'tirocks', { num: 123, str: 'tirocks' }],\r\n obj: {\r\n num: 321,\r\n str: 'skcorit'\r\n }\r\n };\r\n\r\n invalidArray = [Ti.Gesture, Ti.UI.createLabel({ text: 'Whoops' }), 123, 'tirocks', { num: 123, str: 'tirocks' }, [123, 'tirocks', { num: 123, str: 'tirocks' }]];\r\n\r\n Ti.App.fireEvent('test', validObject);\r\n Ti.App.fireEvent('test', { arr: validArray });\r\n Ti.App.fireEvent('test', invalidObject);\r\n Ti.App.fireEvent('test', { arr: invalidArray });\r\n});\r\n\r\nTi.App.addEventListener('test', function (e) {\r\n Ti.API.info(e);\r\n});\r\n\r\nwin.add(btn);\r\nwin.open();\r\n{code}\r\n\r\nPR: https://github.com/appcelerator/titanium_mobile/pull/9856", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-02-16T13:31:21.000+0000", "updated": "2018-02-17T09:14:36.000+0000" }, { "id": "434644", "author": { "name": "gduthieuw", "key": "gduthieuw", "displayName": "Guile", "active": true, "timeZone": "Europe/Berlin" }, "body": "I've seen your PR, there is something uncomfortable : you should assume the BC Break, as it exists right now in GA and not going back to your initial decision in the serialization of the event parameter.\r\n\r\nThe fact is that I changed my code to make it work with 7.0.2 and I won't go back on it.\r\n\r\nSo let's assume that TI.Gesture can not be stringify in JSON. Document it clearly.\r\n\r\nWhat do you think about it ?", "updateAuthor": { "name": "gduthieuw", "key": "gduthieuw", "displayName": "Guile", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-02-20T10:55:10.000+0000", "updated": "2018-02-20T10:55:10.000+0000" }, { "id": "434721", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey there! The PR fixes exactly that by restoring the old behavior. In addition, it now throws a warning if you still do. In case of your exact case, you are sending the whole event you receive for convenience, although not all properties of the event are required. The PR basically checks for unserializable object fragments and removes them + warns you in case it finds them. This was done before as well, but using a third party library that was removed in Titanium 7. Would you agree on the change? And again, if it really is such an issue, you can simply replace {code:js}\r\nTi.App.fireEvent('_customEvent', e);\r\n{code} \r\nwith \r\n{code:js}\r\ndelete e.source;\r\nTi.App.fireEvent('_customEvent', e);\r\n{code}\r\nA more elegant solution really would be to only pass the required info, e.g. the orientation, but thats fine. I will also document the general behavior. ", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-02-21T19:51:14.000+0000", "updated": "2018-02-21T19:51:14.000+0000" }, { "id": "434722", "author": { "name": "gduthieuw", "key": "gduthieuw", "displayName": "Guile", "active": true, "timeZone": "Europe/Berlin" }, "body": "The warning is fine, so the PR ;-)\r\n\r\nI've already fixed my code by not passing through the event object. Thank you !", "updateAuthor": { "name": "gduthieuw", "key": "gduthieuw", "displayName": "Guile", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-02-21T19:56:29.000+0000", "updated": "2018-02-21T19:56:29.000+0000" }, { "id": "434724", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Happy to hear, thank you! And sorry for causing this, this is properly unit-tested now as well :-).", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-02-21T19:59:03.000+0000", "updated": "2018-02-21T19:59:03.000+0000" }, { "id": "438736", "author": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "body": "*Closing ticket.* Verified fix can be seen in SDK Version: {{7.3.0.v20180618182516}}\r\n\r\n*FR (Passed) Test Steps:*\r\n# Created an application with the code above in the comments\r\n# Ran the program\r\n# Application no longer errors out and the following warnings can be seen\r\n{code:java}\r\n[DEBUG] : Firing app event: test\r\n[WARN] : Cannot serialize object, trying to repair ...\r\n[WARN] : Found invalid value \"[object GestureModule]\" that cannot be serialized, skipping it ...\r\n[WARN] : Found invalid value \"[object TiUILabel]\" that cannot be serialized, skipping it ...\r\n{code}\r\n\r\n*Test Environment*\r\n{code:java}\r\nAPPC Studio: 5.0.0.201712081732\r\nAPPC CLI: 7.0.4\r\niphone 6 (11.2) Emulator\r\nOperating System Name: Mac OS High Sierra\r\nOperating System Version: 10.13\r\nNode.js Version: 8.9.1\r\nXcode 9.2\r\n{code}\r\n", "updateAuthor": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-26T20:44:17.000+0000", "updated": "2018-06-26T20:44:17.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }