Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Unity 2017.2 beta is now available for download.
    Dismiss Notice

The assetbundle build is different each time if I remove the Library folder

Discussion in 'Asset Bundles' started by watsonsong, Sep 12, 2017.

  1. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    141
    I am building the assetbundles to support the "hot" update the game asset. So I want to keep my asset bundle binarary consistency so thay the user will not download the whole assets.
    But if I delete my Library folder without any change to my Assets folder, the build result is not the same. I have to commit the Library folder to the version control to avoid this, it really mess up the project.
    I known there have a lot of discussion about this issue, but I never find a right way.
    Is there any way to reslove this, or I am missing something.
     
  2. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    97
    We've done quite a bit to fix binary stability of asset bundle builds. What version of Unity are you using, and by chance do you have any tools or packages that do anything with assets on import?
     
  3. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    141
    I am using Unity 5.6 and the svn as version control. I submit my assetbundle to the svn, but each time I delete Library folder and rebuild assetbundle, I found a lot of bundle is changed.
    I write a script to deal with the import setting for each folder, make sure the import setting in the right way. Different setting for different folder.
     
  4. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    97
    Ok, so the svn stands out as a possible source of the problem:
    - Make sure your SVN does not modify the line endings of any text files on checkout. This will definitely cause the asset hash to be different in certain cases. Unity uses unix line endings when it writes out any text files, regardless of platform. So if your SVN is modifying the line endings to match the platform, that will mess up the hash calculation and make it think the asset has changed and thus need a rebuild.
    - Timestamps are also a big deal with SVN as from what I remember SVN tends to mess up the timestamps of when the asset was last modified. If that is still the case, then that would make the asset hash calculation system mess up again and make it think the asset has changed.

    Finally, I'd also test to see if the bundles themselves are actually different run to run. Use a diff application like DiffMerge to check the 2 bundle files and see if they are the same or different. If they are different, you can use WebExtract on the bundles to pull out the internal content, then run binary2text on the extracted internal content to get a more human readable version of the bundle data. Then run DiffMerge again on the text files and you can then see exactly what changed. If you post or direct message that information I can definitely look over it (note: on vacation next week) and see if it is something we have fixed, or still need to fix. WebExtract & binary2text are found in the Unity install location under the Data/Tools directory.
     
  5. onur-gg

    onur-gg

    Joined:
    Dec 14, 2015
    Posts:
    1
    We also have same issue with GIT and any version of Unity 5.2+. I'm sure generated asset bundles are same, because they have same CRC but different hash in their manifest. We reduce cases with defining all unity files as "-text" in gitattributes, so git not changes the line endings. But as far as I know it's impossible to preserve actual time stamps in GIT. It's actually quite annoying because we almost never achieve to NOT generate asset bundles. There is always one developer/artist who imported the assets which differs from rest of team :(

    Edit: The problem may not be caused from different timestamps. What we observes in our team is that we usually ends up with same binary and meta file, however the importer generates one hash, and rest of team generated another hash for same asset bundle.
     
    Last edited: Sep 22, 2017 at 7:35 PM
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    1,736
    This can also happen if even a single meta file is missing in the directory chain. IE: If you have assets/foo/bar/myfolder/mything, and the meta file for foo is not checked in, it will get generated on each machine with a different GUID and cause mything.bundle to get a different hash, even though it isn't actually different.