raiguard / RecipeBook

Recipe Book for Factorio.
MIT License
20 stars 9 forks source link

Multiplayer player stuck when desync #72

Closed viniciuslrangel closed 2 years ago

viniciuslrangel commented 3 years ago

Describe the Bug

In a modded multiplayer, in the latest versions, the second player cannot move anymore after some seconds.

To Reproduce

Steps to reproduce the behavior:

  1. Host a server
  2. Let a friend join it
  3. Wait some seconds

Save file & Username

SingletonFactorio

Copia do Industrial Craft.zip

Log file

factorio-current.log

raiguard commented 3 years ago

Can you and your colleague both do speed tests of your network connections? That could be contributing.

viniciuslrangel commented 3 years ago

I have more than 50 Mbps of upload and my friend about 10 Mbps of download. Our latency goes between 12 and 32ms. He does have lag sometime when he has anyone in his house. Not sure if you saw, but our modpack is pretty big and it's your mod doing some weird stuff.

But, good job, you did a great mod with a lot of essential features to me. Thanks

raiguard commented 3 years ago

Do you both use the same language, or are you using different languages in-game?

The reason I ask is because this is likely being caused by the dictionary system. Recipe Book has to send a ton of data between clients to translate a bunch of localised strings into a format that the mod can use. This scales linearly with the number of objects you have in a modpack:

image

viniciuslrangel commented 3 years ago

I'm using it in English, my friend is set to Portuguese. If you can give me a brief how this works, I can help debugging/fixing

raiguard commented 3 years ago

Can you type this into the console, have your friend join and time out, then attach the log file?

/c script.on_event(defines.events.on_string_translated, function() log("TRANSLATED "..game.tick) end)

viniciuslrangel commented 3 years ago

This gets us the "mod event handlers are not identical". I paused the level, waited for him to join it then ran the command the fastest I can. Mine My friend's log

oorzkws commented 3 years ago

This happens to me on LAN. I believe it's related to the changes that resolved #56, or that's when it cropped up anyway. I changed translations-per-tick to 5 and it stopped at the same time but I'm not sure if the two correspond.

raiguard commented 2 years ago

So the translations per tick option is entirely legacy, and is used for the old translation module. I never thought I would have to add an option for the new module, but I guess I do. This will require some changes on the flib side as well.

raiguard commented 2 years ago

I've made the necessary change in flib. Once I release it, please update and try decreasing the Dictionary levels per batch setting.

raiguard commented 2 years ago

Were any of you able to find success with decreasing the Dictionary levels per batch setting?

viniciuslrangel commented 2 years ago

Sorry, I couldn't test it yet. I'll in a week or two

viniciuslrangel commented 2 years ago

Just tested today and even lowering it to 1 didn't solve the issue.

raiguard commented 2 years ago

Unfortunately I don't think I can solve this. There is just a lot of data to pass around with the janky translations system that Factorio uses. The only way to fix this would be to remove localised search from the mod and use actual localised strings for the GUI, which would tank performance and severely cripple the mod. I'm sorry.

Bykow commented 2 years ago

Just a heads up: I have the same issue on a multiplayer server

raiguard commented 2 years ago

Sourcehut ticket: https://todo.sr.ht/~raiguard/factorio-mods/7