This object is in archive! 

infinite loop with conveyor sorter

Denzel J Holmes shared this bug 3 years ago
Won't Fix

Summary

I've been playing space engineers for some time to better keep track of how many components I have, so I can more easily know when I need more. I've been using in-game scripts but these tend to be a bit of a performance hog. I finally got around to trying the conveyor sorter you added some time ago as a replacement for the in-game script method of putting all my components in specific storage and ran into an issue where the game creates in infinite loop. At this point, my only options are to either put up with the infinite loop and hope it doesn't cause issues or go back to using in-game scripts to handle sorting and put up with its impact on performance.

Issue History

To understand this issue, it's important that you understand where I'm coming from. When I first started playing space engineers there were several things I liked about the game but one feature which I consider critical and relevant to this issue is that no matter which storage you are at you can store and grab an item from anywhere within your base or connected ships. This allows for easier building and getting ready to go on a voyage so it's very important that I not lose this functionality.


The Sorter Block Issue

I've set up a conveyor system using conveyor sorter blocks and every time I run into an issue where some of one item in my storage leaves to be transferred and then comes back to the same storage because I intentionally gave the conveyor sorter only one place to go. This appears to be because of the way the conveyor sorter was designed to function and that the conveyor sorter has no knowledge of which storage block a given item came from or simply fails to use this to prevent this type of loop.

It looks to me as if the conveyor sorter block was designed with a primary focus on its ability to restrict the direction of traffic and give users greater control over where things can flow than its ability to ensure filtered items make it to any particular storage. In the current design, they seem to use as a source anything connected to the side the arrow on the conveyor sorter is not pointing to and as a destination anything on the opposite side of the conveyor sorter. That's what I would expect for a system with the goal of giving users control over the flow of traffic but working as intended here restricts the ability to both sort items to containers and take/deposit from anywhere from any cargo.


The Problem

The problem comes when you try and design a system with the following goals:

- The ability to access the contents of any storage from anywhere to both take and deposit items its critical and must not be lost.

- The primary goal of my use of the conveyor sorter is to ensure all components end up in specific storage.


For the second goal, there is no issue, the conveyor sorter handles this splendidly and I didn't notice any impact on performance when this was running.

The first goal however is a problem. In order to ensure that you can take items from the storage the components should go to, that target storage must be connected to the same storage you are pulling the items from. Effectively making the target storage also a source for pulling items from. This is what results in the infinite loop. I could of course remove the conveyor that allows the target storage to be a source to the conveyor sorter but not without preventing myself from taking any components from that storage. When getting ready to go on a voyage loading my ship with extra components and ore is certainly required so that's not an option with the above goals.

In this configuration with the target storage also a source for the conveyor sorter, the conveyor sorter does what its supposed to and all my filtered items end up in only my desired target storage however since the target storage is also a source some item in that storage is constantly leaving the target storage, passing through the conveyor sorter, and finally coming back to the storage it started from because I intentionally didn't give it any other place to go. In programming, infinite loops like this are typically bad and although in my small setup I didn't notice any impact from this, on much larger servers with more users I expect it would be an issue.

To help illustrate the setup i've used to generate this inifite loop see the attached SE-Sortmap2.png. Also allow me to describe a few things about this image to help you understand my setup:

- I've color coded each box to help make it easier to see which direction items can flow within the system, there is a key at the bottom.

- I've also included arrows on the lines connecting each type of block to show which direction if one-way and both directions where the conveyor sorter doesn't restrict me from passing two-way traffic.

- The color code for storage actually includes my refinery and assembler, I'm referring to anything with storage here, not specifically a storage block.

- The storage block I want my sorter block to place all items in is in the bottom row and named "component storage".

- There are six blocks with storage I want to be able to access items between, including the component storage, assembler, and refinery.


If you need anything else let me know, i'm happy to help.

Replies (6)

photo
1

Great detail of why this is an important feature! And I'm so very happy someone else actually thinks this is important enough to thumbs up my report (https://support.keenswh.com/spaceengineers/pc/topic/turn-sorters-off-if-in-infinite-loop)!


The SE-Sortmap2.png diagram does looks a little over complicated for what's needed to show the issue. It seems to show the use case of the bug being fixed. To reproduce the bug, I think just a sorter pushing into a cargo and also on a shared conveyer network shouldn't cause infinite loop. In other words, this diagram should result in the sorter doing nothing instead of an infinite loop. https://excalidraw.com/#json=5076470946856960,ns6rc2_pH5kWXgdv0mi-kw

photo
1

After finding the issue I did realize that a much simpler setup could likely produce the problem but I went with this diagram because it uses a pretty standard setup to show why it's so important that the issue be fixed.

On Tue, Feb 9, 2021, 22:17 <support@keenswh.com> wrote:

photo
1

@Feddas I just realized you are under the impression that in my diagram the bug would be fixed, this is absolutely false.

It's true that in my setup all items get pushed to my component storage and its also true that I can successfully access all items from any storage regardless of where I am but neither of those are the bug. The bug here is that some item constantly leaves the storage and then comes back in an infinite loop and that bug absolutely is still there.

A more simple design would have detracted from demonstrating the need for the bug to be fixed which is just important as describing what the bug is because all developers have to prioritize what they can fix when. I'm sure you could repro it with something simpler.

This bug seems to be a result of a combination of ensuring that I can still access all storages bi-directional from anywhere and the way the conveyor sorter uses as its source of items to move, any storage connected along the system; Because if I remove the conveyor line that makes my target storage be a source I didn't notice that issue.

I.E. the reason something keeps leaving my target storage is that the target storage is also a source.

the reason the same item eventually comes back to the same storage is my design intentionally only gave it one target storage.

the reason the target storage is also a source is that there is no other way to give myself access to this storage from anywhere.


In short you could say the reason for this bug is that the conveyor sorter system was not designed with the use case in mind of users not wanting to lose the ability to access all storages from anywhere. And that's probably because the focus on that block was not on the drain-all feature but on its ability to restrict flow. Perhaps the drain all feature was an afterthought and that's why this use case was overlooked.

At any rate, a fix will need to somehow take into account what storage is the target and stop using it as a source.

photo
1

"the way the conveyor sorter uses as its source of items to move"

The way the sorter determines its source of items to move is by the count of conveyor blocks to that source. You can setup a grid in such a way that it's deterministic in what order the sorter will pull items. This does not work through connectors. Details here: https://imgur.com/a/Z0DllGS


I agree, a fix should determine if a sorters destination inventory is the same as the inventory it's pulling from, if so cancel the pull and turn the sorter off until the grids inventory is dirty.

photo
1

Well on my own server I have it setup the way i have outlined in that attachment and I can confirm despite having a conveyor junction between it and the conveyor sorter that it does take items from my roof cargo and deposit it into the one on the bottom. Not sure if that's the block type you meant when you said it doesn't work through connectors or not. Just wish that infinite loop would go away. I don't dare make a complete system with these because of that infinite loop.

multiple having or involving or consisting of more than one part or entity or individual More (Definitions, Synonyms, Translation)

photo
1

Hello, Engineers!

Sorry that you are experiencing this issue in a first place. And thanks for extending information on the subject. But to say the truth, I found myself kinda lost in all its complexity.

You thing any of you can provide the actual game save with grid showing this issue in the game as well, please?

From what I learned from the text and comments, this issue is global and it does not matter if you are playing single played or any type of multi player, am I right? Is it possible to observe it on vanilla game without any mods?

Thanks in advance for providing the save file with the affected grid - showing is always better than telling, hope you understand.

You can access your save files by typing %appdata% into your Windows search bar and you will be redirected to the hidden Roaming folder. After that just follow: \Roaming\SpaceEngineers\Saves. There should be a folder with your SteamID and your saves.

Please zip the file and attach it here. If you are having difficulty attaching files you can optionally use Google Drive. When sharing a google drive link please make sure it is set to be downloadable by anyone with the link.

Thanks again for you cooperation.

Kind Regards

Keen Software House: QA Department

photo
1

Sure, a save game is attached. This same game has a single grid. The goal of this grid is to allow for a play to deposit a beverage item into any part of the grid and to sort Clang Kola and Cosmic Coffee.

Note: Both sorters are set to drain all.

Note: Both sorters have conveyors setup to pull from and deposit to the entire grid.


Repo steps:

1. View the inventory of the only grid in this world.

OBSERVE the Clang Kola being toggled between its sorter and its cargo again and again (AKA infinite loop).

EXPECTED the Clang Kola to stay in the "Cargo Kola" container. The Sorter to not pull from the same container it uses as its destination.

photo
1

Hello, Feddas!

Wow, thanks! Awesome. This is exactly what I meant by show once is better than tell with million words :)

It´s clearly visible there and thus successfully reproduced and put into our internal system.

Thanks so much for the save again.

Kind Regards

Keen Software House: QA Department

photo
1

My pleasure! Glad this post is getting attention and that Denzel linked to and posted on the duplicates of this post so I knew about it.

Thank you for QAing Ondrej!

photo
1

With how old those posts were I wasn't sure how useful it would be to link them but I'm glad it ended up helping out.

On Wed, Mar 17, 2021, 09:27 <support@keenswh.com> wrote:

photo
1

Hello, everyone!


Thank you again for your report. I'm sorry to inform you, that according to our programmers this issue is too complicated and unfortunately cannot be fixed.


Kind regards,

Keen Software House

photo
1

You can fix this within the game already. It requires some planning ahead usually for optimal layout but most systems can be retro fitted.


Here is my solution to the problem.

https://excalidraw.com/#json=6237969467834368,BdYScQuB3Ddb4s6u_6VR6g


Basically you use connectors and collectors to create an air gap. This method uses an additional unsorted storage as a temporary holding area for everything that is waiting to be sorted.


So in my main working area I will usually have a return storage crate and a non return storage crate. I can grab anything I want from the normal storage crate and move anything to any other storage crate. (except the return storage) the return storage acts as a garbage recycler anything I toss in there immediately starts getting pulled away by the sorters. So when I am done building something and have too much left over I just dump it.. Or.. Manually drop it over my ore collector.


This system contains no infinite loops and let's you pull from anywhere. I do hide the return storage crate from the inventory. And you can hide the main storage before the air gap If you want so you don't see it.


The sorters pull the materials out of the main storage. They end up at the connectors which are set to drain all and to eject. (and you can add more to speed up the process) the connectors are set directly next to a collector which leads directly to a storage. So if you get real close you can see the little puff of smoke as it gets shot out and immediately sucked up by the collector.


This means the sorters are only drawing from the temporary storage and can't create an infinite loop. It also means you can freely pull from and move things around as needed. However... If you manually put something back into the wrong storage like put ore in your components storage it will stay there. Which is why I use a return storage or drop into the gravity collector. (the gravity generator is not needed for the system to work but if you want to have a garbage chute on the outside of your ship or something then that's what it's for.)


The biggest downside is that it's slower than normal but not terrible. If you hook up a massive ship load full of stuff you want to offload into a factory or something you coukd run into a bottleneck but you could also just make more temporary storage to free up the ship quicker or just make more connectors and collectors to speed up the process.

photo
1

Hi @Dustin Fox, Thanks for the post and the excalidraw diagram. What stops the connector/collector air gap coming out of your "Assembler or Refinery" from collecting items from the 3 large storage containers? I don't get why that air gap coming out of your "Assembler or Refinery" wouldn't cause an infinite loop.

photo
1

For that you would just have it set to eject but leave off drain. So it doesn't pull material. The assembler would pull the ingots from storage and then spit out the products.when it spets then out it will be spitting them into the collector set to eject and that will push it back to the sorting system.


I made this from memory so I'm not 100% on the assembler / refinery. I know the rest works. Ingots and ore only have one place to go (except ice / uranium) so it's not an issue if the system is pulling them it won't infinite loop once the assembler is full or you run out of ingots. The air gap prevents it. IIRC the assembler / refinery act pretty normal with this system.. They still occasionally get too full or end up hiding all your uranium from you but you can go in and manually move it.

photo
1

Thanks Dustin Fox. The workaround you described here does about half of what I was looking for. You can take anything from any storage but you still have to put items in a specific storage in order for them to get moved to the right location.

What I was looking for is something that makes it so you can grab anything from any storage and put your items in any storage and have it still end up sorted in the right place. The setup I put in my original post actually does this but has the problem of an infinite loop which apparently is never going to get fixed.

I know scripts can make this happen but I was hoping for a way built-in to the game. Since it refused to fix the problem looks like I'm stuck with scripts.

photo
1

The main reason I posted this as a bug in the first place is that there is a way to create an infinite loop in the game and that's generally considered a really bad thing.

Replies have been locked on this page!