Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-28412

iOS: Optimize JS Promise creation on iOS 12

    Details

    • Story Points:
      3

      Description

      Summary:
      On 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...
      https://github.com/appcelerator/titanium_mobile/blob/master/iphone/TitaniumKit/TitaniumKit/Sources/Kroll/KrollPromise.m#L35-L49

      To-Do:
      We 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.

      Note:
      Apple documents that evaluateScript() will add function/variable definitions permanently to the global context.
      https://developer.apple.com/documentation/javascriptcore/jscontext/1451350-evaluatescript

      This means we should use a unique prefixing convention to avoid collision.

      Also, 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.

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              jquick Joshua Quick
              Reviewer:
              Christopher Williams
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Integration