Repository navigation
fancyholograms: Fix holograms silently stopping to show/update (dead scheduler tasks) - #387
Open
intersecato wants to merge 1 commit into
Open
intersecato wants to merge 1 commit into
intersecato wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Description
All periodic hologram tasks in FancyHolograms run on the
FancyHolograms-Hologramsthread viaScheduledExecutorService.scheduleAtFixedRate/scheduleWithFixedDelay, with no exception handling. Per theScheduledExecutorServicecontract, if a single run throws, all subsequent executions are suppressed. The exception is stored in aScheduledFuturethat 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
PlayerListenerand not through the dead task. The console stays completely clean. That matches several open reports:updateShownStateFor()How we discovered it
FancyHolograms-Hologramsthread:lambda$initializeTasks$3(text refresh): 160 sampleslambda$initializeTasks$2(pending changes): 4 sampleslambda$initializeTasks$1(visibility loop, callsforceUpdateShownStateFor): 0 samples, even though it iterates 867 holograms × online players every second.$2and$3are alive. The instance for$1is gone, because the executor dropped it from its queue after the failure.🔍 Changes
FancyHolograms v2
HologramManagerImpl#initializeTasksList.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 inMultimaps.synchronizedSetMultimap, since it is accessed from the same threads.Hologram#isWithinVisibilityDistanceandHologramImpl#show: checkLocation#isWorldLoaded()before callinggetWorld(). On Paper,getWorld()throwsIllegalArgumentException("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#initRefreshTaskand both loops in#initUpdateTaskrun inscheduleWithFixedDelaywith no exception handling. On Paper,FoliaSchedulerHelper.playerSchedulerruns the runnable inline, so any exception thrown byrefreshHologram,shouldSeeHologramorupdateForreaches 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.List.copyOf(Bukkit.getOnlinePlayers())).FancyHologramsPlugin: the autosave task is guarded.Hologram#viewersis 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
HologramShowEventlistener that throws for one specific hologram, or unload the world of a hologram./spark profiler start --thread FancyHolograms*and check that the visibility loop (forceUpdateShownStateForin v2,refreshHologramin v3) keeps showing up over time.✅ Checklist
mainbranch