Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Legend_Bacon · Nov 23, 2017 at 10:36 AM · unity 5errorserverbundlesdecompress

Asset Bundle: Failed to decompress data - Unity 5.6 - Windows Standalone 64

Hello everyone,

So I am relatively new to asset bundles, but it should be enough for what I need. Previously, I had all my asset bundles hosted on my own private/testing server, and my client could download them without issues. Everything was working.

Today, I tried uploading the bundles to the client's server, and now I get the error: "Error while downloading Asset Bundle: Failed to decompress data for the AssetBundle".

The link is right (if I type it in the url it downloads the bundle) and I haven't changed any code, the only difference is the hosting server. My download goes up to 95%, then stops and gives me that error.

I have tried:

  • Recreating the bundles

  • Recreating them with BuildAssetBundleOptions set to None

  • Recreating them with BuildAssetBundleOptions set to ChunkBasedCompression

  • Recreating them with BuildAssetBundleOptions set to UncompressedAssetBundle

Do you guys have an idea of what I may be doing wrong? The client's hosting service is Magnolia.

My code for bundle generation:

 public class CreateAssetBundles : MonoBehaviour
 {
     [MenuItem("Assets/Build AssetBundles for Windows _F6")]
     static void BuildAllAssetBundles()
     {
         string assetBundleDirectory = "Assets/AssetBundles/Windows";
         if(!Directory.Exists(assetBundleDirectory))
             Directory.CreateDirectory(assetBundleDirectory);
 
         BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneWindows64);
     }
 }


My code for loading the bundle:

 public IEnumerator DownloadBundleCoroutine(Action<GameObject> modelFound, string url, string modelName)
     {        
         uri = <confidential, but it is the right url.>;
         AssetBundle bundle = null;
 
         //I get versionOnServer from elsewhere, that isn't the problem.
         UnityWebRequest request = UnityWebRequest.GetAssetBundle(uri, (uint)versionOnServer, 0);
         request.Send();
         while (!request.isDone)
         {
              // Feedback on download progress. Goes up to 95% then breaks and outputs the error.
             onDLProgress?.Invoke(modelName, request.downloadProgress);
             yield return null;
         }
 
         // the error has already happened by the time it gets here
         bundle = DownloadHandlerAssetBundle.GetContent(request);
         GameObject model = null;
         if (bundle != null)
         {
             AssetBundleRequest newRequest = bundle.LoadAssetAsync<GameObject>(modelName);
             while (!newRequest.isDone)
             {
                 Debug.Log("Loading");
                 yield return null;
             }
             model = (GameObject)newRequest.asset;
         }
         modelFound(model);
 
         bundle.Unload(false);
         yield return null;
     }


Note: Each asset bundle only contains one asset, so I don't need to bother with the manifest file AFAIK.

Thank you!

~LegendBacon

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image NorthStar79 · Nov 23, 2017 at 10:44 AM 0
Share

I can not see any error on your code, just an idea, make sure that you have enough storage left ( at least 2 two times bigger than asset bundle size for being sure ) on the device.

avatar image Legend_Bacon NorthStar79 · Nov 23, 2017 at 10:48 AM 0
Share

Hello there, and thanks for the reply. The bundle is about 50 $$anonymous$$o, and I have about 100 Go of free space on the device. I wish that's what it was!

Cheers,

~LegendBacon

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Legend_Bacon · Nov 24, 2017 at 08:39 AM

Hello everyone,

So for those following this question and in need of an answer, here is how I fixed this:

Apparently, Magnolia applies its own compression algorithm to files that need to be downloaded. It makes sense, but also makes asset bundles unusable.

The first solution is to upload the file as a .zip file, download it, and unzip it at runtime, which adds a little overhead and can be little slow on some devices.

The second, and one I ended up using, is to use the WWW class instead of UnityWebRequest. It doesn't come with that neat .GetAssetBundle(), but at least it works. Here is my working code:

 uri = <Confidential. Direct link to the file on server>;
 
         WWW bundleRequest = new WWW(uri);
         while (!bundleRequest.isDone)
         {
             Debug.Log("downloading....");
             onDLProgress?.Invoke(modelName, bundleRequest.progress);
             yield return null;
         }
 
         AssetBundle bundle = null;
         if (bundleRequest.bytesDownloaded > 0)
         {
             AssetBundleCreateRequest myRequest = AssetBundle.LoadFromMemoryAsync(bundleRequest.bytes);
             while(!myRequest.isDone)
             {
                 Debug.Log("loading....");
                 yield return null;
             }
             if(myRequest.assetBundle != null)
             {
                 bundle = myRequest.assetBundle;
                 GameObject model = null;
                 if (bundle != null)
                 {
                     AssetBundleRequest newRequest = bundle.LoadAssetAsync<GameObject>(modelName);
                     while (!newRequest.isDone)
                     {
                         Debug.Log("loading ASSET....");
                         yield return null;
                     }
                     model = (GameObject)newRequest.asset;
                     modelFound(model);
 
                     bundle.Unload(false);
                 }
             }
             else
             {
                 Debug.LogError("COULDN'T DOWNLOAD ASSET BUNDLE FROM URL: " + uri);
                 modelFound(null);
             }
         }
         else
         {
             Debug.LogError("COULDN'T DOWNLOAD ASSET BUNDLE FROM URL: " + uri);
             modelFound(null);
         }


Kind of a pain, but everything works asynchronously. I do have to build my own cache though, as now the bundle is downloaded every time instead of getting loaded from cache if the revision numbers match.

Hope that can help other people!

~LegendBacon

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
11

Answer by bob2unlimited · Nov 03, 2018 at 06:43 AM

Had the same issue, 5.6+, and realized the files were uploaded using FileZilla, not in Binary mode. Re-uploaded in Binary mode and all was good. Test code below.

     ------------
     string uri = "www.mywebsite.com/asset1";
     using (UnityWebRequest uwr = new UnityWebRequest(uri, UnityWebRequest.kHttpVerbGET))
     {
         uwr.chunkedTransfer = false; 
         uwr.SetRequestHeader("Accept", "*/*");
         uwr.SetRequestHeader("Accept-Language", "en-US");
         uwr.SetRequestHeader("Content-Language", "en-US");
         uwr.SetRequestHeader("Accept-Encoding", "gzip, deflate");
         uwr.SetRequestHeader("User-Agent", "runscope/0.1");
         uwr.downloadHandler = new DownloadHandlerAssetBundle(uri, 0);
         yield return uwr.SendWebRequest();
         assetBundle = DownloadHandlerAssetBundle.GetContent(uwr);
         if(assetBundle != null){

         }else{
             Debug.Log(uwr.error);
             Debug.Log(uwr.downloadHandler.text);
         }
     }
Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image James-DeCarlo · Dec 30, 2018 at 10:52 PM 0
Share

Thanks man worked perfectly once I set filezilla to upload in binary ins$$anonymous$$d of auto

avatar image xari2k James-DeCarlo · May 15, 2019 at 02:16 PM 1
Share

Thats the solutions, thanks man ♥

alt text

filetypes.png (26.5 kB)
avatar image Mirmukhsin xari2k · Jul 07, 2021 at 08:42 AM 0
Share

Even after setting Binary in the settings, it didn't work, I had to select Binary in the menu "Transfer/TransferType/Binary" too. Then it worked.

Show more comments
avatar image unity_WPzfLehdpNGaDQ · Sep 03, 2019 at 08:13 AM 0
Share

Thanks man! It worked for me also!

avatar image wisher_wisher · Oct 28, 2019 at 08:23 AM 0
Share

it worked for me after I disable these 5 lines,

      uwr.SetRequestHeader("Accept", "*/*");
      uwr.SetRequestHeader("Accept-Language", "en-US");
      uwr.SetRequestHeader("Content-Language", "en-US");
      uwr.SetRequestHeader("Accept-Encoding", "gzip, deflate");
      uwr.SetRequestHeader("User-Agent", "runscope/0.1");

I worked with google drive and firebase. but I couldn't work with my own free host. I even used FileZilla with binary forced always get this error in my own free host "failed to decompression"

avatar image deuterocanonico · Dec 14, 2021 at 10:04 PM 0
Share

My error in Chrome was: Error while downloading Asset Bundle: Failed to decompress data for the AssetBundle and @bob2unlimited' answer has saved my day thank you! Upload the files in binary mode solved my problem

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

174 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity3d + SmartFox dll + Windows 8 Store Build produces errors 0 Answers

Game Analytics & Facebook sdk android build error 1 Answer

Unity failed to decompress package 1 Answer

Unity Master Server - Ubuntu build problem 4 Answers

Android application (Unity 5) closes without error a few seconds into game on random devices. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges