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
1
Question by Feyyyyy · Feb 28, 2017 at 09:46 AM · iosassetbundleassetbundles

Loading asset from an asset bundle crashes on ios.

Hi all,

I am experiencing very strange behaviour on ios with asset bundles.

I made some asset bundles, which depends to other asset bundles. On ios i download asset bundles using "on demand resources". I am making sure that they are downloading just fine. Also Debug section of Xcode shows that asset bundles downloaded succesfully. To make sure i log contents of asset bundles and see that the asset that i will request are already there. (I check if my asset name is in assetBundle.GetAllAssetNames() and i find it there.)

But when i try to load an asset using assetbundle.loadassetasync or assetbundle.loadasset the game crashes.

This is the crash log

 2017-02-28 12:36:38.435420 VM[741:261572] Uncaught exception: NSRangeException: *** -[_NSZeroData getBytes:range:]: range {408687, 7168} exceeds data length 0
 (
     0   CoreFoundation                      0x000000018bce11d0 <redacted> + 148
     1   libobjc.A.dylib                     0x000000018a71855c objc_exception_throw + 56
     2   CoreFoundation                      0x000000018bce1100 <redacted> + 0
     3   Foundation                          0x000000018c710b9c <redacted> + 276
     4   VM                                  0x0000000100dfad8c _ZN16AssetCatalogFile4ReadEyyPvPy + 132
     5   VM                                  0x0000000100dfa8e0 _ZN29AssetCatalogFileSystemHandler4ReadER13FileEntryDatayyPvPy + 76
     6   VM                                  0x0000000100d59660 _ZN12FileAccessor4ReadEyyPvPy + 68
     7   VM                                  0x0000000100d50eb8 _ZN20ArchiveStorageReader15ReadFromStorageEyyPvPy + 196
     8   VM                                  0x0000000100d509ac _ZN20ArchiveStorageReader9ReadBlockEjyyPvPy + 324
     9   VM                                  0x0000000100d4bfa8 _ZN20ArchiveStorageReader4ReadEyyPvPy + 308
     10  VM                                  0x0000000100d4be4c _ZN15ArchiveReadFile4ReadEyyPvPy + 84
     11  VM                                  0x0000000100d4b1b4 _ZN17ArchiveFileSystem4ReadER13FileEntryDatayyPvPy + 44
     12  VM                                  0x0000000100d59660 _ZN12FileAccessor4ReadEyyPvPy + 68
     13  VM                                  0x0000000100d44d38 _ZN4File4ReadEyPvm + 52
     14  VM                                  0x0000000100ab0e80 _ZN24AsyncReadManagerThreaded11ThreadEntryEv + 216
     15  VM                                  0x0000000100ab0c24 _ZN24AsyncReadManagerThreaded17StaticThreadEntryEPv + 12
     16  VM                                  0x0000000100d24f7c _ZN6Thread16RunThreadWrapperEPv + 96
     17  libsystem_pthread.dylib             0x000000018ad75850 <redacted> + 240
     18  libsystem_pthread.dylib             0x000000018ad75760 <redacted> + 0
     19  libsystem_pthread.dylib             0x000000018ad72d94 thread_start + 4
 )
 2017-02-28 12:36:38.435860 VM[741:261572] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[_NSZeroData getBytes:range:]: range {408687, 7168} exceeds data length 0'


I tried the same project on Windows platform. Instead of ODR im using WWW. And it works fine on windows.

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

1 Reply

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

Answer by Feyyyyy · Mar 01, 2017 at 11:25 AM

I found solution of this problem. I am writing it here in case some other people suffer from the same problem.

I was using the code below to load asset bundle

 OnDemandResourcesRequest request = OnDemandResources.PreloadAsync(new string[] {bundleName }) 

After this request finishes the operation i was using the next line of code to create asset bundle

 AssetBundle.LoadFromFileAsync("res://"+bundleName);

The problem is while i was doing it i was loosing the reference to the "request" object. And after garbage collecting phase that asset bundle i load started giving errors.

I keep the reference to the "request" object at some place and problem solved.

Comment
Add comment · Show 5 · 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 bcicanci · Aug 20, 2020 at 11:12 AM 0
Share

Thank you very much for sharing your solution, that was exactly the same problem I had.

avatar image Visutate bcicanci · Sep 16, 2020 at 07:58 PM 0
Share

Hello @Feyyyyy or @bcicanci , I'm having the same problem. By saying keeping the reference, do you mean you made request a global field and didnt use request.Dispose() ? How exactly?

avatar image bcicanci Visutate · Sep 17, 2020 at 10:22 AM 0
Share

@Visutate in my case I kept a list with all OnDemandResourcesRequest objects and didn't call the Dispose() until I need to unload all assets. Hope that helps!

avatar image unity_iGFB1LthpsBUYw · Sep 16, 2020 at 07:56 PM 0
Share

What do you mean by keeping reference at some place? Is it like referencing it to a field in singleton?

avatar image dzennik unity_iGFB1LthpsBUYw · Jan 30, 2021 at 12:11 AM 0
Share

Yes, just like Singleton for example, must be at least one link which not killed (don't use local variable).

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

89 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

Related Questions

Assetbundle memory leaks 0 Answers

Can a windows and an android app use the same assetbundle specified with no target?,Can Windows and Android apps run assetsbundles with notarget? 0 Answers

AssetBundleManager - what asset bundle URL to specify for iOS (Xcode simulator, Testflight, Appstore)? 0 Answers

Is there a scene count limit for asset bundles? 0 Answers

iOS, Assentbundles and Custom Shaders 1 Answer


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