pyanodon / pybugreports

Central bug-report repository for pymods
The Unlicense
5 stars 1 forks source link

Insertion deadlock when production building asks for more than an item's stack size #262

Open alexkaratarakis opened 1 year ago

alexkaratarakis commented 1 year ago

Mod source

Factorio Mod Portal

Which mod are you having an issue with?

Operating system

GNU/Linux

What kind of issue is this?

What is the problem?

There are cases where the production building is requesting for more items than the item's stack size. This causes the inserters to pick up additional items to place into the building, but then failing to do drop them because the stack size limit has been reached. Since the inserter(s) is now blocked until it drops its payload, the production building may stop producing if another ingredient runs out, causing a deadlock.

Automatic insertion limits may be relevant here: https://wiki.factorio.com/Inserters#Insertion_limits

Steps to reproduce

The examples use 1 inserter for easier reproducibility, but the deadlock can occur even when having more than 1 inserters.

Example 1: Lab researching one of the high sciences

1) Have a box containing all science packs 2) Have 1 inserter picking up science packs from the box and putting them in the lab 3) Lab is researching Pyrhhic Victory

After a couple of cycles, you will get a deadlock like the following.

a) deadlock with Automation Science Pack

Screenshot from 2023-04-01 10-27-40

b) deadlock with Py Science Pack 1

Screenshot from 2023-04-01 10-46-27

The problem can occur with either Automation Science Pack (recipe needs 200) or Py Science Pack 1 (recipe needs 100). The inserter will attempt to load more than that (presumably 2x), even if other science packs are missing. Other science packs stop at 2x what the recipe asks (matching what the wiki says about lab limits), which is below each pack's stack size. The highest one of the others is the Logistic Science Pack which stops at ~160, and since its stack size is 200 (and the gap between the 160 and 200 is more than what an inserter can do in 1 swing), it won't cause a deadlock.

For Py Science Pack 1, the request is 200 science packs which is right at the item's stack size limit, but can still cause a deadlock due to the inserter's stack size (as per the screenshot).

Workaround: Have an auxiliary inserter than blocklists Automation Science Pack and Py Science Pack 1.

Example 2: Basic Oxygen Furnace with Rocket Fuel

1) Have a belt with plastic and Rocket Fuel 2) Have 1 inserter picking up from the belt and loading into a Basic Oxygen Furnace 3) Basic Oxygen Furnace is using the 3x Antimony Oxide Recipe (recipe-name: sb-oxide-02). Supply Oxygen and Antimony Pulp 02 as well. 4) (optional) Use speed modules for faster repro

After some cycles, you will get the following deadlock

Screenshot from 2023-04-01 10-28-01

The furnace needs plastic, but the inserter is stuck trying to place Rocket Fuel which it never will because the furnace won't consume Rocket Fuel until more plastic is inserted.

Workarounds: a) Have a dedicated belt for fuel b) Have an inserter that filters-in fuel, and an inserter that filter-out fuel (but that can be problematic as you can have as many filters as the filter-inserter-type allows and can't mix or swap fuel without modifying the filters) c) Use a smaller stack size limit only when using Rocket Fuel. 5 seems to be safe given the insertion limits from the wiki.

Additional context

Here is a blueprint with the above two examples.

0eNrdWttu4yAQ/Ree4xUGX6P9k9UqwjbJovomwFWjKv++4Kip60ICtuKV9qWK6TBzODBnBifvoKgH2nPWSrB/B6zsWgH2v96BYKeW1HpMnnsK9oBJ2oAdaEmjn/pzUNG+E0wGBRGsBJcdYG1F38A+vOweTi+6Y9C8wGgyDV1+7wBtJZOMXiGMD+dDOzQF5crvbXbJKZHslQZNVx2040B0Ay+p8j9CYl2rI2ssWfwj3oEz2Mc5/hGraEdWS8qvAT4Af66Kd9VQ6vmBKBltSxr0pHwBekUfMB8b/9bmM/BoEfjUB3zdnZiQrHSAbjE1AceLgGderJ+/4AgiC9/fzUyAoyWA89AHcMNqJgk/OzBtMTUBjxcBhz7AB6nhuOA2W5pgJ4tgIx/YQkWnDqBNdibI6W0Gfes5FSKQnLSi77hSM1rL+zoSjYArxml5tYgMIbJPUFIfVtYKytUK77uOR9dKgyXv6kNB/5BX1nFtWDJeDkwe1P+q2+wj40IeHim1VdN0IIVOK38MoX5sesKJ1BHBT3C5WrTXZQodINR/TpzSdirQrFKboOT7cjEQkS/gOvXjOoQeZKdPJdumwZtQHYYLuM48uUYeXGfPPdiGsrENz9if50mBceM5cud54vsZPNuq3TZcxwu4hp5cJx5cw6dyTQbZNeSfiXW4oDJOSrkb2x6lceL7GWwb+4ptiM4XdE0I5jM67rfVNRlLUUG4uV3iXflCZXAcaG25tMAFBQXfMCbz44BMMZZd65A9SvKAF3uOGTiyGhv5Qvb7sWENH7uZQPhxuN2OVZhNgo8DyXwgmg+g+QCcDcx9IjwfyGcD0dxFNLeIoeX8I+zRRkR39/q/EmAUeWfcVBVSFwFG8aoYiVOM5Purnu9ew8+dzb9pxQ6oz2zcIlEE3RuraACR8qI3bORX9JRWWiyGmgZYAzEhSVdpWOakYdlKDct8NWze+4Zur0xCi27li7Ixe3o2mpa5SR7iz8pXk8LUmaQ38Vbdt9GFpbD1RAj9mbaUn853iv0tNYze0aokzl2SGONVMTKnGJN7TkPqOqhJ05ukAn7BbvJkeX/22rEqKP9QYYIb5g/dul8OUJjZCU5MvlMz5GM9KMzWkzEJY0rBm2x+9anOf3B13L2dTyoXTICyFWJ5zYSHYonzVWJpiOIrlthNLLHl/TJcIJZm1M8VS7yVWEahx40umjW9D1IksnxxIoae8kAMhYo4zrYKqKLeCHqNuBm20yRuUbQqBnSKEa9KWeSSslGyKgZ2ipGulAXkKwuqJjSsJLXDLdBiapSHbOU68Fp5Q27yhiz480Xyhp4ub7bt2kTi4mWijzcXfbQZI+EqbUMu2hYjj94L3jmLJt94Xe9lPvIPey91le2Hutc3Wf17h3Ez95PfYOzAq0r0q0pmYZTmKE1yBDOMLpe/wBg9/g==

(This blueprint uses https://mods.factorio.com/mod/creative-mod entities for item and power generation)

Factorio Version 1.1.80 pycoalprocessing: 2.1.0 pyrawores version: 2.4.8 (these are latest as of 2023-04-01)

Log file

No response

notnotmelon commented 1 year ago

Do you have a solution for this? Seems like an engine issue.

oorzkws commented 1 year ago

I think the former can be solved, sort of, but there would still be cases where the inserter stack size would cause issues unless we put the science stack size very high. The latter I'm not certain can be solved within a mod. Thoughts?

alexkaratarakis commented 1 year ago

Possibly helpful: It is possible for buildings to exceed the item stack size. Below is an example with Korlex Food. Meat, Seeds, Tin Plate have stack-size 100 while Flora, Fish, Seaweed, Fawogae, Salt have stack-size 50. All limits are exceeded in the screenshots below.

Furthermore, crafting speed seems to affect the "internal" size. The beaconed building in the second screenshot allows even more items. I was able to go even higher by stacking more beacons.

Screenshot from 2023-04-06 09-33-05

Screenshot from 2023-04-06 09-33-35

ShadowTheAge commented 1 year ago

I think increasing automation science pack size to 400 (2x 200 where 200 is the highest recipe size) or to 411 (2x200 + 12 - 1 where 12 is the max stack inserter size)

and increasing stack size for pysp1 to 211 (2x100 + 12 - 1) should mostly fix the issue

kingarthur91 commented 1 year ago

I think increasing automation science pack size to 400 (2x 200 where 200 is the highest recipe size) or to 411 (2x200 + 12 - 1 where 12 is the max stack inserter size)

and increasing stack size for pysp1 to 211 (2x100 + 12 - 1) should mostly fix the issue

Absolutely not doing random ass numbers like 411 or 211. It's arbitrary and annoying to both dev and players. I'd rather round up to the nearest 50 or 100.

but we can look at increasing the sizes. Probably inline with the endgame tech ratios to hopefully fix the issue.

ShadowGlass0 commented 1 year ago

According to the last line on the Automatic insertion limits documentation (https://wiki.factorio.com/Inserters#Insertion_limits), the inserter should be able to overfill the building, instead of deadlocking.

"An inserter that has a higher inserter capacity bonus than 1 can overfill the target building, due to the inserter picking up a higher amount of items than needed. Overfilling can also occur if multiple inserters are used to insert items into one building."

Could you raise this as a Factorio bug? At least we'd get confirmation if the above is correct or not.