Search Unity

Lean Loader - Load from the web or a cache

Discussion in 'Assets and Asset Store' started by dentedpixel, Nov 4, 2013.

  1. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hi there,
    The major performance upgrades I was hoping to get was not possible because the main performance hitch is on the Unity side of decoding an image :-/, but I will try and make auto-stagger out calls like this so you won't get a hitch if calling a bunch of load calls. You can also call the next image on setOnComplete( then call the next image to be loaded)
     
  2. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    I am sending you an updated version that will auto-stagger out the processing of the loaded images. If you want to adjust this throttle just set the value:

    //LeanLoader.IMG_PROCESSING_THROTTLE=5f; // defaults to one but set to larger to space out image calls

    Other people wanting the same update, I will make an updated version for the store soon!
     
  3. Boegi

    Boegi

    Joined:
    Dec 6, 2014
    Posts:
    19
    Hello dentedpixel...

    There is still an error in your hosted json feed...
    Please check it... (I reported it months ago! See page1. You should see it in less than 30 seconds.)
    ---
    There is a error/typo in your latest json feed. http://dentedpixel.com/assets/test_json.txt
    It returns ...
    "texture":"ttp://dentedpixel.com/assets/PrincessPiano.jpg"
    (h from http is missing)
    ---
    Thanks
     
  4. Boegi

    Boegi

    Joined:
    Dec 6, 2014
    Posts:
    19
    Fixed the JSON on my server but another error... The scene... LoadJSON Example is still not working. Can you help me? I downloaded the asset again (today) from the asset store to check that I have the latest version. Thanks...


    ---UPDATE---
    I found the second error... The upper quotation marks are also messed up in the json file...
     
    Last edited: Oct 29, 2016
  5. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Sorry about that! I have fixed the JSON now on the server
     
  6. itsjesseyp

    itsjesseyp

    Joined:
    Jul 25, 2013
    Posts:
    3
    Dented,

    I'm using 5.5 and just dowloaded your package. there are a couple of minor bugs, and one huge one to report.

    Here's a video to speed things up for you


    So, the biggest thing is that, when using cached files, your own examples are not working, nor are my own hello worlds. I tested this a few times by creating new projects, and simply running the provided examples. on first load, the images draw. on subsequent "loads" a gray box is drawn. in your example, i can push the purge cache button and the stuff will load from web and draw, but break again on next load. if i custom code things using the minimal example i get the same results. i managed to get a black drawing, as you see briefly, if i set the cache duration to int.max, then delete the cache via code - i dunno which one triggered it - but it seems permanent. Issues persist on compiled applications.

    In the video you'll see a few minor things, like a missing script reference in an example, and a conflict if you use leantween and leanload in the same project. there's also the minor issue that the lloption setUseFile is not documented on your website.

    i use leantween religiously. i'm stoked to have a project that needs something I can pay you for. let me know if i'm missing something boneheaded.
     
  7. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hey there!

    Thanks for letting me know, I think there was a conflict with LeanTween. I have fixed that and I will dm you the updated package (I'll also upload it to the asset store for others).

    This asset hasn't been very popular so I haven't kept my eyes on it, so it's good to get some feedback.

    Thanks! Glad you like LeanTween :)
     
  8. itsjesseyp

    itsjesseyp

    Joined:
    Jul 25, 2013
    Posts:
    3
    IT WORKS!!!!!!! So, to help anyone else and negate concerns. The post with the video about caching problems was fixed... in about 2 hours. Very much appreciated, Dented.

    What does ".setUseFile(true)" do?
     
  9. itsjesseyp

    itsjesseyp

    Joined:
    Jul 25, 2013
    Posts:
    3
    Also, if you don't set a cache life is it automatically forever?
     
  10. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    SetUseFile makes sure you use file storage instead of PlayerPrefs when possible (set to true by default)

    Yup cache life is set to forever by default.
     
  11. Xtro

    Xtro

    Joined:
    Apr 17, 2013
    Posts:
    608
    I really can't believe you are using playerprefs as a database. Just can't.... :(
     
    spakment likes this.
  12. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Haha, that is just for Web. It uses file storage by default otherwise.
     
  13. Xtro

    Xtro

    Joined:
    Apr 17, 2013
    Posts:
    608
    Have you ever checked the data in playerprefs in editor with a tool like "Advanced Player Prefs"? After downloading images with lean loader, there are millions of entries in playerprefs. 3 entries for each image. You didn't even compact the 3 data into 1. After a certain number of images, the tool can't even display that many entries and errors out.
     
  14. petergraham003

    petergraham003

    Joined:
    May 5, 2018
    Posts:
    14
    Hello dentedpixel,

    I am developing a game for StandaloneWindows, in which I am using LeanLoader to download and cache some textures. I see that there is a performance drop in game because of downloading textures and saving them to my localDisk (As I am using cache and by default useFile is set to true). Is there any other way to cache rather than saving them in localDisk ? I doubt saving them in localDisk is the reason for performance drop (as I am downloading some 90 textures at a single shot, writing all those data into files in localDisk would be a performance hit)

    And does LeanLoader does the loading and caching part asynchronously ? And can I know, what is IMG_PROCESSING_THROTTLE ?
     
    Last edited: Mar 21, 2019
  15. spakment

    spakment

    Joined:
    Dec 19, 2017
    Posts:
    96
    Ha, I know!
    This bobbed up in a google search for "download anad cache file at runtime" this is a pretty crazy solution, taking the binary data files and stuffing them into Player Preferences.
    For future finders of this page , this is not the way - Application.persistentDataPath is here for you.

    I can't vouch for it but this is a much more sensible looking solution - https://github.com/shamsdev/davinci/blob/master/Davinci/Assets/Davinci/Scripts/Davinci.cs