Conversation
dktapps
left a comment
There was a problem hiding this comment.
There are too many unrelated changes in this PR. Cycle destroying makes sense, but I'm not a fan of imposing an arbitrary hard limit on forms, particularly since it won't stop the player spamming forms anyway.
| $this->spawnPosition = null; | ||
| $this->deathPosition = null; | ||
| $this->blockBreakHandler = null; | ||
| unset($this->forms); |
There was a problem hiding this comment.
This could just set the field to [] instead of unsetting
| * Closes the current viewing form and forms in queue. | ||
| */ | ||
| public function closeAllForms() : void{ | ||
| $this->forms = []; |
There was a problem hiding this comment.
This really ought to trigger onClose for the affected forms
There was a problem hiding this comment.
there is no onClose() method
There was a problem hiding this comment.
Give null to the response handler, that would be what the client would do
There was a problem hiding this comment.
on my plugin, the handler may send the same form to player again when the response is null. this is not expected and may cause another issue
also the client can ignore the forms sent by server like this
There was a problem hiding this comment.
Well, the forms should know that they've been discarded in my opinion. As far as I know, the current method will cause the client to send close responses for any sent forms anyway, so this would just be mirroring the existing behaviour. (Correct me if I'm wrong.)
There was a problem hiding this comment.
PMMP should not trust the client behavior
the solution for me is just ignoring it or adding Form->onDrop() (BC break)
There was a problem hiding this comment.
for some server i played, player pressing "X" (= passing null to handler) to close the form will back to previous page (= send new form)
| if(count($this->forms) >= self::MAX_PENDING_FORMS){ | ||
| $this->logger->debug("Exceeded pending forms limit, removing oldest form"); | ||
| unset($this->forms[array_key_first($this->forms)]); | ||
| } |
There was a problem hiding this comment.
I don't like this. This seems very arbitrary, and it also doesn't notify the sender that the form was discarded
This reverts commit f18f3e6.
|
for limit of pending forms, try this and check the memory used fake player by https://github.com/PrismarineJS/bedrock-protocol |
|
this is the result on my PC |
|
You should be rate limiting this yourself rather than making PM impose general limits. PM isn't responsible for the means by which forms are sent. If you don't limit it yourself, the player will get lots of copies of the same form anyway, which isn't good in any case. |
|
i think PMMP has responsibility to limit it. this is count limit of array instead of rate limit. it is easy to waste server memory but this will take some time |
Related issues & PRs
Changes
Player->closeAllForms()Player->formsonPlayer->destroyCycles()because class extending\pocketmine\form\Formin plugin may contain Player class variable which may lead to memory leakAPI changes
Behavioural changes
Backwards compatibility
Follow-up
Tests
i haven't tested yet