CustomSkinLoader

CustomSkinLoader

3M Downloads

[Bug] Crash when enableLocalProfileCache: true and textures payload empty

evan-goode opened this issue ยท 0 comments

commented

Describe the bug

When enableLocalProfileCache is true, and the skin server provides an empty textures map for the player, the client crashes when joining a world (singleplayer or multiplayer).

According to the authlib-injector Yggdrasil server spec, skin servers can omit the skin or cape field of the textures object inside the base64-encoded textures profile property if the player does not have a skin or cape assigned. I don't know whether the MojangAPI implementation here cares about the authlib-injector spec, but it would be nice to be compatible :)

EDIT: According to https://minecraft.wiki/w/Mojang_API#Query_player's_skin_and_cape, the skin texture field "does not exist if the player does not have a custom skin". This might have been true at one point, but does not seem to be true now...

The crash happens at Common/src/main/java/customskinloader/profile/ProfileCache.java:

localProfiles.put(username.toLowerCase(), null);

where a NullPointerException is thrown. localProfiles is a ConcurrentHashMap, which unlike a HashMap cannot have null keys or values. Given that this is the underlying problem, there's probably a simpler way to trigger this bug that doesn't involve an empty textures map.

Perhaps localProfiles could be changed to a Map<String, Optional<UserProfile>>?

Here is a minimal reproducing configuration file:

Minimal config file
{
  "version": "14.22",
  "buildNumber": 31,
  "loadlist": [
    {
      "name": "Drasl",
      "type": "MojangAPI",
      "apiRoot": "https://drasl.REDACTED.com/",
      "sessionRoot": "https://drasl.REDACTED.com/"
    }
  ],
  "enableDynamicSkull": true,
  "enableTransparentSkin": true,
  "forceLoadAllTextures": true,
  "enableCape": true,
  "threadPoolSize": 8,
  "enableLogStdOut": false,
  "cacheExpiry": 30,
  "forceUpdateSkull": false,
  "enableLocalProfileCache": true,
  "enableCacheAutoClean": false,
  "forceDisableCache": false
}

Steps to reproduce

1. Use Minecraft 1.20.6 (version probably doesn't matter) with CustomSkinLoader 14.22.
2. Use a skin server that sends an empty `textures` object inside the base64-encoded textures profile property. Drasl will do this when a user doesn't have a skin.
3. Use the above CustomSkinLoader.json.
4. Join a world. The game will crash.

Link to crash-report if applicable

https://mclo.gs/lUUFkLp

Link to CustomSkinLoader.log if applicable

https://mclo.gs/sNRbIp9

Link to latest.log if applicable

No response

[Only Forge User] Link to Forge Log if applicable

No response

Mod Version

14.22

Minecraft Version

1.20.6

Minecraft Launcher Name and Version

Fjord Launcher 9.2.1

Mod Loader

Fabric

Operating System

Linux

Before submitting a bug report

  • This bug wasn't already reported (I have searched bug reports on GitHub).

  • This is a valid bug (I am able to reproduce this on the latest dev build).

  • This problem is triggered in the latest version of the mod (if not the latest please upgrade the mod first)