Fix the web build: a wasm trap on integer % 0, and buttons that never fired
The web export reached the main menu and went no further. Two separate bugs,
one hiding the other.
BUTTONS NEVER FIRED. A browser on a phone delivers the touch DOWN and never
the release. IconButton emits `pressed` only on release, deliberately, so
that dragging off cancels - so on the web it never emitted at all, on every
button in the game. fire_on_press (default OS.has_feature("web")) completes
the press there instead, and does not latch, since nothing is coming to
unlatch it. The cost is drag-off-to-cancel, which every other platform keeps.
Measured on the device rather than guessed: an on-screen probe reported
`touch=1 mouse=1 held=y` after one tap - one down, one emulated mouse down,
the button latched through ordinary GUI routing, then nothing.
THE ENGINE THEN TRAPPED. With the button working, pressing Play loaded and
built Main.tscn and the whole engine stopped mid-frame, page still alive.
An error overlay in a custom HTML shell finally showed why:
Uncaught RuntimeError: remainder by zero
An integer % 0. Wasm TRAPS on that; native builds silently tolerate it. So
the bug was equally present on Android and in all 100 tests, doing nothing
in both - which is why nothing runnable here could ever have caught it, and
why reasoning from frozen screenshots got nowhere for several rounds. Every
variable modulo is now guarded: the hangar grid's `i % columns`, planet
naming's `% names.size()`, and two in the map editor.
WHAT IS KEPT, AND WHY
- web_shell.html mirrors console errors onto the page, hidden until one
occurs. Godot's errors go to the browser console, which is unreachable on
a phone; this found in one shot what inference had failed to find all
evening. It costs nothing when there is nothing to report.
- MainMenu._start does load -> instantiate -> add_child by hand instead of
change_scene_to_file. That call does all three opaquely, so a failure is
indistinguishable from an unpressed button; split, each step reports.
- PlanetAtmosphereController defers the forced world populate out of the
frame that builds Main.tscn. It did not fix the hang - the trap did - but
25 chunks of asteroids and 49 of planets do not belong in the one frame
that already constructs 197 nodes, and nothing can paint until it ends.
Removed the direct-input-routing experiment and its test: it was written on
the theory that touches were not reaching Controls, which `held=y` later
disproved, and its set_input_as_handled() swallowed the very events the
probe was reading.
Full suite green at 100/100.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
00455dc6ba
commit
137e4e528d
13 changed files with 319 additions and 89 deletions
39
MainMenu.gd
39
MainMenu.gd
|
|
@ -94,36 +94,23 @@ func _on_play_pressed() -> void:
|
|||
_start("res://Main.tscn")
|
||||
|
||||
|
||||
# "Nothing happens when I press Play" covers three different faults, and they
|
||||
# are indistinguishable from the outside: the press never reaching this
|
||||
# handler, the scene change refusing, or the scene change reporting success
|
||||
# and not taking effect. Each writes a DIFFERENT line here, so one look at
|
||||
# the screen says which one it is.
|
||||
#
|
||||
# (nothing at all) - the press never got here
|
||||
# "Loading Main.tscn..." - it got here but the scene never finished
|
||||
# loading
|
||||
# "Could not load ..." - the load returned nothing
|
||||
# "Starting Main.tscn..." - loaded and the change reported OK, yet the
|
||||
# menu is somehow still up
|
||||
# "Could not start (...)" - the change refused, with the error number
|
||||
#
|
||||
# The scene is also loaded HERE rather than left to change_scene_to_file(),
|
||||
# which loads internally and reports a single error for both steps. Doing it
|
||||
# in two makes the failure specific, and takes whatever that call does about
|
||||
# background loading out of the picture - the web export is built without
|
||||
# thread support, so anything expecting a loader thread is worth removing
|
||||
# from the path rather than trusting.
|
||||
# Loaded, built and added by hand rather than through change_scene_to_file().
|
||||
# That call does all three in one opaque step, so when the web build hung
|
||||
# there was no way to tell which part failed. Split out, each step can say so
|
||||
# - and a scene change that fails otherwise leaves the menu up, which looks
|
||||
# exactly like an unpressed button.
|
||||
func _start(scene_path: String) -> void:
|
||||
status_label.text = "Loading %s..." % scene_path.get_file()
|
||||
var packed: PackedScene = load(scene_path)
|
||||
if packed == null:
|
||||
status_label.text = "Could not load %s" % scene_path.get_file()
|
||||
return
|
||||
status_label.text = "Starting %s..." % scene_path.get_file()
|
||||
var result: int = get_tree().change_scene_to_packed(packed)
|
||||
if result != OK:
|
||||
status_label.text = "Could not start (%s, error %d)" % [scene_path.get_file(), result]
|
||||
var scene: Node = packed.instantiate()
|
||||
if scene == null:
|
||||
status_label.text = "Could not build %s" % scene_path.get_file()
|
||||
return
|
||||
get_tree().root.add_child(scene)
|
||||
get_tree().current_scene = scene
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_dev_mode_pressed() -> void:
|
||||
|
|
@ -132,7 +119,7 @@ func _on_dev_mode_pressed() -> void:
|
|||
status_label.text = "Dev mode only runs from Godot"
|
||||
return
|
||||
GameState.start_dev_game()
|
||||
get_tree().change_scene_to_file("res://Main.tscn")
|
||||
_start("res://Main.tscn")
|
||||
|
||||
|
||||
func _on_editor_pressed() -> void:
|
||||
|
|
|
|||
Loading…
Reference in a new issue