Skip to content

fancyholograms: Fix holograms silently stopping to show/update (dead scheduler tasks) - #387

Open
intersecato wants to merge 1 commit into
FancyInnovations:mainfrom
intersecato:fix/fancyholograms-visibility-task
Open

intersecato wants to merge 1 commit into
FancyInnovations:mainfrom
intersecato:fix/fancyholograms-visibility-task

Conversation

@intersecato

@intersecato intersecato commented Nov 16, 2026 •

Copy link
Copy Markdown

📋 Description

All periodic hologram tasks in FancyHolograms run on the FancyHolograms-Holograms thread via ScheduledExecutorService.scheduleAtFixedRate / scheduleWithFixedDelay, with no exception handling. Per the ScheduledExecutorService contract, if a single run throws, all subsequent executions are suppressed. The exception is stored in a ScheduledFuture that nobody reads, so nothing is ever logged.

When this happens to the visibility task, holograms stop appearing and disappearing as players move. They only show up again on join, teleport or world change, because those paths go through PlayerListener and not through the dead task. The console stays completely clean. That matches several open reports:

How we discovered it

  • JFR, 60 s with a 1 ms sampling period, filtered on the FancyHolograms-Holograms thread:
    • lambda$initializeTasks$3 (text refresh): 160 samples
    • lambda$initializeTasks$2 (pending changes): 4 samples
    • lambda$initializeTasks$1 (visibility loop, calls forceUpdateShownStateFor): 0 samples, even though it iterates 867 holograms × online players every second.
  • Heap dump: the lambda instances for tasks $2 and $3 are alive. The instance for $1 is gone, because the executor dropped it from its queue after the failure.
  • Restarting the server, or rejoining, "fixes" it until the next exception.

🔍 Changes

FancyHolograms v2

  • HologramManagerImpl#initializeTasks
    • The visibility, pending-changes and text-refresh loops are guarded per hologram and player. One failing hologram can no longer kill the task or skip the others.
    • Failures are logged through the FancyLogger with the hologram name, the player and the stack trace, so the actual root cause finally shows up in console.
    • Logging is throttled to once per minute per task/hologram key, so a persistently broken hologram cannot flood the console.
    • Online players are copied once per run with List.copyOf(Bukkit.getOnlinePlayers()), instead of being iterated live for every hologram from an async thread.
  • Hologram#viewers: HashSet → ConcurrentHashMap.newKeySet(). The set is changed from the hologram thread (show/hide) and read or copied from the main thread (API, commands, getViewers()). v3 already does this.
  • Visibility.ManualVisibility#distantViewers: wrapped in Multimaps.synchronizedSetMultimap, since it is accessed from the same threads.
  • Hologram#isWithinVisibilityDistance and HologramImpl#show: check Location#isWorldLoaded() before calling getWorld(). On Paper, getWorld() throws IllegalArgumentException("World unloaded") once the world reference is gone, which was a direct way to kill the task.
  • FancyHolograms#onEnable: the autosave task is guarded, so one failed save does not silently disable autosave for the rest of the uptime.

FancyHolograms v3

v3 has the same pattern: HologramControllerImpl#initRefreshTask and both loops in #initUpdateTask run in scheduleWithFixedDelay with no exception handling. On Paper, FoliaSchedulerHelper.playerScheduler runs the runnable inline, so any exception thrown by refreshHologram, shouldSeeHologram or updateFor reaches the executor and cancels the task for the rest of the uptime.

  • HologramControllerImpl: the refresh, update and text-update loops are guarded per hologram and player, with the same throttled logging. On Folia the guard sits inside the runnable passed to the player scheduler.
  • The refresh loop copies the online players once per run (List.copyOf(Bukkit.getOnlinePlayers())).
  • FancyHologramsPlugin: the autosave task is guarded.
  • Hologram#viewers is already a concurrent set in v3, so nothing to change there.

Nothing changes when no exception is thrown: visibility interval, update interval and caching are untouched.

🧪 How to Test

  1. Build and start a server with a few holograms and at least one player.
  2. Force an exception inside the visibility path. For example, register a HologramShowEvent listener that throws for one specific hologram, or unload the world of a hologram.
  3. Before: after the first exception, no hologram appears or disappears when walking in or out of range until you rejoin or teleport. Nothing is logged.
  4. After: the error is logged once, with the hologram name and stack trace. Every other hologram keeps showing and hiding normally.
  5. Optional: profile with /spark profiler start --thread FancyHolograms* and check that the visibility loop (forceUpdateShownStateFor in v2, refreshHologram in v3) keeps showing up over time.

✅ Checklist

  • My code follows the project's coding style and guidelines
  • I have tested my changes locally and they work as expected
  • I have added necessary documentation (no documentation changes needed)
  • I have rebased/merged with the latest main branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant