Skip to content

Add missing GetVirtualScreenSize stub to HeadlessWrapper#1789

Open
YangLeoZhao wants to merge 1 commit intoPathOfBuildingCommunity:devfrom
YangLeoZhao:fix/headless-getvirtualscreensize
Open

Add missing GetVirtualScreenSize stub to HeadlessWrapper#1789
YangLeoZhao wants to merge 1 commit intoPathOfBuildingCommunity:devfrom
YangLeoZhao:fix/headless-getvirtualscreensize

Conversation

@YangLeoZhao
Copy link
Copy Markdown

Summary

  • HeadlessWrapper.lua stubs GetScreenSize() and GetScreenScale(), but not GetVirtualScreenSize()
  • Launch.lua calls GetVirtualScreenSize() in DrawPopup() (line 390) and during restart (line 125)
  • When running headless and an error triggers DrawPopup on the first OnFrame, this causes a crash because GetVirtualScreenSize is not yet defined — Modules/Common.lua (where it is normally defined, line 1044) hasn't loaded yet at that point
  • The stub delegates to GetScreenSize() since GetScreenScale() returns 1 (no scaling) in headless mode, matching what the real implementation in Common.lua would produce

Reproduction

  1. Run POB2 headless via HeadlessWrapper.lua
  2. Trigger any code path that calls DrawPopup before Modules/Common.lua is loaded (e.g., an initialization error on the first OnFrame)
  3. Crash: attempt to call global 'GetVirtualScreenSize' (a nil value)

Test plan

  • Verified the fix resolves the crash when running headless
  • Confirmed the return value matches Common.lua's implementation (since GetScreenScale() returns 1, GetVirtualScreenSize() == GetScreenSize())

Launch.lua calls GetVirtualScreenSize() in DrawPopup() and during
restart, but HeadlessWrapper.lua only stubs GetScreenSize() and
GetScreenScale(). When running headless and an error triggers
DrawPopup on the first OnFrame, this causes a crash because
GetVirtualScreenSize is not yet defined (Modules/Common.lua where
it is normally defined hasn't loaded yet).

The stub delegates to GetScreenSize() since GetScreenScale() returns
1 (no scaling) in headless mode, matching what the real implementation
in Common.lua would produce.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant