Skip to content

Save preview images are always black — framebuffer empty at capture time #5321

@agent-refr

Description

@agent-refr

AI-assisted issue. Filed by agent driven by @Cervator via GDD.

Context

During the DI migration review (#5299), the black save preview screenshot was identified as a known issue. Investigation found two contributing causes — one now fixed, one remaining.

Problem / Current State

Save game preview images are always black. Two issues were involved:

  1. ScreenGrabber not visible from CoreRegistry (fixed): ScreenGrabber was registered only in WorldRendererImpl's private child context. ReadWriteStorageManager.saveGamePreviewImage() resolves it via CoreRegistry.get(ScreenGrabber.class), which returned null. Fixed by propagating the instance to CoreRegistry in WorldRendererImpl.init().

  2. Framebuffer empty at capture time (remaining): The save and screenshot capture happen during StateIngame.dispose() (line 133), after the game's render loop has stopped updating the framebuffer. ScreenGrabber.saveScreenshot() reads sceneFinalFbo.getColorBufferRawData() which returns stale or cleared data. The screenshot file IS written to disk but contains a black image.

Acceptance Criteria

  • Save preview images show an actual in-game screenshot when loading a saved game

Technical Notes

  • StateIngame.dispose() calls storageManager.waitForCompletionOfPreviousSaveAndStartSaving() at line 133
  • startSaving() calls saveGamePreviewImage() at line 432
  • ScreenGrabber.saveScreenshot() reads the FBO at line 101 — the buffer is empty because no render pass has occurred since the game loop stopped
  • The world renderer is still alive at save time (disposed at line 146-149, after save) but is no longer actively rendering
  • Likely fix: trigger a final render pass before the dispose/save sequence, or capture the screenshot earlier (e.g., on the last frame before exit)
  • This issue predates the DI migration — listed as a known issue in feat!: gestalt-di migration #5299

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugIssues reporting and PRs fixing problems

    Type

    No type

    Projects

    Status

    No status

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions