mojira.dev
MC-162253

Lag spike when crossing certain chunk borders

The bug

I've encountered some sort of lag spike which I narrowed down to be a floating structure. This structure can be a single block.

The lag spike seems to occur when I'm moving into the spawn chunks while an elevated block is placed on the opposite side of the spawn chunks. It occurs when the block is at Y96 or higher.

To replicate what I did on a 1.14.4 vanilla server:

  • Create a default world with seed: -4952361208952771886

  • Place a block at x 143 y 63 z -371 and another block at x 144 y 63 z -371. This is the location to test for the lag.

  • Place a block at x 307 y 96 z -302. This will be the block to create the lag.

  • Set the spawn point to x 227 y 66 z -376

  • Walk back and forth over the two blocks you placed earlier.

  • If you see a stutter, feel free to remove the block at x 307 y 96 z -302 and check again. Lag will be gone.

I cannot attach the video as the file size is slightly too large but you may watch it here: https://youtu.be/jmtq3jcXujo

I should note that it is not specific to my PC. It occurs on other clients on other devices.

Render distance will affect where the lagspike occurs in vanilla singleplayer, but is relative to the view-distance on servers. I believe it's distance + 1 in chunks, or there abouts.

Code analysis

Code analysis and further explanation by @unknown can be found in this comment. There also exists a Fabric mod that fixes this issue: comment.

Linked issues

MC-167553 Lag Spike if you go trough specific chunks in Amplified Resolved MC-168419 Massive frame drops caused by light update while crossing certain chunks Resolved MC-168904 FPS is drops unless i hold down a mouse button Resolved MC-168956 Moving across specific chunk borders causes a lag spike Resolved MC-169580 Lag spikes, between chunks Resolved

Attachments

Comments 158

I have found another lag spot caused by the same floating block which prompted some further investigation.

I have discovered that if you place a block at Y96 or higher within the inner spawn chunks and then travel 11 chunks away (not including the chunk the block is in) and then cross between the 11th and 10th chunk, there will be a brief lag spike. This lag spike is worsened depending on how many blocks are in the sky it seems.

I haven't tested placing the block in the outer spawn chunks. I can say that my creeper farm in my real world does cause lag which is in the outer spawn chunks but I haven't counted how many chunks away that is. I think it's 13 chunks away as opposed to 11 like with a block within the inner spawn chunks but I haven't checked to be sure. 

It does not occur if the block is placed outside of the spawn chunks.

I'm not sure why it's Y96 as the starting point - perhaps it varies on biome I'm not sure.

[Mod] violine1101

Hmm, I can reproduce this in singleplayer with render distance 12, no matter whether the block is placed or not. That chunk border seems to cause lag in general. I tested it in 19w39a as well, so it can't be MC-158672.

I believe this might have something to do with light calculations across chunk borders, but I'm not too sure.

That may be a different issue to be honest as the lag caused by a block above Y96 will happen when render distance is set to 2 (meaning, the block isn't even close to being rendered in), and under the exact same conditions in single player it doesn't lag. In your case, it may be lighting but for me it seems to be something else.

The chunk borders are optional. The lag occurs when they aren't visible. I enabled them for the video just so we are aware that the lag occurs when crossing the chunk. 

Can confirm that the lag occurs in vanilla 19w39a but one chunk further away than in realms (this matches up with paper, spigot and other non-vanilla servers) which is odd but no problem. For me using the server snapshot I had to move between the 12 and 11th chunk away from the placed block as opposed to 11 and 10 like on realms. Again, lag still persists without the chunk borders visible and no longer lags when the block is removed.

Still a problem in 1.15 Pre 1

148 more comments

@JomaZ
I had this problem plaguing me for several years but it was fixed for 1.20 just as this ticket states. You might be having a similar but separate issue. Good luck with it!

@Naga

No, I literally have the same bug, I swear to god, I can send a video if you want.

@Naga
It was very strange about 1 year ago I had the perfect game and from one moment to the next this bug started to occur, I still can't find a solution.

[MOD] Greymagic27

As this is marked as fixed please create a new bug report if you're still experiencing this issue and reference this report.

I already create a new report but no one respond /:

Tencryn

gegy

Confirmed

Important

Performance

1.14.4, 19w39a, 19w40a, 19w41a, 1.15 Pre-release 1, ..., 1.19, 1.19.2, 1.19.3, 23w07a, 1.19.4

23w16a

Retrieved