Skip to content

Fix active render target restoration during screenshot readback - #59

Merged
Winlifes merged 1 commit into
FunplayAI:mainfrom
MoLing14725:codex/fix-screenshot-active-render-target
Oct 8, 2026
Merged

Winlifes merged 1 commit into
FunplayAI:mainfrom
MoLing14725:codex/fix-screenshot-active-render-target

Conversation

@MoLing14725

Copy link
Copy Markdown
Contributor

What changed

ReadTextureToTexture2D saved RenderTexture.active after Graphics.Blit had already bound the temporary readback target. Its finally block therefore restored that temporary target and released it while it was still active, producing Releasing render texture that is set to be RenderTexture.active! and losing the caller's previous target.

Capture the caller's active target before allocation or rendering. The existing cleanup now restores that target before releasing the temporary texture. Add regression cases for both a null target and an existing bound target, checking target restoration, red pixel readback, and absence of the release warning. Update CHANGELOG.md.

Validation

  • Tested in an existing URP project on Unity 6000.3.12f1, macOS, Apple M1 Pro / Metal. This was not a clean project or a Unity 2022.3 test run.
  • ScreenshotFunctionsTests: 25 passed, 0 failed, 0 skipped, including both new regression cases and existing orientation tests.
  • Independent owned-texture probe: before the fix, both cases emitted the active-target release warning and the bound target was not restored; after the fix, both targets were restored, pixels remained correct, and neither case emitted warnings.
  • Script compilation/domain reload completed without compilation errors. Funplay > MCP Server opened successfully and the running server handled subsequent read-only scene queries.
  • An actual Edit Mode capture_game_view call returned a 1653 × 930 PNG without new active-target release or memoryless depth warnings. The idle Game View was black; this is a tool smoke check, not Play Mode visual validation.

Scope

This fixes the independently reproduced active-target restoration/release bug. Memoryless depth load/store warnings were observed separately during diagnosis, but their causal relationship to this bug has not been established; this PR does not claim to resolve all such warnings. No capture API, setup, update, or configuration behavior changes.

Checklist

  • I tested the package in a clean Unity 2022.3+ project (existing Unity 6000.3.12f1 project used instead, as described above)
  • I verified Funplay > MCP Server opens and starts correctly
  • If I changed setup, update, or config flows, I verified the affected flow end-to-end (not applicable)
  • I updated docs for any user-facing behavior changes (CHANGELOG.md; no API or UI changes)
  • I did not commit local junk such as .idea/ or .DS_Store
  • I updated CHANGELOG.md when the change affects users

@Winlifes

Winlifes commented Oct 8, 2026

Copy link
Copy Markdown
Member

Maintainer validation completed against PR head 43929d60b76375ea7663f7758d0ea42ae2c019dc in the dedicated FunplayMcp test project:

  • Unity 2022.3.62f3c1 on macOS, graphics-enabled Editor (not -nographics).
  • ScreenshotFunctionsTests: 25 passed, 0 failed, 0 skipped, including both new null/bound-target restoration cases, correct red-pixel readback and absence of the active-target release warning.
  • The PR's GitHub CI run was approved and completed successfully.

The source change preserves the caller's active render target before Graphics.Blit changes it, with the existing finally-block cleanup restoring it before release. This is targeted EditMode validation; it does not claim a full-suite run or Play Mode visual testing.

@Winlifes
Winlifes merged commit bf1973d into FunplayAI:main Oct 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants