Uploaded image for project: 'Minecraft (Bedrock codebase)'
  1. Minecraft (Bedrock codebase)
  2. MCPE-153925

Client can overwrite/corrupt resource packs when caching from host

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Awaiting Response
    • None
    • 1.18.12 Hotfix
    • None
    • Plausible
    • Multiple

      Expected results
      Joining an official bedrock server with multiple resource packs should first download them after accepting the prompt, then join the game world.

      Observed results

      When joining the official bedrock server, downloading more than one resource pack during the login sequence can randomly cause the client to disconnect with the generic error message "Encountered a problem while downloading or applying resource pack." on a dirt-texture background.

      Steps to reproduce

      1. Download test_files.zip and unpack into the server's "development_resource_packs" folder
      2. Move "world_resource_packs.json" into the server's "worlds/<your level's name>" folder to enable the two test resource packs for that game.
      3. Join the server
      4. If the error does not appear, clear Test A and Test B from cache and retry 3 (the bug is timing related and thus unpredictable).

      Side effects

      • The Settings > General/Storage -> Cached Data interface is confusing, as deleted packs are not removed from the list immediately, but only when another mixed-in pack is removed.
      • After removing one pack from the aforementioned GUI, its memory footprint shown on the right changes.
      • Pack dependencies and the pack stacking logic are both broken due to unpredictable overwriting of the files.

      Probable cause

      When caching resource packs, the game seems to use a Base64 encoded 8-byte timestamp with 4 bytes of unix timestamp and 4 bytes of (probably) microseconds as a string for the pack's cache folder name (eg. "MpjdYW4HDgA=").

      During pack download, if two packs complete the download at roughly the same time, both packs will be unzipped into the same folder due to time-based naming. This causes a race condition for overwriting duplicate files like the important "manifest.json" during unzipping.

      Now, the game's resource pack cache list in memory and on the filesystem is out of sync. This can be proven by first validating that this condition is present by inspecting the downloaded packs' cache folder (singular!) and notably, only one "manifest.json" is present. This one folder will now contain both the folders "test_A_files" and "test_B_files".

      Looking at Settings > General/Storage -> Cached Data will reveal either Test A, Test B or both packs. If both packs show up, deleting Test A deletes the folder in /packcache. Now restarting the client, pack B will not be in cache anymore (the whole pack cache folder is deleted).

      Fix

      • Use a unique cache directory name for storing server pack data, like the hash of the pack's UUID and version.

      Workaround

      • One can try to join the server once more. The error will probably not appear and packs will load.
      • Copying packs manually into the packcache directory does work, as the game ignores folder names.
      • Use larger packs, delaying the download (still unpredictable).
      • Use packs of greatly differing size (still unpredictable).

            etwas Etwas
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: