Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

ScrollView loads slow

$
0
0

Titanium Info

Application type: mobile Titanium SDK: Titanium Command-Line Interface, CLI version 3.3.0, Titanium SDK version 3.3.0.GA Device: iPad mini Host Operating System: OSX 10.9.3 Titanium Studio, build: 3.3.0.201407100905 Build: jenkins-titanium-rcp-master-164 (origin/master)

I'm having some problems with how long a Titanium app I am making takes to load a ScrollView.

I decided to run a test, comparing how long it would take for a titanium app to load a similar view, and a native built version (iOS).

The test was loading 1000 textfields into a ScrollView.

For the natively built app, it took about 0.850 seconds to load on an iPad mini (based on 3 trials).

For the titanium built app, it took about 59.3 seconds to load on the same iPad mini (based on 3 trials).

Obviously, this is a significant difference. My code for the Titanium build is below. Is there something I'm missing? Some option that is making the ScrollView so slow? 59 seconds compared to 0.850 is pretty significant.

index.xml

<Alloy>
        <Window class="container" >
            <ScrollView id="scrollView" layout="vertical"></ScrollView>
        </Window>
    </Alloy>
index.tss
".container": {
        backgroundColor:"white"
    }
index.js
var startTime = new Date();
    startTime = startTime.getTime() / 1000;
 
    $.index.addEventListener('postlayout', calculateTimeToLoad);
 
    loadThousandTextFields();
 
    function calculateTimeToLoad() {
        $.index.removeEventListener('postlayout',calculateTimeToLoad);
        var endTime = new Date();
        endTime = endTime.getTime() / 1000.0;
 
        Ti.API.info("Total time taken:" + (endTime - startTime) + " seconds"); 
    }
 
    function loadThousandTextFields() {
        for(var i = 0; i < 1000; i++) {
            $.scrollView.add(Ti.UI.createTextField({
                hintText: "Hint text"
            }));
        }
    }
 
    $.index.open();

Note: I am aware of Titanium's ListView, however, based on my experiments with it, it looks like it won't work too well with the app I am making, as I need interaction between my various components and the ability to change them based on that interaction. (For example, having a switch that, upon being turn off, would clear a nearby textfield, or fill it with some text. ListViews seem to be very slow in updating views like that. If I'm wrong, please let me know).

Further Note: I tried running the same test on 3.2.3, and it took about 6 seconds as opposed to 59, on the same iPad mini. However, in my app, the scrollview actually took longer to load.

Thanks


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>