{ "id": "176143", "key": "TIMOB-28412", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "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": "21199", "description": "", "name": "Release 10.0.1", "archived": false, "released": true, "releaseDate": "2021-07-28" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2021-06-17T11:53:30.000+0000", "created": "2021-04-02T01:43:38.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "async", "iOS", "performance", "promise" ], "versions": [], "issuelinks": [], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2021-06-17T11:53:30.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": "*Summary:*\r\nOn iOS 12 and older versions, there is no native API to create a JavaScript {{Promise}}. So, we create promises via a JS {{eval()}} as shown below...\r\nhttps://github.com/appcelerator/titanium_mobile/blob/master/iphone/TitaniumKit/TitaniumKit/Sources/Kroll/KrollPromise.m#L35-L49\r\n\r\n*To-Do:*\r\nWe should optimize this so that we don't do an {{eval()}} every time a promise needs to be created. Simplest solution is to only create the JS promise handling function once and re-use it.\r\n\r\n*Note:*\r\nApple documents that {{evaluateScript()}} will add function/variable definitions permanently to the global context.\r\nhttps://developer.apple.com/documentation/javascriptcore/jscontext/1451350-evaluatescript\r\n\r\nThis means we should use a unique prefixing convention to avoid collision.\r\n\r\nAlso, every time we define our JS {{executor()}} and {{createPromise()}} functions, theoretically we're slowly bloating the JS global context with these re-definitions. This may be a slow memory leak.", "attachment": [], "flagged": false, "summary": "iOS: Optimize JS Promise creation on iOS 12", "creator": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "458519", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR (master): https://github.com/appcelerator/titanium_mobile/pull/12684", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2021-04-02T01:54:23.000+0000", "updated": "2021-04-02T01:54:23.000+0000" }, { "id": "458795", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "master and backport merged", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2021-06-17T11:53:25.000+0000", "updated": "2021-06-17T11:53:25.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }