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 Paulius-Liekis · Aug 08, 2011 at 07:17 PM · androidcoroutinewwwyield

yield return request never returns

Hi,

I'm having problems with yield: "yield return request;" never returns on Android device of my customer. I looked for existing answer, but couldn't find any useful hints.

 using UnityEngine;
 using System.Collections;
 
 public class TestConnection : MonoBehaviour {
 
     // Use this for initialization
     void Start () 
     {
         StartCoroutine(Test());
     }
     
     IEnumerator Test()
     {
         string tag = "Test";
         Debug.Log("Test connection: " + tag);
         
         string url = "http://search.twitter.com/search.atom?lang=en&q=%23" + tag;
            WWW request = new WWW(url);
         
         Debug.Log("Created request");
     
         // Wait for download to complete
         yield return request;
         
         Debug.Log("Done request. Error: " + (request.error != null ? request.error : "NoError"));
         Debug.Log("request.text: " + request.text);
     
         GetComponent<Text2D>().text = request.text.Substring(0, 50);
         
         Debug.Log("Set text");
     }
 }


I just prints: "Test connection: Tag" and "Created request" and then just sits there.

Any ideas?

Comment
Add comment · Show 5
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 Eric5h5 · Aug 08, 2011 at 07:46 PM 0
Share

@Bovine: certainly "request" is being used, that's what "yield return request" is doing, as well as the actual results, namely request.text. Yield return null just waits a frame, which isn't useful at all in this case.

avatar image SisterKy · Aug 08, 2011 at 10:54 PM 0
Share

(looks like UnityAnswers ate your formatting... please reformat...)

avatar image Waz · Aug 09, 2011 at 12:02 AM 0
Share

It's weird that format breakage happens sometimes. I just edited, added a blank line and saved. Odd.

avatar image Waz · Aug 09, 2011 at 12:04 AM 0
Share

It's conceivable that on your Android device there is something wrong with networking (so the request never completes). Does it all work fine in the editor?

avatar image Paulius-Liekis · Aug 09, 2011 at 07:45 AM 0
Share

It works fine in the editor. The Android device can open same link in a browser.

2 Replies

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

Answer by Paulius-Liekis · Apr 18, 2012 at 09:06 AM

It looks like this was bug in Unity 3.0 and it has been fixed long time ago.

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

Answer by roamcel · Aug 09, 2011 at 05:49 AM

I believe that for proper debugging you could try using a coroutine, adding a timer inside it and another timer in the caller function, to verify if the routine's actually running or has frozen for whatever reason, sending both timers to log.

Comment
Add comment · Show 3 · 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 Paulius-Liekis · Aug 09, 2011 at 07:47 AM 0
Share

Sorry, could you explain what you mean by "adding timer inside coroutine"? I can't add anything to WWW class, my coroutines run fine... The rest of the code runs fine - it's just coroutine that freezes.

avatar image Bovine · Aug 09, 2011 at 10:34 AM 0
Share

$$anonymous$$aybe the suggestion is to see if replacing the yield return WaitForSeconds(5) will continue or whether that blocks as well - you could yield return null to confirm this. At least you know the issue is with the WWW object and coroutines generally then.

avatar image roamcel · Aug 09, 2011 at 11:32 AM 0
Share

I am pretty sure this is a ti$$anonymous$$g issue. by "try using a coroutine" i meant move your

     string tag = "Test";
     Debug.Log("Test connection: " + tag);

     string url = "http://search.twitter.com/search.atom?lang=en&q=%23" + tag;
     WWW request = new WWW(url);

     Debug.Log("Created request");

     // Wait for download to complete
     yield return request;

code in a new routine, which you call with

yield return StartCoroutine(myurlopen());

as per the timers, you just debug.log Time.timer inside and outside of the caller and called functions.

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to yiled a try/catch block? 2 Answers

Yield Problems 2 Answers

How to set timer for WWW helper? 1 Answer

yield return WWW stops Coroutine? 0 Answers

yield on a www never completes 10 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