PocketMine-MP icon indicating copy to clipboard operation
PocketMine-MP copied to clipboard

NetworkSession: add support for discarding repeated packets before th…

Open dktapps opened this issue 7 months ago • 2 comments

…ey're decoded

this dramatically reduces the server workload dealing with spammy packets like right-click interactions trigger. It also solves the problem of players getting kicked for right-clicking for too long.

Related issues & PRs

Fixes #5728 in local testing

Changes

API changes

No public API changes.

The network system has some new functions supporting this feature, but these are not part of the versioned API (as with all pocketmine\network\mcpe stuff).

Behavioural changes

The server will now discard InventoryTransactionPacket when repeated. This may result in a performance improvement in some servers.

Follow-up

Maybe filter out more spammy c2s packets, like AnimatePacket?

Tests

Locally tested with the "Improved input response" toggle in the client set to ON.

Caveats

I'm not sure if doing this might have unintended side effects. So far as I know, there is no obvious reason to send the same transaction multiple times, but I may have overlooked something. Please test thoroughly and feedback.

dktapps avatar May 28 '25 22:05 dktapps

https://github.com/user-attachments/assets/694eab42-c1f9-47d9-9b01-65f28eaa71e6

kostamax27 avatar May 29 '25 10:05 kostamax27

Not too sure how to resolve that issue. I could have it expire the filter after 1 tick, but it might still result in legit actions disappearing in certain conditions.

dktapps avatar Jun 02 '25 14:06 dktapps

The latest commit of the PR should work better for your case @kostamax27, it's now more conservative than before

dktapps avatar Sep 15 '25 18:09 dktapps