How do I get images to load properly?

  1. What do you want to achieve? Keep it simple and clear!
    I want to fix images not loading in properly if possible
  2. What is the issue? Include screenshots / videos if possible!
    When i use GetUserThumbnailAsync, a lot of the images are blank
    image

I’ve tried using imageLabel.IsLoaded:Wait() but it just doesnt load anymore if i do that

2 Likes

Can you share the code that uses GetUserThumbnailAsync?

1 Like

Sorry for the late reply, this is the code I’m currently using:

1 Like

Sometimes, most images load while other times, only a few load properly.

2 Likes

I haven’t done lots of testing by any means, but I also didn’t have any problems loading lots of thumbnails in my testing.
I think it might perhaps have to do with the fact you’re using pcall, which is usually a good idea but the getthumbnail function actually does wonders by checking if isReady is true instead of success from pcall. So I’d recommend testing if it works by doing it the same way as the docs have done it since they don’t use pcall there

1 Like

Thanks for the help! I believe the cause of the missing data might have been me being friends with people who had their account banned or deleted.

2 Likes

Given the amount of duplicates in your UI, your game can benefit by caching the API call results and looking them up in the cache before making an actual API request. Also the if ready then statement in your code is a bit useless, if the image fails to load you should still have the attribute of the player and their failed image instead of a default “Roblox” one.

Another culprit that comes to mind is your retry logic. In your code you have many image labels that all, if they happen to fail, spam the API call with under a second intervals, until they succeed. If an image happens to actually be problematic and unable to load, it will keep making requests forever, causing throttling effects to the rest of the unrelated API calls. To fix this I suggest only retrying a fixed amount of times with increasing delays. For example try once after 0.2 seconds, then after 1 second, then after 5 and then just load a default image.

Lastly since this is related to API calls I suggest making the requests one after another instead of parallel, to avoid any rate limits that might be in place. Currently if I’m not mistaken you tell all your images to make requests at the same time, by having different scripts(however if you switch to non-parallel images may appear slow to load, so you might want to finetune how many images you load at once, if that happens).

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.