ID:2148798
 
Applies to:Dream Seeker
Status: Open

Issue hasn't been assigned a status value.
The rightclick context menu in byond games is really fraught with problems

Once you get above 20-ish objects on a tile, there starts to be a very noticeable client freeze whenever someone rightclicks, while that menu is populated. This scales up with the quantity of objects and verbs involved in calculations, it just gets worse and worse.

The main problems with this:

1. Useability. In SS13 we have many rightclick commands for things like pointing at objects, giving things to people, picking things up, etc. Thexe exist for quick access, but when large piles are involved, the useability aspect of these is lost, and they become very cumbersome. In cases where these context options are the only real way to do something, it can be a huge pain.

2. Griefing. It is possible for someone to amass a large pile of objects in an area, which will freeze everyone who attempts to inspect it for a long time. This can have gameplay impacts, and will often cause players to quit, thinking their client has crashed.

SS13 has many scenarios where large piles of objects can be created without intentional griefing. Like a gardener or a miner emptying out the bag of things they've harvested. Or anyone opening any kind of locker or crate with a lot of things in it

Something really ought to be done about this menu.
I've spent several hours today working on optimising it, and honestly there's really not much i can do without stripping out a ton of functionality from our game. It seems to scale more or less linearly with the quantity of objects, and verbs on the objects/mob/client involved. I managed to get the freeze time down to 30 seconds (formerly 105 seconds) on a large pile of objects, by removing ALL of the verbs from a human mob (literally, verbs.Cut()). it's still a painfully long time.

I don't think there's anything we can feasibly do to deal with this problem, which is why i'm here requesting that byond devs handle it.

Some possible solutions you guys could code:

1.
A config option to configure a maximum number of objects in the menu, or a maximum amount of time spent on generating it, after which the engine would abandon trying to resolve the rest of the pile and just put "Plus 15 more objects..." at the bottom. Perhaps allowing us to click that to bring up a new popup menu to examine the contents of the turf in more detail


2.
Background loading for this menu. give the user some feedback that the menu is loading, and run it on a different thread, or in the background with space CPU time or something, so that it doesn't freeze up the client while generating the menu.

3.
Keep two seperate verbs lists. One with all of them as we have now, and one which contains only verbs that might be relevant for context menus (generally, those with arguments). And only look at the latter when generating context menus. Whenever a verb is added to the main list, have it automatically added to the latter too if it qualifies. And removed from there if it's removed from the main list.

4.
My personal favourite option, procedural loading of the menu.
Generate the menu instantly, with only one item, and some sort of loading animation underneath indicating it's not done. and then have the menu repeatedly update as more and more objects are processed. The user would see the menu rapidly expand infront of them. The best thing about this, is once the object that they want to do things with is loaded, they could select that, choose a verb, and thus terminate the loading of the menu early.

For best results, generate objects in inverse of their layer/draw order. Those visible on the top of the pile should appear at the top of the menu,


Fusing the latter three ideas together into a hybrid solution could effectively solve this issue in a scaleable manner
511 has slightly faster rightclicks, but it's not perfect.

The delay itself is actually a bug, there is a bug report up, but it's eluding detection. So far we know that the delay has to do with admin verbs that the player doesn't have, somehow not having those verbs causes extra delay. This means that admins have much lower right click delay then players do, (go on, test it out).

We know that it's a network issue, not a cpu issue, the client is asking the server for info in a odd way where it's suppose to be able to get that info dynamically from the world state it already knows about.


In response to MrStonedOne
A bug, how?
What would things be like if that were resolved?

Surely there's still the issue of calculating ~100 verbs across the client and mob, multiplied by the number of objects in the tile, which would cause significant slowdown with or without a bug, unless some combination of the above is implemented.

I can see that such a bug would increase the length of the delay by some indeterminate factor, but i should note that i'm doing my testing, including the above listed time values, as the head admin of a local test server (thus i have all verbs and also no network lag)

Nevertheless i'd be happy to see it fixed, but i'm not confident that solving the bug you talk about will entirely, or even mostly, fix the problem
You can safely add 300 items to a windows gui based context menu without lag, and the webclient when i tested did a html context menu of 500 items in about a full second. So clearly DS can do much faster than it is doing.
I'd rather we just have the tools necessary to create custom right click menus, personally.
That requires waiting on 512, i'd like to see right click get fixed while it still can in 511, then work on expanding the tools needed for custom right click in 512 for if the work in 511 doesn't cut it.
Also, a bug is a bug