Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bgie opened this issue Feb 6, 2024 · 5 comments
Open

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

bgie opened this issue Feb 6, 2024 · 5 comments

Comments

@bgie
Copy link
Contributor

bgie commented Feb 6, 2024

Tested versions

  • Reproducible in v4.2.1.stable.official [b09f793], v4.2.stable.official [46dc277]
  • 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

@dalexeev
Copy link
Member

dalexeev commented Feb 6, 2024

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.

void Range::_set_value_no_signal(double p_val) {
if (!Math::is_finite(p_val)) {
return;
}

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 #75555 (comment), but that's a slightly different issue.

@Mickeon
Copy link
Contributor

Mickeon commented Feb 6, 2024

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.

@quirkylemon
Copy link
Contributor

quirkylemon commented Feb 8, 2024

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

@jitspoe
Copy link
Contributor

jitspoe commented Mar 11, 2024

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. 😅

@lonevox
Copy link

lonevox commented Sep 13, 2024

I just discovered that as well as being shown as 0, NAN variables can also show as -9223372036854775808. No idea why, and it was very confusing while debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants