1. Steps of preview icons creation.
1) When icon preview needs it be displayed, the application looks up preview cache for existing
preview. If preview isn’t in cache, application sends request for preview.
2) Each individual preview request isn’t sent to MX server. Instead, requests are added to queue to
be sent to server in a bunch with previewer/covers request.
3) This is how the queue works: when the first request is added to the queue, a timer is started with
expiration time of 0.1 second. Since we usually need to display several previews, while the timer
is running more previews are added to the queue. At timer expiration all items from already
enqueued requests are added to the MX server previewer/covers request and request is
sent to server.
4) Data received from the server are parsed continuously, each time when application gets a piece
of data from the server. When parser encounters boundary marker between individual preview
images, an image object is created and request that asked for this image is notified about its
successful completion. So it is not needed to wait for previewer/covers request completion
to display item’s preview if it’s already received.
5) Image that is displayed on the screen doesn’t have the same size as image sent by the server.
Resizing of the image is started when application gets image from the server. This operation is
performed in the separate low priority thread to not delay network data processing.
Investigation shows that time needed to receive full response from the server doesn’t depend on whether
we perform data processing or not. For example, without processing receiving previews for 10 images
takes approximately from 35 to 65 seconds with average time 45 seconds (in 10 runs). With processing
and image resizing it takes about the same time. Amount of data received by network connection in one
time can change from 1500 bytes to 50000 bytes. This is what changes time to get response.