Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-4752

Chunks not unloaded, but not loaded either according to World#isChunkLoaded

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • Fresh 1.14 Spigot server with newly generated world.

      No plugins except the testing plugin mentioned below.

    • This server is running CraftBukkit version git-Spigot-0c02b0c-e879c44 (MC: 1.14) (Implementing API version 1.14-R0.1-SNAPSHOT)
    • Yes

      While trying to update one of my plugins (Shopkeepers) from 1.13 to 1.14 I noticed the following issues:

      The plugin is spawning mobs, sets them as NoAI and non-persistent, and reacts to chunk unload events to perform cleanup and chunk load events to respawn them. Additionally it periodically checks if the spawned (and tracked) entities are still valid (Entity#isValid) and if the chunk they are in is still loaded.

      In Spigot 1.14, the plugin would find that the chunks for these entities would get silently unloaded (without a corresponding ChunkUnloadEvent), and the entities themselves would still be marked as 'valid' indefinitely. Also the entities would not get removed when leaving the area and coming back, even though they are marked as non-persistent.

       

      To try to further pin-point the issue(s) for reproduction I created a small testing plugin (see attachement, source code included).

      This plugin basically spawns a few different entity variants (NoAI+non-persistent, NoAI+persistent, AI+non-persistent,AI+persistent), checks for chunk loads and unloads, and periodically checks if these entities are still valid and if their chunk(s) are still loaded (according to World#isChunkLoaded).

      I started the server (freshly generated world), the plugin would spawn the mobs and outputs any chunk events and periodic entity and chunk states. Then I joined the server, teleported to these entities, flew away until out of range, flew back to these entities, and logged out again.

      The server log of this can be found in the attachment.

      One can observe the following things:

      • As expected: The chunk gets loaded when spawning the entities (line 164 shows the corresponding chunk load event).
      • As expected: Directly after being spawned (same tick), the chunk is loaded and the entities are valid (lines 166-172)
      • Unexpected: A few ticks later (line 173) the entities are still valid, but their chunk is no longer loaded. And no corresponding chunk unload event was observed in between.
      • Unexpected: The entities stay valid even though their chunk is no longer loaded. (lines 173-676)
      • Line 677: I join the server.
        • As expected: Lines 686-1196: Plenty of chunk loads due to me joining the world. Since I am far away from the spawned mobs, their chunk remains unloaded.
      • Line 1197: I teleport towards the mobs.
        • As expected: Chunks are getting loaded. The chunk with the mobs inside reports to be loaded as well (line 1233).
        • Unexpected: However, there has been no ChunkLoadEvent observed for the mobs' chunk (lines 1200-1233).
      • Lines 1233-2574: I am flying away from these mobs.
        • As expected: Plenty of chunk loading.
        • Unexpected: No chunk unloading observed.
      • Lines 2576: The chunk with the mobs reports to be no longer loaded, but there has been no corresponding chunk unload event in the meantime (actually: no chunk unload events at all..)
      • Lines 2789: I flew back towards the mobs.
        • As expected: The chunk is loaded again.
        • Unexpected: No corresponding chunk load event for this particular chunk.
        • Unexpected: As can be seen from the logged chunk load events, there are also no events for the other nearby chunks (which got already loaded earlier when I teleported towards the mobs).
      • Lines 2990-3451: The first time that chunk unloads are observed. They are mixed with further chunk loaded. But none of these events correspond to the mobs' chunk.
      • Line 3466: I am disconnecting.
        • As expected: Plenty of chunk unload events. Mobs' chunk is unloaded again as well (line 4486).
        • Unexpected: No chunk unload event corresponding to the mobs' chunk.
      • Line 4534: Server is stopped.

      Also unexpected: When teleporting to the mobs and after leaving and coming back, all mobs were present, regardless of their persistence flag that got originally set.

        1. ChunkUnloadChunkLoad 1.14.jar
          2 kB
        2. latest.log
          505 kB
        3. Test.jar
          9 kB

            Unassigned Unassigned
            blablubbabc blablubbabc
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: