BuildCraft|Core

BuildCraft|Core

7M Downloads

Crash on loading a chunk that contains heat exchangers

fjelliott opened this issue ยท 14 comments

commented

BuildCraft version: 7.99.15
Forge version: 14.23.2.2613
Link to crash report or log: https://pastebin.com/D5tgBPxY
Singleplayer or multiplayer: Single Player
Steps to reproduce: Load certain chunks
Additional information:

A pretty annoying bug. Nearly every time I load into my game this crash occurs. It doesn't occur 100% of the time so if I just keep trying to start my game eventually it will load and I can play.

Most often the crash occurs when I load my world. The crash happens on what seems to be the first tick. It can also occur when I travel a distance from my base and return. Once I get within a certain distance of my base after being away, the game crashes, and will continue to crash when I restart the game. Decreasing my render distance can temporarily alleviate this problem if the crash occurs when I'm returning to my base from far away. This lets me get closer to my base before the game crashes. Then I increase my render distance before I reload the world and that seems to help the game load (but not always).

While it occurs most frequently when I load my world, it can also occur in-game as well. In general, it seems to occur when certain chunks get unloaded and then reloaded. The chunks in question are around my base, which is where my bed is along with my workshop. The workshop contains a number of IC2 machines connected to a complicated item sorting system designed with buildcraft pipes. The sorting system itself is fed with a buildcraft quarry, which is powered by 6 iron engines fueled by a buildcraft oil refinery (which means several distillers, heat exchangers, and tanks all connected with buildcraft fluid pipes).

I'm reasonably confident the crash is being caused by buildcraft because I took a look at the crash logs from the numerous times the game crashed (the crash-reports folder has 50 reports in it, and they all appear to caused by the same thing). The crash seems to reference one of the heat exchangers in my oil refinery setup. The oil refinery is outdoors and away from my workshop, so there aren't blocks from other mods anywhere close to it. I built my base on the same hill where I spawned when I first started this world, so it's likely the refinery is within a spawn chunk.

BEGIN SPECULATION

I am a programmer and so naturally I investigated the problem myself. Please note I know nothing about the buildcraft or minecraft code bases, so take what I say with a grain of salt.

From my look at the crash logs, the bug always references a heat exchanger, but not always the same heat exchanger. Since the crash never occurs as long as I stay near to the base (and the oil refinery), I assume that the problem occurs on the first tick of when the chunk the oil refinery is in is loaded. The crash occurs on line 167, where it calls a method of an object it just retrieved by calling getFacing(). The getFacing() function returns null when the block's state object is null. I went further up the call chain as well. It's a series of other functions that ask another function for the block's state object, and then checks an assumption of the properties of the state and returns null if that assumption check fails.

My instincts tell me the bug is a race condition for the block's internal state object, which might not be set yet given it's the first tick the block was loaded, or is changed by somewhere else in the tick in such a manner as to cause one of those functions to return null.

In either case, what I would do is change findAdjacentExchangers() to return an empty Deque if thisFacing is null. If the assumptions the function is working under are faulty, it shouldn't act and instead wait for the next tick. I assume returning an empty array is a way to gracefully fail, as anything that calls that function will just assume that there are no adjacent heat exchangers for that tick. This, of course, assumes that whatever was causing thisFacing to be null corrects itself by the next tick, which should be the case for a race condition.

Of course, I don't know anything about the minecraft or buildcraft code bases besides my brief glimpse. If I'm totally wrong please don't mind my meaningless ramblings.

END SPECULATION

commented

After doing a little more poking, it seems that disabling OptiFine might have solved the problem. Not sure how that works, since the crash occurred in buildcraft code.

commented

According to the crash report the block is air, rather than a heat exchanger, which is a bit odd. Fortunately it doesn't really matter, as your speculation seems to be about right, and checking to see if it is null is a trivial fix on our end, even if optifine has something todo with it.

commented

Glad I could help!

commented

BTW: When will be buildcraft's next release? And will a fix for this bug be in it? My game is ultra-laggy without OptiFine (less than 2 FPS). It's pretty painful to go without it.

commented

Is it possible that #3616 is affecting you? (Specifically if using this resource pack fixes the FPS issues https://mod-buildcraft.com/releases/Misc/packs/buildcraft_fluid_still.zip)

commented

And the release probably won't be too far away, as it's mostly bugfixes.

commented

Actually, loading that resource pack causes the game to crash again (same crash log as I posted earlier). I should mention that OptiFine is still disabled. However, my lag is caused by the tick. My tick is like 85% according to that pie chart. Given that I have a custom built gaming computer, I don't think rendering problems are an issue for me.

commented

Hmm, ok. I guess there's little todo then until 7.99.16 is actually released. Can you look around to see what part of "tick" is actually taking longest? It seems odd that ticking is taking up such a huge amount...

commented

How would I even investigate what's consuming the most time in a tick? I'd certainly love to know what's giving me such shitty FPS, but once again I have next to no experience debugging videogames.

commented

When the debug pie is open press any of the number keys to go into the most expensive element, or 0 to go up. It should display the expensive element at the top (starting with 1)

This isn't a generic videogame debugger unfortunately:(

commented

NVMD I found a tick profiler mod made by MinimallyCorrect. Oddly enough it says that I have 20 ticks per second. It claims that by far most of the time is spent on the client thread. In any case I tried enabling that disable animated fluids resource pack again by enabling it while my game was running, and my FPS went up significantly. However, it doesn't seem to have affected the fluids in any way. My fluid pipes still have moving liquid inside of them. Nevertheless the FPS, while not smooth, is now playable. Whatever that resource pack does, it helped a lot. So I guess I'm suffering from #3616.

commented

On second take my FPS is still pretty bad. Give me a minute to work that debug pie chart.

commented

Tick 75% -> textures 90% -> unspecified 89%

Well that was rather unhelpful... With and without the resource pack those numbers stay the same.

commented

optifine has some settings related to animated, textures, you can try using those, if they help there probably also is another mod with lots of animated textures that are causing issues