A few days ago, I had a friend take a look at the code for simon’s job that didn’t work in release mode for some reason. I explained to her that you could click on the buttons in debug mode, but it wouldn’t work in release mode.

At first, she thought it might be related to the fact that the buttons were created with the CSG API, which was only designed for non-production use. However, changing the code to use a regular mesh didn’t fix the problem. After some investigation, she noticed the following:

func _ready() -> void:
	assert(OK == static_body.mouse_exited.connect(mouse_exited.emit))
	assert(OK == static_body.input_event.connect(_on_input_event))
 
	material = StandardMaterial3D.new()
	material.albedo_color = data.off
	material.emission = data.on
	material.emission_enabled = on
 
	material_override = material

She suggested that the assert call might be causing the issue. Indeed, the documentation warned against this at the end of its description:

@GDScript documentation

Warning: For performance reasons, the code inside assert() is only executed in debug builds or when running the project from the editor. Don’t include code that has side effects in an assert() call. Otherwise, the project will behave differently when exported in release mode.

Sure enough, removing the assert fixed the release build.