AlmuraDev / SGCraft

Stargates mod for Minecraft
https://www.almuramc.com/sgcraft/SGCraft.html
MIT License
31 stars 31 forks source link

Chunk gets unloaded when dialing from computer interface #152

Open drzpk opened 4 years ago

drzpk commented 4 years ago

When I'm trying to dial a distant Stargate (on unloaded chunk) using OpenComputers interface, the dialing sequence gets interrupted before a wormhole is established. However, dialing exactly the same address via a DHD ends successfully.

I did some debugging (using the most recent version built from sources) and it turns out that chunk unload event is fired on the chunk I'm dialing to and that interrupts the dialing sequence. I compared code of dialing from DHD and computer interface and there is indeed a difference, I don't know the internals of this mod to pursue this further, though.

KamaroTheN7 commented 4 years ago

Well, I have this same problem, but when I created respond I got was "You probably have mod, that changes chunk loading", that was true, so I give up, but today I checked it with only Stargate Network, malisiscore and OC, and it still happening.

KamaroTheN7 commented 4 years ago

@IlynPayne A tak w ogóle to fajny twój program wybierający.

Dockter commented 4 years ago

In your configuration files, under "options:", what do you have I:chunkLoadingRange= set to?

Dockter commented 4 years ago

Please try this: http://solder.almuramc.com/downloads/SGCraft-2.0.4-beta-3.jar

drzpk commented 4 years ago

It's set to 1, I've never modified it. But you assumed otherwise, hence the beta-3 artifact. Well, I tested it anyway and - surprise, surprise - it didn't work. dialing still gets interrupted.


Please take a look at this issue, especially the code snippets. Mine, called from the Lua shell, doesn't work, while @dallenwilson's does.

Dockter commented 4 years ago

I'm making some assumptions as I have no way to test this exactly with your environment. I have not been able to replicate this in my environment but I am not using CC. Looking at how the chunk ticket is created is "SHOULD" keep the gate active.

I need you to give me a thread dump at line 578 of SGCraft.java.

Dockter commented 4 years ago

I could create a debug build specifically for you. Talking with another developer we're curious if you're hitting the max chunk ticket threshold. That would cause this issue as well.

Dockter commented 4 years ago

Pull down this commit: https://github.com/AlmuraDev/SGCraft/commit/b1937ccf7394b2923dfe47daee6e3ad6995ac828 and compile. Tell me if you're seeing that debug line during dialing.

Dockter commented 4 years ago

Actually no, that can't be the issue either because you specifically stated using the DHD works fine.... WTH...

drzpk commented 4 years ago

No, this message you've just added didn't show up.

I uploaded the thread dump you asked for (with breakpoint at SGCraft:579, b1937ccf). I also managed to reproduce this error using the world save uploaded below (SGCraft started from Intellij and dependency mods only, no other mods were used). There's an OC setup somewhere around X=33, Y=72, Z=309, just repeat the last command.

threads_report.txt chunk_loading_test.zip

Dockter commented 4 years ago

Curious. Zidane was thinking the mod to blame would be in the trace, yet SF is in the trace....

Dockter commented 4 years ago

If I load this saved world, can you tell me how to tell the computer to dial out?

drzpk commented 4 years ago

The Lua shell currently is running in the dialing computer and the last command I entered was sg.dial, so just like in a "real" shell, pressing arrow up and then enter will execute it.

Dockter commented 4 years ago

testing now....

Dockter commented 4 years ago

OK, issue confirmed.... working through this.

Dockter commented 4 years ago

Please try this: http://solder.almuramc.com/downloads/SGCraft-2.0.4-beta-5.jar

drzpk commented 4 years ago

Now gates are working fine, no interruptions whatsoever, thank you.

Dockter commented 4 years ago

Thanks goes to you for creating a way for me to perfectly test this. I had researched this previously but could never reproduce it. You're the reason this is fixed for everyone else.

Dockter commented 4 years ago

This issue is not fixed with 2.0.4.....

LemADEC commented 4 years ago

For the record, creating a Forge chunk loader ticker doesn't load the chunks immediately. As such, in your forceChunkRangeOnTicket method, you might want to do a World:getBlockState() in each chunks to force the loading so the rest of mod doesn't have to deal with that mess. Also, it appears the ticket is released and recreated when the gate state is changing. When releasing a ticket, forge may unload the chunks immediately under certain conditions & configurations, causing a whole of issues (memory leak, lag spike and state desynchronization). I suggest to keep existing ticket with its chunks instead of releasing and creating a new ticket.

Dockter commented 4 years ago

I think Zidane added an appropriate fix for this. I am including in the 2.0.5 build to be released tonight, give that a try please.