Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Titanium Mobile JavaScript/Native Development


I am a relatively new Titanium Mobile user.
I started using Titanium because the possibility for developing (semi-)native applications for the most popular mobile platforms (iPhone, Android, Blackberry in the making) was very promising.

However, in the past monhts I began to lose my confidence in the platform, based on accumulated knowledge of its inner workings. I am not quite ready to abandon all hope yet, so I will ask several general questions, hoping that I have mis-understood something or there are other ways.

First, let me state my goals: I want to build an application infrastructure around Titanium. I need to achieve the following goals:

  • Goal1. Be able to develop/deploy native UI on iPhone/Android client devices.
  • Goal2. Be able to implement and expose server-hosted services in uniform manner, that can be easily consumed by the mobile clients mentioned in Goal1.
  • Goal3. Goal1 and Goal2 must be achieved productively, with little overhead per new project.

>What have I done up until now:

  • (Goal1) Obviouslu, using Titanium, I am able to create native interfaces for the target platforms
  • (Goal2) I have chosen a common platform-independent protocol for communication: XML-RPC
  • (Goal2) I have implemented a Java-XMLRPC bridge, which makes exposing pure Java services a breeze
  • (Goal2) I have modified a JavaScript XML-RPC client to work on the iPhone. This client converts XML-RPC documents to JavaScript objects. The client uses the HttpRequest Titanium object to perform remote invocations

>Going back to the point of this topic - my

  • Problem1. The iPhone XML-RPC client is very slow and takes up LARGE amounts of memory for heavier requests. I have tried to analyze the situation using XCode's instruments. I can see MANY objects of type TiDOMElementProxy and TiDOMNodeListProxy. Below you can find a screenshot of Xcode Instruments Leaks. It is made afted one (!) XML-RPC request was made returning around 100 serialized objects with their properties in XML:
    (Please note that if we invoke the service only without working with the result, such objects are not created)

Titanium Project in XCode Leaks

>So, here are some related questions:

  • Question1. The most general question: Am I right in the following assumption: Titanium Mobile is executed as JavaScript (within WebKit), with some hooks that redirect specific JavaScript calls to the Objective-C universe. If this is correct, how are objects passed between these two universes and what is the overhead of these operations? I can only imagine that some kind of pairs (JavaScript proxy)/(Objective-C proxy + real object) exist in order for the framework to operate.

>And a more detailed question:

  • Question2. Am I right in the following assumption: The HttpRequest.xmlResponse returns a proxy to a Objective-C DOM tree, which (as a single proxy) is not a performance and memory hog. But then, the JavaScript XML-RPC parser starts to pull parts of the DOM tree into JavaScript objects - Strings, numbers, dates, arrays, maps. Each pulled part of the DOM tree needs a pair of JavaScript variable and Objective-C proxy. We end up having thousands of pairs of javascript/proxy objects. This behaviour heavily affects at least device CPU and Memory.

And the logical question:

  • Question3. Can this be avoided at all? Have someone been the same road and found a way to use XML-based protocols for communication without the overhead described above? Maybe there is a way to use the real JavaScript XMLHttpRequest object - I have the feeling that it will be much lighter and faster?

>Thanks in advance, Georgi

— asked September 26th 2010 by Georgi Denchev
  • javascript
  • native
  • titanium
  • xml

1 Answer

  • Hi Georgi

    I'm working at quite the same thing as you! I implemented the JS-XMLRPC in my application. It works fine with creating a request (although it might be because there are quite few properties) - but processing a response takes forever. Did you find an approach to speed the whole thing up?

    Best regards!

    — answered February 12th 2012 by Lukas Heppler
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.