Status 400: Failed to load the photo

Hello guys,
I’m trying to make a custom Avatar scene, based on RPM examples. All is working into Unity Editor (perfectly), but when I export to WebGL, however, I can’t move forward this.
I got a “failed to load the photo”, when i try to select a custom Avatar from a list. Also, i see a strange list of avatar (some are missing).

Any idea?

I tried with 6.0.0 and 6.1.2, the issue is the same.

Hello and welcome to the forum,

Are you using the camera to take a photo and generate an avatar, or do you choose the ‘‘continue without photo option’’ and then get this error when you select from the templates?

Thank you!

I’m using “continue without the photo”.

You can see the issue here: Unity WebGL Player | Project Sceicchi

I see you added more examples of avatar templates to the initial sample, but some look empty. Can you share the code for the script that handles the selection screen?
Also, can you confirm again that it works in Editor but doesn’t work only on the WebGL export? Ideally, maybe you can share a video of how it looks in the Editor when it shows correctly so we know what’s the expected outcome :slight_smile:

I don’t use any custom code, i copy-pasted the Avatar sample and edit the UI.

Also, i never added any avatar examples.

It works in the editor (here i see empty avatar, but i can advance and edit my avatar), but not in Web GL Build. It works also in Windows Build.

I have some news. The empty avatars is an issue caused by some GameObject inside the UI. I deleted this and now is fixed, BUT i cannot create an avatar, i got the same error.

It continues to work in Unity Editor, Windows Build but not on WebGL.

Hello,
The link shared above still shows the empty avatar templates. Could you update it with the new build to see the current issue?
On our end, building to WebGL our sample scene works. Could you provide more information about the changes you made so we can track where the issues come from?
You can also try to build our sample scene without any changes to confirm that the WebGL sample works on your end too.

I ran into what I believe was the same issue after upgrading Unity from 2021.3.5f1 to 2021.3.38f1. The AvatarCreatorWizard would fail after choosing an avatar template with the message "We failed to load the photo (we bet you look great, though)! Please try using a different file." even though the photo selection was never attempted. This only ever occurred in builds, never in the editor.

The issue was very hard to reproduce, and didn’t occur when importing the SDK into an empty project. Sometimes, changing seemingly random things would fix it.

It seems that for whatever reason, the "id" field in the response from AvatarAPIRequests.GetAvatarTemplates() was no longer deserializing correctly, which caused the later code to incorrectly assume that you didn’t choose a template and are trying to create an avatar from a photo (even though no photo was ever taken, resulting in the API call failure). I confirmed this with a minimal code sample like this:

var data = "{\"imageUrl\":\"https://readyplayerme-avatars.s3.amazonaws.com/avatar-template-images/white-female-1.png\",\"id\":\"645cd1cef23d0562d3f9d28d\"}";
var x = JsonConvert.DeserializeObject<AvatarTemplateData>(data);
Debug.Log("Does this work? id=" + x.Id + " imageUrl=" + x.ImageUrl);

Which printed:

Does this work? id= imageUrl=https://readyplayerme-avatars.s3.amazonaws.com/avatar-template-images/white-female-1.png

After a few hours of debugging I figured out that Unity is likely somehow striping out the Id property setter because it thinks it’s unused. Other strings in the class worked because they were fields, rather than properties. Changing the Managed Stripping Level in Project Settings > Player from the default of Low to Minimal seems to have fixed the issue.

Alternatively, you can create a file called link.xml anywhere within your Assets hierarchy with the following contents, to force Unity to never strip the RPM assemblies, which seems to work just as well:

<!-- Workaround an issue after Unity 2021.3.5f1 -> 2021.3.38f1 upgrade where some of the JSON serializable properties get stripped randomly -->
<linker>
  <assembly fullname="ReadyPlayerMe.Core" preserve="all"/>
  <assembly fullname="ReadyPlayerMe.AvatarCreator" preserve="all"/>
</linker>

(listing the serializable types explicitly, or using preserve annotations in the code would be even better, but I didn’t want to bother with that)

1 Like