Connection is no longer valid. Calling auto disconnect. Error

Hi, Im getting the following errors.
its a coroutine basically what it does is, it downloads a bunch of image from the server and it will first check if that file name already exists in the storage in the persistentDataPath then if not it will download and store it there, it works fine with my other android devices, but other tablet it does not work, I tried development build, but it doesnt return any error other than what I mention in the title, I also tried looking at the adb logcat it still the same as the title says, heres the code for reference

IEnumerator DownloadSlidesCurrent()
{

    int _cnt = GetComponent<db_materials>().material_count - 1;
    if (current_lesson <= _cnt)
    {
        num_threads += 1;

        string[] slide_link = model_mat[current_lesson].slides.Split(',');
        string img_name = model_mat[current_lesson].disp_name + "_" + (current_slides + 1);
        if (File.Exists(_path + img_name + ".png"))
        {
            sec_towait = 0.03f;
            yield return new WaitForSeconds(sec_towait);

            //check if the current slides has reached the max slide number
            //if it does it will reset the current_slides to 0 and +1 to current lessons
            if (current_slides == slide_link.Length)
            {
                PlayerPrefs.SetInt(model_mat[current_lesson].disp_name + "_FileCount", downloaded_img);
                current_slides = 0;
                current_lesson += 1;
                downloaded_img = 0;
                
                //then it will check if the current lessons is still less than the total lesson (for index error)
                if (current_lesson <= GetComponent<db_materials>().material_count - 1)
                {
                    slide_link = model_mat[current_lesson].slides.Split(',');
                    img_name = model_mat[current_lesson].disp_name + "_" + (current_slides + 1);
                }
                

            }

            if (current_lesson <= _cnt)
            {
                byte[] byteArray = File.ReadAllBytes(_path + img_name + ".png");
                Texture2D texture = new Texture2D(8, 8);
                texture.LoadImage(byteArray);
                Debug.Log("already exist: " + img_name);

                downloaded_img += 1; // this will count slides then will save it for future reference
                
                num_threads -= 1;
                current_slides += 1;
                total_file_download += 1;

                ShowLoading("(" + current_slides + "/" + (slide_link.Length - 1) + ") Downloading " + model_mat[current_lesson].subject + " resources...");
                yield return CoroutineUtils.Try(DownloadSlidesCurrent());
                
            }
            else
            {
                StartCoroutine(FinishSetup("Setup Complete!"));
            }
        }
        else
        {
            sec_towait = 0.03f;
            yield return new WaitForSeconds(sec_towait);

            //check if the current slides has reached the max slide number
            //if it does it will reset the current_slides to 0 and +1 to current lessons
            if (current_slides == slide_link.Length -1)
            {
                PlayerPrefs.SetInt(model_mat[current_lesson].disp_name + "_FileCount", downloaded_img);
                current_slides = 0;
                current_lesson += 1;
                downloaded_img = 0;
                //then it will check if the current lessons is still less than the total lesson (for index error)

                if (current_lesson <= GetComponent<db_materials>().material_count - 1)
                {
                    slide_link = model_mat[current_lesson].slides.Split(',');
                    img_name = model_mat[current_lesson].disp_name + "_" + (current_slides + 1);
                }
            }

           
            if (current_lesson <= _cnt)
            {
                WWW www = new WWW(slide_link[current_slides]);
                yield return www;
                Texture2D texture = www.texture;
                byte[] bytes = texture.EncodeToPNG();
                File.WriteAllBytes(_path + img_name + ".png", bytes);
                Debug.Log("downloaded: " + img_name);

                downloaded_img += 1; // this will count slides then will save it for future reference

                num_threads -= 1;
                current_slides += 1;
                total_file_download += 1;

                ShowLoading("(" + current_slides + "/" + (slide_link.Length - 1) + ") Downloading " + model_mat[current_lesson].subject + " resources...");
                yield return CoroutineUtils.Try(DownloadSlidesCurrent());
                
            }
            else
            {
                yield return CoroutineUtils.Try(FinishSetup("Setup Complete!"));
                //StartCoroutine(FinishSetup("Setup Complete!"));
            }
        }

    }

}
  • oh and 1 more thing…
  • it just suddenly close not showing any messages in my android devices saying it crashes or something… while in the middle of downloading the file

nvm, after weeks of debugging, I have found that the memory leak is what causing the app to crash.
the code "Texture2D texture = www.texture; " - this create to many instances of that object after each image is downloaded, so by adding, UnityEngine.Object.Destroy(texture) below, it solves the problem.,nvm. after weeks of debugging, I have found that crashes is occurring because of memory leak.
I identify that the objects I initialized (Texture2D texture = www.texture;)
needs to be destroyed after use, because it creates many instances of that texture.
by adding UnityEngine.Object.Destroy(texture) below solves the problem.