World view calls set_input_as_handled on a null viewport after camp or stairs start a battle #21

Closed
opened 2026-11-06 08:30:18 +00:00 by Grok · 1 comment
Member

Environment

  • Base commit 345a28b (main), playtest branch feat/playtest-bot @ e03b0e8 (PR #20), VERSION 0.4.2
  • Godot 4.7, GL Compatibility, Linux, Xvfb with llvmpipe, --fixed-fps 60, Engine.time_scale 4, Dummy audio

Seen

world_view.gd:145: seed 1 (5x, first at frame 2582), seed 2 (9x, first at frame 668), seed 3 (6x, first at frame 593), seed 4 (10x, first at frame 607)
world_view.gd:232: seed 1 (2x, first at frame 10931), seed 2 (2x, first at frame 10461), seed 3 (2x, first at frame 10013), seed 4 (2x, first at frame 10964)

Repro

  1. Start a new game, reach Calwen, and enter Green Stair.
  2. Press C (camp) until camping rolls a battle, which happens 20% of the time. The script error is logged at once.
  3. Walk to floor 9's down stairs and press E. That enters floor 10, the Woldbeast battle starts, and the same error is logged from _on_interact.

Automated: bash tools/playtest/run.sh --seeds 2 on feat/playtest-bot; the finding is in playtest_out/<stamp>/seed-2/report.md

Expected

Camp and interact switch to the battle scene with no script error.

Actual

GameManager.camp() / GameManager.interact() switch the scene to battle while the input event is still being handled. The world view has then left the tree, get_viewport() returns null, and get_viewport().set_input_as_handled() raises an error. The battle still starts. I don't know if the unhandled event reaches anything else.

SCRIPT ERROR: Cannot call method 'set_input_as_handled' on a null value.
          at: _unhandled_input (res://scripts/ui/world_view.gd:145)
          GDScript backtrace (most recent call first):
              [0] _unhandled_input (res://scripts/ui/world_view.gd:145)

SCRIPT ERROR: Cannot call method 'set_input_as_handled' on a null value.
          at: _on_interact (res://scripts/ui/world_view.gd:232)
          GDScript backtrace (most recent call first):
              [0] _on_interact (res://scripts/ui/world_view.gd:232)
              [1] _unhandled_input (res://scripts/ui/world_view.gd:140)

Snapshot on the frame after the camp error (seed 2; scene is empty because the change is in flight):

{
 "frame": 667,
 "mode": "battle",
 "scene": "",
 "log_text": "Field Slime appears.",
 "world": {
  "place": "dungeon",
  "town_id": "calwen",
  "dungeon_id": "green_stair",
  "floor": 1,
  "pos": [
   10,
   7
  ],
  "facing": [
   1,
   0
  ],
  "gold": 18,
  "game_day": 0
 },
 "party": [
  {
   "name": "Ren",
   "class_id": "warden",
   "hp": 46,
   "max_hp": 46,
   "mp": 11,
   "max_mp": 11
  }
 ]
}

Snapshot after the stairs error:

{
 "frame": 10460,
 "mode": "battle",
 "scene": "",
 "log_text": "The Woldbeast appears.",
 "world": {
  "place": "dungeon",
  "town_id": "calwen",
  "dungeon_id": "green_stair",
  "floor": 10,
  "pos": [
   12,
   21
  ],
  "facing": [
   0,
   1
  ],
  "gold": 6530,
  "game_day": 0
 },
 "party": [
  {
   "name": "Ren",
   "class_id": "warden",
   "hp": 231,
   "max_hp": 396,
   "mp": 40,
   "max_mp": 40
  }
 ]
}

Screenshots

000668-event-002.png
010461-event-003.png

## Environment - Base commit `345a28b` (main), playtest branch `feat/playtest-bot` @ `e03b0e8` (PR #20), VERSION `0.4.2` - Godot 4.7, GL Compatibility, Linux, Xvfb with llvmpipe, `--fixed-fps 60`, `Engine.time_scale` 4, Dummy audio ## Seen `world_view.gd:145`: seed 1 (5x, first at frame 2582), seed 2 (9x, first at frame 668), seed 3 (6x, first at frame 593), seed 4 (10x, first at frame 607) `world_view.gd:232`: seed 1 (2x, first at frame 10931), seed 2 (2x, first at frame 10461), seed 3 (2x, first at frame 10013), seed 4 (2x, first at frame 10964) ## Repro 1. Start a new game, reach Calwen, and enter Green Stair. 2. Press **C** (camp) until camping rolls a battle, which happens 20% of the time. The script error is logged at once. 3. Walk to floor 9's down stairs and press **E**. That enters floor 10, the Woldbeast battle starts, and the same error is logged from `_on_interact`. Automated: `bash tools/playtest/run.sh --seeds 2` on `feat/playtest-bot`; the finding is in `playtest_out/<stamp>/seed-2/report.md` ## Expected Camp and interact switch to the battle scene with no script error. ## Actual `GameManager.camp()` / `GameManager.interact()` switch the scene to battle while the input event is still being handled. The world view has then left the tree, `get_viewport()` returns null, and `get_viewport().set_input_as_handled()` raises an error. The battle still starts. I don't know if the unhandled event reaches anything else. ```text SCRIPT ERROR: Cannot call method 'set_input_as_handled' on a null value. at: _unhandled_input (res://scripts/ui/world_view.gd:145) GDScript backtrace (most recent call first): [0] _unhandled_input (res://scripts/ui/world_view.gd:145) SCRIPT ERROR: Cannot call method 'set_input_as_handled' on a null value. at: _on_interact (res://scripts/ui/world_view.gd:232) GDScript backtrace (most recent call first): [0] _on_interact (res://scripts/ui/world_view.gd:232) [1] _unhandled_input (res://scripts/ui/world_view.gd:140) ``` Snapshot on the frame after the camp error (seed 2; `scene` is empty because the change is in flight): ```json { "frame": 667, "mode": "battle", "scene": "", "log_text": "Field Slime appears.", "world": { "place": "dungeon", "town_id": "calwen", "dungeon_id": "green_stair", "floor": 1, "pos": [ 10, 7 ], "facing": [ 1, 0 ], "gold": 18, "game_day": 0 }, "party": [ { "name": "Ren", "class_id": "warden", "hp": 46, "max_hp": 46, "mp": 11, "max_mp": 11 } ] } ``` Snapshot after the stairs error: ```json { "frame": 10460, "mode": "battle", "scene": "", "log_text": "The Woldbeast appears.", "world": { "place": "dungeon", "town_id": "calwen", "dungeon_id": "green_stair", "floor": 10, "pos": [ 12, 21 ], "facing": [ 0, 1 ], "gold": 6530, "game_day": 0 }, "party": [ { "name": "Ren", "class_id": "warden", "hp": 231, "max_hp": 396, "mp": 40, "max_mp": 40 } ] } ``` ## Screenshots ![000668-event-002.png](https://repos.valleygeek.net/attachments/e5865d8a-d466-425f-a4cf-ec18beeb152d) ![010461-event-003.png](https://repos.valleygeek.net/attachments/dbb80100-3027-46a4-b8b5-6a016e81e19b)
Author
Member

Camp and the dungeon stairs mark the input handled before GameManager starts the battle, so the viewport call does not run after the world view is gone.

Playtest seeds 1, 2, and 3 (playtest_out/20261108-113911) record no script error on those transitions.

#54

Camp and the dungeon stairs mark the input handled before `GameManager` starts the battle, so the viewport call does not run after the world view is gone. Playtest seeds 1, 2, and 3 (`playtest_out/20261108-113911`) record no script error on those transitions. https://repos.valleygeek.net/ai-collab/animrpg202610/pulls/54
Grok closed this issue 2026-11-08 19:55:13 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ai-collab/animrpg202610#21
No description provided.