Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 eaguayo_sav · Nov 05, 2016 at 12:06 AM · assetbundleexceptionwebrequestbug report

Do some operations/statements implicitly access MainAsset of an AssetBundle, throwing AssetBundle:get_mainAsset?

Super strange issue, and maybe a bug within Unity. In a C# base applicaiton, when downloading an asset bundle from S3 occasionally, on both mobile devices and within the editor, the following error is thrown

 AssetBundle client_editor_en_us doesn't have main asset!
 UnityEngine.AssetBundle:get_mainAsset()
 DownloadBundleState:OnBundleDl(AssetBundle) (at Assets/Scripts/StateMachine/DownloadBundleState.cs:218)
 <DLBundles>c__Iterator2:MoveNext() (at Assets/Scripts/Managers/AssetBundleDownloadManager.cs:138

Now, the main asset is in fact null/unset but no code is explicitly trying to access the main asset. In fact this bundle is simply passed into a callback function. This callback function is what is actually throwing the error.

Here's the download logic: using (UnityWebRequest www = new UnityWebRequest (url)) {

 // Set up a download handler to pull and asset bundle by version, ignore the check sum
             DownloadHandlerAssetBundle downloadHandler = new DownloadHandlerAssetBundle (url, cachedVersion, 0);
             www.downloadHandler = downloadHandler;

             yield return www.Send ();

             if (www.error != null)
                 throw new Exception ("WWW download had an error:" + www.error);

             url = url.Split ('?') [0];
             dictAssetBundleRefs.Add (
                 url + cachedVersion.ToString (), 
                 new AssetBundleRef (url, cachedVersion) {
                     assetBundle = downloadHandler.assetBundle
                 }
             );

             callback (downloadHandler.assetBundle);
         }

And here's the callback being invoked:

 private void OnBundleDl(AssetBundle bundle) {
         AssessmentContentProvider.Instance.Init (bundle);
         Blackboard [AssessmentConstants.BLACKBOARD_KEY_DOWNLOADED_CONFIG_VERSION] = 9;
         StartBundle ();
     } // DownloadBundleState.cs:218

 

3 very abnormal things:

  1. No code tries to access the main asset. Only the AssessmentContentProvider initialization just assigns the variable to a member.

  2. The error is reported at the last line of the function, leading me to believe it actually occurs when the function parameter itself is evaluated or after the function is completed outside the main thread.

  3. Despite throwing this unhanded exception the app functions totally fine, the asset bundle is set, and we are able to read assets from it.

Because of that I wonder if this a bug within Unity itself, where under certain circumstances it automatically tries to read the main asset. The really crazy, to me, is why normal program execution is totally unaffected by this (relative to where it occurs) critical unhanded exception.

Am I missing something very obvious about the user of bundles within parameters or how unity cleans up reference local reference variables to bundle? Only documentation I can find on the main asset says its optional and must be requested specifically.

Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Access raw AssetBundle data using UnityWebRequest? 4 Answers

Asset bundle memory leak and exception 1 Answer

assetBundle.mainAsset exception 0 Answers

AssetBundle.LoadFromFile throws exception instead of just returning null, why? 1 Answer

failing to download assetbundle manifest object with UnityWebRequest 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