godot icon indicating copy to clipboard operation
godot copied to clipboard

Float values NAN or INF are shown as 0 in the debugger and inspector

Open bgie opened this issue 1 year ago • 3 comments

Tested versions

  • Reproducible in v4.2.1.stable.official [b09f793f5], v4.2.stable.official [46dc27791]
  • NOT reproducible in v4.1.3.stable.official [f06b6836a]

System information

Godot v4.2.1.stable - Debian GNU/Linux trixie/sid trixie - Wayland - Vulkan (Forward+) - integrated Intel(R) Xe Graphics (TGL GT2) () - 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 Threads)

Issue description

Variables in the debugger window (stack variables) or properties in the inspector of type float will never show NAN or INF values correctly, they show up as 0 The tooltip in the script editor DOES show if a variable contains NAN or INF.

Rather nasty bug if you happen to be debugging a broken formula or something outputting an unwanted nan you are not aware of. The nan will profilerate but you will not see it at all. Nan has some special comparison properties also, which 0 does not, and this could really mess with your mind until you realize the debugger itself is bugged.

Steps to reproduce

Run the mrp until the breakpoint hits. Open the local variables in the debugger -> all values show as 0 Open the 'self' object in the inspector -> all property values show as 0

Minimal reproduction project (MRP)

mrp_no_nan_visible_in_debugger_and_inspector.zip

bgie avatar Feb 06 '24 07:02 bgie

I'm guessing this is because the inspector and debugger use SpinBox to display floats. SpinBox inherits Range, which doesn't allow you to set non-finite values. So we should probably either fix this in Range or use a custom control in the editor.

https://github.com/godotengine/godot/blob/d3352813ea44447bfbf135efdec23acc4d1d3f89/scene/gui/range.cpp#L96-L99

For infinities note that Range has min_value and max_value properties, but allow_lesser and allow_greater should always be enabled in the case of the debugger. For the inspector, see also https://github.com/godotengine/godot/issues/75555#issuecomment-1492996207, but that's a slightly different issue.

dalexeev avatar Feb 06 '24 09:02 dalexeev

It really feels like the simplest solution to this would be to add a property to SpinBox/Range to allow only finite values or not. only_finite, allow_infinite, allow_finite_only... or similar.

Mickeon avatar Feb 06 '24 12:02 Mickeon

Could y'all check out the pr draft? It works but idk if the solution is good. Also there some suggestions in the comments.

quirkylemon avatar Feb 08 '24 14:02 quirkylemon

Commented on the PR. Seems pretty straightforward other than that. Not sure if it's worth adding complexity to the code to allow setting nan/inf, but I'll take it to avoid debugging headaches like what I ran into the other day. 😅

jitspoe avatar Mar 11 '24 06:03 jitspoe