Adventure: save preview can show the menu instead of the world (driver-dependent)

Open Beginner friendly
#12,710 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
android, java
Domain
backend, game-dev

Research direction

Start by reading WorldSave.requestPreview() and its callers, especially GameStage.openMenu() and the quick save path. Check how GuiBase.getInterface().isGuiThread() and Gdx.app.postRunnable are used elsewhere, then run the relevant preview and save tests if available. Done means menu previews show the world across drivers and quick saves capture the current preview.

Written by the indexing model from the issue text.

Description

Adventure: save preview can show the menu instead of the world (driver-dependent)

Some players' save slots show a picture of the pause/save menu instead of the world map. It depends on the GPU driver; on an AMD RX 7900 XTX the preview is correct.

Cause: WorldSave.requestPreview() only captures at once on the first call of a session (firstCapture). Every later call is deferred with Gdx.app.postRunnable (from "fix preview spam", 647b5eac951).

  • GameStage.openMenu() calls requestPreview() and then Forge.switchScene(StartScene) in the same frame.
  • On LWJGL3, Lwjgl3Application.loop() runs posted runnables after Lwjgl3Window.update(). That update renders the frame (now the menu) and calls glfwSwapBuffers.
  • The deferred ScreenUtil.getThumbnailPreview() then runs glReadPixels on the back buffer after the swap. Its contents are undefined in OpenGL at that point:
    • drivers that flip buffers hand back an older frame (the world, correct by luck)
    • drivers that copy on swap hand back the frame just drawn (the menu)
  • Android runs posted runnables at the start of the next onDrawFrame, which is also after a swap.

Side effects of the same deferral:

  • Quick save (F5) posts the capture and then saves at once, so the quick save always stores the previous preview.
  • The blurred menu backdrop (Forge.lastPreview) comes from the same capture.

Suggested fix (about 5 lines): in requestPreview(), capture at once when the call is already on the GL thread (GuiBase.getInterface().isGuiThread()), which covers every current caller. Keep the 800 ms cooldown for the spam case, and keep postRunnable only as the fallback for calls from other threads. At input time the menu hasn't been drawn yet, so the back buffer holds a world frame on every driver. That is also why the first capture of a session already works.

Dominant language
Java
Stars
2.7k
Forks
1.1k
Avg merge
19h 28m
Merged PRs (30d)
316

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Card-Forge/forge

All issues in Card-Forge/forge

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.