WebGL memory issue when using WWW to Download Images.

Hello guys,

The error happens when try to download a image from AWS server using WWW.

This topic may be recurrent, but I’ve not found a solution for this specific issue.

This is a quiz game with text and images questions, and i believe the error present where the code tries to download the image. Here a part of the code:

if(!string.IsNullOrEmpty(question.image_url))
{
      loadingBarImg.fillAmount = 0;
      percentageTxt.text = "0%";

      //Debug.Log("Downloading image, from quesiton ID: "+question.id);
      wwwQuestion = new WWW(question.image_url);
      while (!wwwQuestion.isDone)
      {
             percentageTxt.text = Mathf.Round(wwwQuestion.progress*100)+"%";
             loadingBarImg.fillAmount = wwwQuestion.progress;
      }

      yield return wwwQuestion;

      question.questionImage = Utils.BytesToSprite(wwwQuestion.bytes);
}

Error presented on normal Build:

Error presented on development Build:
(Sorry this one is in Portuguese (BR))

101924-captura-de-tela-2017-09-15-as-112118.png

Any help or hint would be good. :slight_smile:

Anyone can help?

This loop:

while (!wwwQuestion.isDone)
{
    percentageTxt.text = Mathf.Round(wwwQuestion.progress*100)+"%";
    loadingBarImg.fillAmount = wwwQuestion.progress;
}

will crash your app. Read this page, especially the section:

Do not block on WWW or WebRequest
downloads

What should work is this:

while (!wwwQuestion.isDone)
{
    percentageTxt.text = Mathf.Round(wwwQuestion.progress*100)+"%";
    loadingBarImg.fillAmount = wwwQuestion.progress;
    yield return null;
}