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 VamshiKrishnaP · Dec 15, 2014 at 09:31 AM · serverloading textures

Problem with WWW (Performance Issue)

Hi ,

Am downloading 10 images from server and displaying on my UI flow.

Sometimes app is crashing.

How to reduce the burden of WWW so that app not crash ?

Thank you !!!

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
0

Answer by SkaredCreations · Dec 15, 2014 at 09:36 AM

It depends on how you're downloading them, it's better to manage a queue than download all of them simultaneously, for example max 2-3. You could use a Queue and Dequeue items inside a loop.

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 VamshiKrishnaP · Dec 15, 2014 at 11:38 AM 0
Share

Ya. At a time am downloading 1 only.

$$anonymous$$y server response is in json format. am splitting the response and downloading an images 1 by 1 with For() loop. Still am getting crashes. (each image size is approx 50-90kb only)

avatar image SkaredCreations · Dec 15, 2014 at 11:52 AM 0
Share

I doubt the downloading is causing the crash, please put the code in your original post of both download and what you're doing later with it.

avatar image VamshiKrishnaP · Dec 16, 2014 at 04:46 AM 0
Share

$$anonymous$$y Code :

First am Checking the image is existed in my persistentDataPath or not? if existed , getting from local data else downloading from the server and saving in a persistent datapath.

 for(int g=0;g<10;g++){
          if(File.Exists(Application.persistentDataPath + "/"+ ThumbImageName+"_"+ThumbImageTimestamp)){
                                 
                                 string URL="file://"+Application.persistentDataPath + "/"+ ThumbImageName+"_"+ThumbImageTimestamp;
                                 WWW wwwArImage = new WWW(URL);
         
                                 yield return wwwArImage;
                                 if(wwwArImage.isDone && wwwArImage.error == null){    
                                     Texture2D ARImage = new Texture2D(250, 250);
                                     ARImage.LoadImage(wwwArImage.bytes);
                                     $$anonymous$$ainArray[g]=ARImage;
                                 }else{
                                     print ("Error !!!");
                                 }
                                 
                             }else{
                                 string ImageURL=N["response"]["data"][g]["subcat_image"];
                                 WWW wwwArImage = new WWW(ImageURL);
                                 yield return wwwArImage;
                                 if(wwwArImage.isDone && wwwArImage.error == null)
                                 {    
                                     Texture2D ARImage = new Texture2D(250, 250);
                                     ARImage.LoadImage(wwwArImage.bytes);
                                     $$anonymous$$ainArray[g]=ARImage;
                                     File.WriteAllBytes(Application.persistentDataPath + "/"+ ThumbImageName+"_"+ThumbImageTimestamp, wwwArImage.bytes);
                                 }else{
     print("Error");
     }
 }


avatar image SkaredCreations · Dec 16, 2014 at 12:17 PM 0
Share

Is there a reason why you're creating Texture2D manually ins$$anonymous$$d of use wwwArImage.texture? The reason of a crash could be many, for example if $$anonymous$$ainArray length is lesser than 10 or File.WriteAllBytes fails to write or wwwArImage is not a texture etc. Did you try to check if there's anything in the log?

avatar image VamshiKrishnaP · Dec 17, 2014 at 06:02 AM 0
Share

Ins$$anonymous$$d of creating Texture2D now am using wwwArImage.texture to load image in an array.

Array length is same as number of textures to download. (i never get array index Out of range exception).

for each image, WriteAllBytes will call once in a lifetime. Next time onwards getting an image from local (persistant data path) only.

Thank you.

(crash is random)

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

How to shut down an Unity application on Amazon Ubuntu EC2 server ? 0 Answers

Network Connection Works Locally, but not Publicly 0 Answers

Unity crashes when opening a scene!? 3 Answers

Does anyone know how to make a "player host server" client 2 Answers

Networking Question 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