Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix block updates being ignored before initial build completes #2066

Closed

Conversation

embeddedt
Copy link
Contributor

If the following sequence of events takes place:

  • A chunk section is loaded and scheduled for an initial build (including creation of the world snapshot).
  • A block update, etc. attempts to schedule the section for re-rendering.
  • The initial build of the section completes.

it appears that the section is never actually built a second time with the new information. This causes problems with mods like AE2, which render disconnected cables initially and then connect them with a block update later. When Sodium is installed, and with a PC of the correct speed, it's possible to reliably reproduce behavior in which the cables remain visually disconnected (despite their hitbox changing) until F3+A is run manually. I was also able to make the reproduction more reliable by artificially adding a 2 second delay to chunk meshing tasks.

After several hours of tinkering and analysis, I believe I've found the culprit: the section manager explicitly avoids scheduling render updates for chunks which are not marked as built. This behavior seems incorrect; we need to process block updates as soon as the section has been added to our tracker and a snapshot of its data has been taken.

I've thus changed the logic to always schedule the block update even for non-null sections. On my system this appears to have fixed the issue, but I would like someone more familiar with the chunk tracker to validate that this does not violate some other invariant.

@embeddedt
Copy link
Contributor Author

Nevermind, this still doesn't seem to work 100% of the time... but I do think the logic error is real.

@embeddedt embeddedt marked this pull request as draft September 8, 2023 16:06
@embeddedt embeddedt force-pushed the fix/early-block-updates branch from 3c95f63 to e2bcb9e Compare September 24, 2023 23:23
@embeddedt
Copy link
Contributor Author

I've created a fix that actually works and updated this to the latest dev branch. For posterity, here is the test case I made to reproduce the issue:

  • Add https://modrinth.com/mod/forcecloseworldloadingscreen/version/2.1.1 to run/mods. (Needed to allow in-game GUI to display before chunks load)
  • Apply this diff to the current dev branch to add ability to stall any chunk updates in progress until the U key is pressed.
  • Launch the dev client and ensure always defer chunk updates is enabled.
  • Create a fresh superflat world in creative mode. (It MUST be a new world, reloading an existing world causes the issue to not happen for some reason.)
  • Wait for the in-game GUI to display. No chunks will be visible yet, as chunk updates are suppressed.
  • Open the creative inventory, get stone, look down, and place it in front of you (I placed it two blocks away from me, not sure if that's important).
  • Hold the U key until chunks start rendering.
  • Observe that the stone does not render.
  • Press F3+A.
  • Observe that the stone now renders.

With the change in this PR, the stone renders after pressing U, without requiring an extra refresh of the chunks.

@embeddedt embeddedt marked this pull request as ready for review September 24, 2023 23:25
@jellysquid3 jellysquid3 added the S-needs-testing Status: Needs testing label Dec 31, 2023
@embeddedt embeddedt deleted the fix/early-block-updates branch February 18, 2024 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-needs-testing Status: Needs testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants