• 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 reverse · Dec 04, 2013 at 12:21 PM · iostexturecoroutinewww.texture

iOS Unity randomly hangs on yield return www

I'm developing an iOS app with Unity where I load textures at runtime from the file system. I only have one scene. The piece of code I use to load the textures is shown below. T$$anonymous$$s is called several times during runtime if the user wishes to change these so called 'backTextures'.

In my tests I call t$$anonymous$$s several times in a row. Everyt$$anonymous$$ng goes well and afaik there is no sign of memory leaks. But after executing t$$anonymous$$s several random times (say as little as 2 times or even as much as 13 times for example) Unity hangs.

According to the Xcode console, the last print I read is the 'Just created the www' so I am assuming the script is hanging waiting for the 'yield return _www;'. T$$anonymous$$s happens always on the first iteration of the for loop (i=0), but as I said before, after calling t$$anonymous$$s piece of code several times.

Can anyone help me out with t$$anonymous$$s? I have no idea why yield return www would hang...

EDIT I did some more testing: T$$anonymous$$s code is running on a coroutine. I added a print to the Update() and it keeps being called. So the Unity engine is not completely dead. It really seems that it is the www that is not returning....

 //some code before
 
                        if(backTextures != null && backTextures.Length != 0){
                             Debug.Log("Cleaning the vector!!!!");
                             for(int i = 0; i < backTextures.Length; i++){
                                 Destroy(backTextures[i]);
                                 backTextures[i] = null;
                             }
                             
                         }

 //Some more code here
 
 Debug.Log("Will load " + picsize + " textures");
             //load textures to memory
             for(int i=0; i<picsize; i++){
                     Debug.Log("Let's read the texture " + i);
                     string _textureURL = "file://" + Application.dataPath + "/../../Documents/current/" + imageNames[i];
                     Debug.Log("The path is " + _textureURL);
                     WWW _www = new WWW(_textureURL);
                     Debug.Log("Just created the www");
 
                     yield return _www;
                      Debug.Log("Returned from yield return");
                     if (_www.error != null)
                     {
                        Debug.LogError("WWW Error: "+ _www.error);
                         i--;
                         _www.Dispose();
                         _www = null;
                         continue;
                     }else{
                         Debug.Log("There was no error!!!!!");
                     }
                     Debug.Log("Will assign textures");
                     backTextures[i] = _www.texture;
                     Debug.Log("Will dispose textures");
                     _www.Dispose();
                     _www = null;
             }
 
 // some code after
Comment
Add comment · Show 1
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 cheaster · Apr 24, 2014 at 01:42 AM 0
Share

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

17 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

Related Questions

Assigning UV Map to model at runtime 0 Answers

Adding gravity and texture to newly added game objects 1 Answer

Texture atlases on iphone 3 Answers

Can I load textures at runtime with a smaller memory footprint? 1 Answer

Unity iOS forced 1kx1k 2 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