Hello,
I would like to report a thread-safety issue with PvPManager when running on Folia / CanvasMC.
When a player disconnects during combat, PvPManager attempts to spawn a combat logger NPC (subclass of ServerPlayer / entity) synchronously within the disconnect/quit event flow. However, this operation violates Folia's regional threading rules and triggers a thread check warning under CanvasMC's TickGuard (which will also start appearing in Paper/Folia once Paper PR #13924 is merged).
The thread check warning stack trace is as follows:
[10:04:00] [Folia Region Scheduler Thread #3/WARN]: [CanvasMC] Thread failed main thread check: Cannot add entity async, context=[thread=Folia Region Scheduler Thread #3,class=io.papermc.paper.threadedregions.TickRegionScheduler$TickThreadRunner,region={center=[44, -20],world=worlds:spawn}], entity={root=[{type=cG,id=844676,uuid=97527597-e09b-4616-a8ef-caff7e378575,pos=(686.742,84.000,-397.277),mot=(0.000,0.000,0.000),aabb=AABB[...]
java.lang.Throwable
at io.canvasmc.canvas.util.TickGuard.guard(TickGuard.java:48) ~[canvas-26.1.2.jar:26.1.2-825-0219586]
at net.minecraft.server.level.ServerLevel.addEntity(ServerLevel.java:1745) ~[canvas-26.1.2.jar:26.1.2-825-0219586]
at net.minecraft.server.level.ServerLevel.addFreshEntity(ServerLevel.java:1693) ~[canvas-26.1.2.jar:26.1.2-825-0219586]
at PvPManager-4.1.71.jar//me.chancesd.pvpmanager.cE.a(SourceFile:96) ~[?:?]
at PvPManager-4.1.71.jar//me.chancesd.pvpmanager.cF.<init>(SourceFile:35) ~[?:?]
at PvPManager-4.1.71.jar//me.chancesd.pvpmanager.cE.<init>(SourceFile) ~[?:?]
at PvPManager-4.1.71.jar//me.NoChance.NMS.v26_1.NMS.a(SourceFile:36) ~[?:?]
at PvPManager-4.1.71.jar//me.chancesd.pvpmanager.gF.b(SourceFile:1021) ~[?:?]
at PvPManager-4.1.71.jar//me.chancesd.pvpmanager.gE.a(SourceFile) ~[?:?]
at PvPManager-4.1.71.jar//me.chancesd.pvpmanager.ev.a(SourceFile:363) ~[?:?]
at PvPManager-4.1.71.jar//me.chancesd.pvpmanager.manager.PlayerManager.applyPunishments(SourceFile:342) ~[?:?]
Reference / Suggested Fix:
The Canvas development team pointed out that Canvas enforces these checks to ensure stability. They suggested that the entity addition (addFreshEntity / addEntity) should be scheduled to the specific location where the entity is being spawned at, rather than executing it synchronously during the connection/disconnection tick.
Also, once this Paper PR is merged, it will enforce similar checks: PaperMC/Paper#13924
Could you please look into scheduling the NPC spawn task using Folia's regional scheduler to keep it thread-safe?
Thank you!
Hello,
I would like to report a thread-safety issue with PvPManager when running on Folia / CanvasMC.
When a player disconnects during combat, PvPManager attempts to spawn a combat logger NPC (subclass of ServerPlayer / entity) synchronously within the disconnect/quit event flow. However, this operation violates Folia's regional threading rules and triggers a thread check warning under CanvasMC's TickGuard (which will also start appearing in Paper/Folia once Paper PR #13924 is merged).
The thread check warning stack trace is as follows:
Reference / Suggested Fix:
The Canvas development team pointed out that Canvas enforces these checks to ensure stability. They suggested that the entity addition (addFreshEntity / addEntity) should be scheduled to the specific location where the entity is being spawned at, rather than executing it synchronously during the connection/disconnection tick.
Also, once this Paper PR is merged, it will enforce similar checks: PaperMC/Paper#13924
Could you please look into scheduling the NPC spawn task using Folia's regional scheduler to keep it thread-safe?
Thank you!