Fix: reopen sell-confirm GUI on player region thread (Folia/Canvas crash)#248
Merged
ptthanh02 merged 1 commit intoMay 30, 2026
Conversation
…vas) After a spawner sell completes, reopenPreviousGui() was dispatched via the global region scheduler (Scheduler.runTask). player.openInventory() -> ServerPlayer.initMenu() must run on the player's own region thread, so on Folia/Canvas this throws "Cannot init menu async" (TickThread check fail). Use Scheduler.runEntityTask(player, ...) so the GUI reopens on the player's region thread. On Paper this falls back to the main thread; if the player logged off mid-sell the entity task simply never runs.
fa603ab to
f9e9b8f
Compare
Dueris
approved these changes
May 29, 2026
|
I can confirm(Canvas dev) as someone who's worked with Folia for a long time, all things that involve an entity instance should be scheduled to the entity in question. The global tick should never be used for that, as it's used for states that are global and doesn't have a specified location. Think time/weather for example. If there are other places in the codebase improperly doing this, it'd be recommended to fix that, otherwise it can cause a lot of issues that are often, frankly, undiagnosable. |
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.
Problem
On Folia/Canvas, confirming a spawner sell crashes when the previous GUI is reopened:
Cause
In
handleConfirm(), the post-sellonCompletereopens the GUI viaScheduler.runTask(the global region scheduler). Butplayer.openInventory()→ServerPlayer.initMenu()must run on the player's own region thread, so Folia/Canvas fails the TickThread check.Fix
Dispatch the reopen via
Scheduler.runEntityTask(player, ...)instead, so it runs on the player's region thread.One-line change in
SpawnerSellConfirmListener#handleConfirm(plus comment updates).Tested on Canvas 26.1.2 — crash gone, GUI reopens correctly after selling.