Search Unity

WWW not working if built WebPlayer with Unity 5 (only on Firefox)

Discussion in 'Editor & General Support' started by Simon_says, Apr 14, 2015.

  1. Simon_says

    Simon_says

    Joined:
    Oct 19, 2013
    Posts:
    141
    After I changed to Unity 5, my game doesn't work on Firefox based web browsers. I have put so much effort in trying to trace the source of the issue, and it seems that the WWWForm class doesn't work properly in Unity 5. What's very odd is that if running the same build on Chrome based browser, everything works perfectly fine.

    I don't know if this is somehow connected to Firefox or Unity Web Player, but this only happens if building with Unity 5.x.

    The problem here is using the POST method from WWW, but the fields are set up correctly and they do get sent from the player. I have proxied my connection with Burp Suite and saw the parameters getting through the game to the browser, but my server doesn't receive that POST field. I get the "undefined index" error in my PHP.

    So after I literally went through every part of the web code in my game, I have created a new empty project and made a simple script and ran the build on both Firefox and Chrome, and the result was the same.

    This is the script I used to reproduce the issue:
    Code (CSharp):
    1.  
    2.     IEnumerator Start()
    3.     {
    4.         WWWForm login_form = new WWWForm();
    5.         string url = "http://serverscript.php";
    6.  
    7.         login_form.AddField("arg0", "login_portal");
    8.  
    9.         WWW login_post = new WWW(url, login_form);
    10.  
    11.         while (!login_post.isDone)
    12.         {
    13.             yield return null;
    14.         }
    15.     }
    And this is the PHP script for getting the info:
    Code (PHP):
    1. $command = $_POST['arg0'];
    As you can see it's a basic POST method.

    I repeat, it works perfectly fine on Chrome browsers, but not on Firefox based browsers...

    I see this has been reported as a bug as I have just went to do the same.
    http://issuetracker.unity3d.com/iss...-unity-5-dot-0-0f2-creates-an-invalid-request
    http://issuetracker.unity3d.com/issues/www-forms-do-not-work-properly-in-webplayer-unity-5
    but I see it's still not fixed(even though it says it should be fixed in 5.1). This issue should have more attention...

    EDIT: I see there's a "hack" for this:
    Code (CSharp):
    1. login_form.AddBinaryData("binary", new byte[1]);
     
    Last edited: Apr 14, 2015
    atomjke likes this.