Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Huge fps drop with UnityWebRequest.GetTexture

Discussion in 'Multiplayer' started by SassyPantsy, Feb 13, 2023.

  1. SassyPantsy

    SassyPantsy

    Joined:
    May 17, 2020
    Posts:
    129
    Hi all,
    I'm not building a multiplayer system or anything, but I figured this will be the best place to ask around in.

    I have a few menus that use UnityWebRequest.GetTexture and UnityWebRequest quite often, to download images and text from a server (that currently runs locally). I've noticed a really big FPS drop when I call UnityWebRequest.GetTexture. Its basically a good 1-2 second screen freeze (depending on the image size).

    The flow is that a System.URIi is created from a url string -> WebRequest is sent -> a texture's returned -> A sprite is created from that texture -> that sprite's assigned to an image container.

    I don't mind not having an image until it finishes loading, but I just don't want my game to freeze.

    I'm guessing the drop might actually happen when I create the sprite and not when the request is sent/returned, but either way I'm not so sure how could I optimize it.
    Anyone knows any good practice for this flow? Or at least what am I doing wrong?

    BTW, I have an amd R9 5900x and an R9 290 GPU with 16Gb 3600mhz ram

    Thanks!