{ "id": "175271", "key": "AC-6572", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "10000", "description": "", "name": "Done" }, "resolutiondate": "2020-08-18T14:10:58.000+0000", "created": "2020-07-08T22:35:36.000+0000", "labels": [], "versions": [], "issuelinks": [ { "id": "58522", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "174093", "key": "TIMOB-27377", "fields": { "summary": "iOS: Disable minifying of Javascript source", "status": { "description": "Submitted for code review", "name": "In Review", "id": "10003", "statusCategory": { "id": 4, "key": "indeterminate", "colorName": "yellow", "name": "In Progress" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } } ], "assignee": { "name": "amukherjee", "key": "amukherjee", "displayName": "Abir Mukherjee", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2020-08-18T14:10:58.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": [], "description": "When running an Alloy project on a device or releasing an Adhoc or an App store version, thus running the project through a pipeline where Javascript files are additionally processed, odd behavior is observed where a block of code may not executed, without any compilation or runtime errors.\r\n\r\n*Steps to reproduce:*\r\n* Create a new default Alloy Project \r\n* add example code below to in index.js controller\r\n* run project on an iOS device (run directly, just without LiveView; or create and install an Adhoc build; or create and install AppStore build through Testflight)\r\n\r\n*Expected result:*\r\n* setTiProps function should've run in entirety and styling should be applied to the Label (correct_screenshot.png)\r\n* OR if any part of the example Javascript is invalid, a compilation error or a runtime error should've been triggered\r\n\r\n*Actual result:*\r\n* setTiProps function is somehow not executed in its entirety and styling is thus not applied to the Label (incorrect_screenshot.png)\r\n\r\nh4. Additional observations - please note that this is *not* a styling issue\r\n\r\nThe correct and expected result is shown in the following cases:\r\n* by running on an actual device _with_ LiveView enabled\r\n* by running on an iOS simulator _with_ or _without_ LiveView\r\n* most unexpectedly, by modifying the example code through inserting *any dummy line* into the setTiProps function just before the _for_ loop, such as: console.log(\"Here\");\r\n* (also, by compiling and running the code with SDK 7.4 and lower)\r\n\r\nThe above observations lead me to postulate that one of the steps active in additional Javascript processing for device builds (minimization, obfuscation, encryption, ...?) encounters a situation in the example code that causes it to silently modify the function in a way that it makes it not run all the way through, all without triggering any compilation or runtime errors - this makes it particularly challenging to track down the real issue as most attempts to debug the code will cause it run correctly again (either by modifying the code with log statements or creating a debug build that then skips the troublesome Javascript processing pipeline).\r\n\r\n----\r\n\r\n_index.js:_\r\n{code:java}\r\nvar ALLOWED_PROPS = [\r\n\t\"backgroundColor\",\r\n\t\"borderColor\",\r\n\t\"borderRadius\",\r\n\t\"borderWidth\",\r\n\t\"height\",\r\n\t\"width\",\r\n];\r\n\r\nfunction setTiProps(args, component) {\r\n\r\n\tif (!component) return;\r\n\r\n\tvar args = args || {}, prop = '';\r\n\r\n\tfor(var i = 0, j = ALLOWED_PROPS.length; i < j; i++){\r\n\t\tprop = ALLOWED_PROPS[i];\r\n\t\tif(typeof args[prop] !== \"undefined\") {\r\n\t\t\tcomponent[prop] = args[prop];\r\n\t\t}\r\n\t}\r\n};\r\n\r\nsetTiProps({\r\n \"backgroundColor\": \"red\",\r\n \"borderColor\": \"green\",\r\n \"width\": \"100%\",\r\n \"height\": \"50dp\"\r\n}, $.label);\r\n\r\nfunction doClick(e) {\r\n\talert($.label.text);\r\n}\r\n\r\n$.index.open();\r\n{code}\r\n", "attachment": [ { "id": "67466", "filename": "correct_screenshot.png", "author": { "name": "ravsec", "key": "ravsec", "displayName": "Roman Avsec", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-07-08T22:36:42.000+0000", "size": 83250, "mimeType": "image/png" }, { "id": "67465", "filename": "incorrect_screenshot.png", "author": { "name": "ravsec", "key": "ravsec", "displayName": "Roman Avsec", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-07-08T22:36:42.000+0000", "size": 82195, "mimeType": "image/png" }, { "id": "67468", "filename": "index.working-correctly.js", "author": { "name": "ravsec", "key": "ravsec", "displayName": "Roman Avsec", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-07-08T22:37:07.000+0000", "size": 602, "mimeType": "application/x-javascript" }, { "id": "67467", "filename": "index.working-incorrectly.js", "author": { "name": "ravsec", "key": "ravsec", "displayName": "Roman Avsec", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-07-08T22:37:07.000+0000", "size": 576, "mimeType": "application/x-javascript" } ], "flagged": false, "summary": "iOS: when running a on a device, Javascript compilation results in a particular block of code not being executed, without errors", "creator": { "name": "ravsec", "key": "ravsec", "displayName": "Roman Avsec", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "ravsec", "key": "ravsec", "displayName": "Roman Avsec", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "* OS: Mac OS Mojave 10.14.6\r\n* Java version: 1.8.0_162\r\n* Xcode: 11.3.1\r\n* Node.js: v10.13.0\r\n* Appcelerator CLI: 8.0.0\r\n* Ti SDK: 9.0.3 (also tried with 8.3.1)\r\n* iOS: 13.3, 13.5\r\n* tiapp.xml use-jscore-framework: tried with both, true and false", "comment": { "comments": [ { "id": "456048", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "[~ravsec] firstly, thank you for such a complete bug report!\r\n\r\nI've took a look into this and it does look to be a problem with the package we use for minification (babel-minify), it appears that when minifying the {{setTiProps}} function it inlines the declaration of {{args}} and {{prop}} into the for loop definition (code below) I believe this is the root cause of the issue you're seeing.\r\n\r\n{code:javascript}\r\nfunction setTiProps(args,component){\r\n\r\n\tif(component)\r\n\r\n\tfor(var args=args||{},prop=\"\",i=0,j=ALLOWED_PROPS.length;void 0>i;i++) {\r\n\t\tprop=ALLOWED_PROPS[i],\r\n\t\t\"undefined\"!=typeof args[prop]&&(\r\n\t\tcomponent[prop]=args[prop]);\r\n\t}\r\n};\r\n{code}\r\n\r\nI was able to fix this without requiring disabling js minification by changing {{setTiProp}} to the following:\r\n\r\n{code:javascript}\r\nfunction setTiProps(args, component) {\r\n \r\n\tif (!component) return;\r\n \r\n\targs = args || {};\r\n\tfor(const prop of ALLOWED_PROPS){\r\n\t\tif(typeof args[prop] !== \"undefined\") {\r\n\t\t\tcomponent[prop] = args[prop];\r\n\t\t}\r\n\t}\r\n};\r\n{code}\r\n\r\nDo you want to give that a try and let me know how it goes?", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2020-07-13T11:47:18.000+0000", "updated": "2020-07-13T11:47:18.000+0000" }, { "id": "456105", "author": { "name": "ravsec", "key": "ravsec", "displayName": "Roman Avsec", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Thank you for your response Ewan.\r\n\r\nIn the meantime I've refactored that particular piece of code to more modern standards as well - it was a very old piece of code as evidenced by the coding standards used :) That seemed to have avoided triggering the minimization bug. Your approach works well too!", "updateAuthor": { "name": "ravsec", "key": "ravsec", "displayName": "Roman Avsec", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-07-15T20:03:23.000+0000", "updated": "2020-07-15T20:03:23.000+0000" }, { "id": "456503", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "I'm going to close this one out as the underlying issue was fixed", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2020-08-18T14:10:53.000+0000", "updated": "2020-08-18T14:10:53.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }