Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question When downloading files, is it better to download larger files? Or is it better to download them one

Discussion in 'Scripting' started by chealin, Sep 21, 2023.

  1. chealin

    chealin

    Joined:
    Sep 10, 2017
    Posts:
    72
    Hello,

    I am creating a 360-degree gallery using Unity WebGL. I plan to place a 360-degree background image on a sphere and then overlay product images on it.

    There are two options:

    1. Combine the product images with the 360-degree background image and download it as one file from the server.
    2. Download the 360-degree background image and the individual product images (10 in total) separately and arrange them.
    • 360-degree background image: 14MB
    • Each product image: 300KB
    There are two possibilities.

    If I go with option 1, I would need to download the combined image (14MB) again whenever I switch to a different view. On the other hand, if I choose option 2, I only need to download the product images (300KB) when switching views.

    I think option 2 is suitable, but I'm concerned about the increased number of exchanges with the web when implementing option 2.


    upload_2023-9-21_16-24-25.png
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,588
    I would go with individual downloads. Get what you need, when you need it. Potentielly cache it, so you dont have to download it twice per session. Ignoring caching, the total time spend downloading would be similar. You appear to be more worried about the "exchanges with the web" tho - but why? I cant imagine any sizable amount of requests occuring through either mechanism, so im not sure what your actual concern is to be honest.

    If you intend to use this at the same location where the server is, you dont really have to consider networking at all. And local transmission speeds are oftentimes extremely fast too. If you intend to use this anywhere on earth, including horrible mobile reception areas, you will have to deal with lost connections and slow downloads in either scenario. The difference here would be whether you want a long loading screen which potentially never ends due to networking problems, or if you want the viewer to already be within the scene, staring at placeholders which eventually pop into view, once they were successfully downloaded.

    You can also consider not downloading the scene initially. You could deliver them with the game, and compare their hash to the version stored on the server. If they differ you can offer to download the version from the server. Something along those lines. Depending on the situation, this can save you the larger downloads, or even enable you to use way larger (thus higher resolution) files, since you wouldnt have to get them every session. But again, whether this is a suitable solution highly depends on what exactly you are doing, or rather where you intend to use it. If the internet connection can be assumed to be stable and fast, you dont really have to worry about any of the above.
     
    Last edited: Sep 21, 2023
    Bunny83 and chealin like this.
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    Individual downloads. Also work on the image file sizes. 14 MB even for a 360° image is a lot, surely this image could be a JPG, or crunch compressed, or converted to 16-bit?

    Unless you need the ability to replace the background image you should bundle it with your app. That will be more efficient both in terms of loading time and app size.
     
    chealin likes this.
  4. chealin

    chealin

    Joined:
    Sep 10, 2017
    Posts:
    72

    Thank you for answer.

    I also think 14MB is large...

    However, if the 360° background image was small, the space looked too broken, so I enlarged it and it became a 14MB image of 8192x81920.

    -By bundling with the app, do you mean bundling the image with an AssetBundle?

    -Do you know how to reduce the size when creating a 360° background image?
    I am creating the image by inserting it into Sphere.
    upload_2023-9-22_12-5-29.png

    Sorry for asking another question...