Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 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. This is called several times during runtime if the user wishes to change these so called 'backTextures'.

In my tests I call this several times in a row. Everything goes well and afaik there is no sign of memory leaks. But after executing this 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;'. This happens always on the first iteration of the for loop (i=0), but as I said before, after calling this piece of code several times.

Can anyone help me out with this? I have no idea why yield return www would hang...

EDIT I did some more testing: This 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

How can you solve it ? I have met the same problem as you

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

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

Saving Unity Texture2D updated with OpenGL FBO via custom plugin 2 Answers

Understanding Texture Formats for iOS: PVRTC 4bit RGBA VS. 16bit RGBA 1 Answer

is it possible to use JPG compression on iOS export for non PVRTC textures? 0 Answers

Image Displaying Bleached Texture. 0 Answers

Changing textures accumulate in memory. iOS. 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