Yeah, that’s not a mistake. I’ve just faced with one special (probably rare) case where the installation time of Symbian QML application had been reduced from 8 min to 30 sec.
How much time do you think
could take an installation of 15Mb symbian sis package file without SmartInstaller wrapping? A
minute, two? Actually, the right answer depends mostly not on the sis file size
but on the number of files in sis package. In general, sis package is just a zip archive
with installation script inside. Script execution and file I/O operations
took most of the time. In my case I had a QML application with a bit more than
500 image files inside. And it tooks 8 min for my N8-00 to install it on
embedded memory card and 3,5 to uninstall. Yeah, there might be applications
that require so many graphic files, for example ebooks and card-learning
systems as well as games.
To make sure the problem is
not sis size dependent I replaced all image files (~19Mb) with only 2 files 10Mb each.
And installation proceeds 10 times faster.
So, could we put all
application resources in one big file to speed up the installation process?
Sure we can with help of The Qt resource system. But there is one big disadvantage: whole
resource file have to be loaded into process memory before you can access
anything inside it. That means if you can’t split your data between resource
files and switch between them during application execution (most probably
application logic doesn’t allow that) you have to load all files in memory when
application starts. In my case that was impossible to do because even EPOCSIZE
tweaks couldn’t help me to avoid *out of memory* crash.
Fortunately I had a deal
with image files and found out that QML architects providently took care about
overloading image providers in QML. Qt 4.7 contains a nice class called QDeclarativeImageProvider. It provides an interface for supporting
pixmaps and threaded image requests in QML. In other words you can derive from that class, create own object from the derived class and attach it to QML engine with certain key (qstring)
value. Every time QML engine try to resolve image source
"image://you_key/somefile_id.jpg" it will invoke your object’s method with
somefile_id.jpg as parameter and will expect QImage or QPixmap in return.
So, the solution is
obvious. All i need is to put all my image files in zip and implement my
QDeclarativeImageProvider-derived class that could read images from the zip. I chose
QuaZip library for reading zip’s. Some code snippets are below. Also you can
find sample project in the attachment.
Declaring our ImageReader class:
Then it could be attached to the QML declarative engine (that should be done before you open any qml file in it):
Here images.zip is our data file and myzip – our keyword.
Now we can use any image from that zip in our qml file like that:
01_sdk_download_v4.jpg will be retrieved from the images.zip when necessary.
Sample project: ZIPDeclarativeImageProvider.zip