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

Godot 3.4.x breaks all prior versions of Area2D because it changes body from int to RID #56410

Open
chucklepie opened this issue Jan 1, 2022 · 13 comments

Comments

@chucklepie
Copy link

chucklepie commented Jan 1, 2022

Godot version

3.4.2

System information

Linux

Issue description

In all version of Godot the signature for body entered is this:

func _x(_body_id: int, _body: Node, _body_shape: int, local_shape: int) -> void:

In 3.4 it has changed to using RID

func _x(_body_id: RID, _body: Node, _body_shape: int, local_shape: int) -> void:

i.e. now using RID. This then fails to trigger any signals because the parameters do not match, so all signals fail to trigger.

I suspect everywhere that also changes to RID will also break too.

Observe the video.

RID.problem2.mp4

If this is known/documented, where is it and is there a list of all places where this/similar change will also break?

Steps to reproduce

  1. Use a body entered area2d from 3.3
  2. Debug and the method never calls
  3. Change to RID manually and it works

Minimal reproduction project

No response

@Calinou
Copy link
Member

Calinou commented Jan 1, 2022

Now that the compatibility breakage has been done, I'm not sure if it's worth reverting this change and breaking people's projects a second time in a short timespan.

@kleonc
Copy link
Member

kleonc commented Jan 2, 2022

For reference it was changed in #42742 (#42743 for 3.x >= 3.4).

@chucklepie
Copy link
Author

chucklepie commented Jan 2, 2022

Got to be honest, the most fundamental principle of public API is don't change the interface, but if you do, make sure it's telegraphed loudly ;-)

Anyway, so it only affects Area2D, RigidBody and only area_shape_entered, area_shape_exited, body_shape_entered and body_shape_exited methods? My project has hundreds of scenes and signals, I expect it'll affect a lot of projects :(

Two things really then:

  1. It would be nice for the changelogs/public notices to have a section (even if it says 'none') at the top to state what, if any, breaking changes are being made? This would give confidence to people upgrading.

  2. I guess this shows one of the failing points of a lack of GDScript lint tool, or perhaps a suggestion could be that it should be possible for IDE created code to detect errors, i.e. given the signals are defined in the tscn file and the IDE highlights signals it should be fairly easy to show project warnings for this and similar errors, e.g. in this case signal is defined but the associated script has not defined it. At the minute it's happy as Larry showing the nice green connection symbol in the gutter while secretly laughing at you because it's fooled you into thinking it's connected...

  3. Bonus! don't be helpful in signal generation by putting in data type hints, leave them as generic ;-)

@Calinou
Copy link
Member

Calinou commented Jan 2, 2022

  1. It would be nice for the changelogs/public notices to have a section (even if it says 'none') at the top to state what, if any, breaking changes are being made? This would give confidence to people upgrading.

While this sounds like a good idea on paper, my issue with this is that it prevents all changes from being nicely contained within a section (unless I repeat compatibility-breaking changes at the top, which can be confusing).

  1. Bonus! don't be helpful in signal generation by putting in data type hints, leave them as generic ;-)

By default, type hints are not added when you connect a function in the editor. They are added because you enabled the editor setting that inserts type hints in autocompletion.

@chucklepie
Copy link
Author

chucklepie commented Jan 2, 2022 via email

@Giwayume
Copy link
Contributor

Giwayume commented Jan 2, 2022

I noticed, I thought it was an intentional change for 3.4.

@akien-mga
Copy link
Member

akien-mga commented Jan 3, 2022

It's not a bug and was indeed changed intentionally.

It's listed in the changelog for 3.4 in the Changed section, which includes things which changed and might indeed impact compatibility for existing projects. That's the section to look at if you're concerned about potential changes that might affect your project:

https://github.com/godotengine/godot/blob/3.4-stable/CHANGELOG.md#physics-1

Now it's indeed annoying that the type hints don't actually work here, as there should be one of two things in theory:

If it doesn't do that, it's a bug with GDScript, which might be fixed in 4.0 (type hints in 3.x are very barebones).

@chucklepie
Copy link
Author

@akien-mga, It took a while but I found the entry stating the change you mentioned. Wasn't very clear it would break code, which was more my point about making breaking changes more prominent.

btw, you're right:
E 0:00:30.310 emit_signal: Error calling method from signal 'body_shape_entered': 'Camera2D(Flip_CameraFlip.gd)::_on_RoomNavigation_body_shape_entered': Cannot convert argument 1 from RID to int..
<C++ Source> core/object.cpp:1236 @ emit_signal()

I just never checked there, probably mainly because a combination of never noticing the error section and I'm that used to the errors all being benign as 99.9% of the time caused simply by a node being deleted then called in a yield. I think from my perspective I'd just like a lot more up-front static checking done, which I know is more difficult given the language.

btw, digressing one thing that always annoys me (another 4 fix I hope) is unless you have a scene file open and selected, when you have a script open you lose all '.' context help and all signal information like signal hints is gone. Would also be nice when inside a script to open the scene (or view list of scenes) that import this script to counter this problem. But I'm digressing :)

@akien-mga
Copy link
Member

I'm that used to the errors all being benign as 99.9% of the time caused simply by a node being deleted then called in a yield.

FYI, that's definitely not a benign error, this would crash on release. Errors are usually things that you really need to fix before shipping a game. Godot does its best to recover from errors on debug so that you can fix them, but it won't be forgiving in an optimized release build.

@Xrayez
Copy link
Contributor

Xrayez commented Jan 3, 2022

3. Bonus! don't be helpful in signal generation by putting in data type hints, leave them as generic ;-)

Yeah, I know that the usage of GDScript type hints is heavily advertised (likely prolifirated by GDQuest tutorials), but you don't have to provide type hints for everything. I've previously stumbled upon similar errors in the past when updating Godot. By doing so, you can improve cross-compatibility.

My personal recommendation is to use type hints only when there's a definite ambiguity that must be resolved. Other than that, there's no benefit as of now. Using type hints won't improve performance either in 3.x (maybe in 4.0), otherwise I'd also recommend using type hints for performance critical parts of code after profiling it.

@Giwayume
Copy link
Contributor

Giwayume commented Jan 3, 2022

Adding type hints in the function signature helps with autocompletion, though.

@Xrayez
Copy link
Contributor

Xrayez commented Jan 3, 2022

Adding type hints in the function signature helps with autocompletion, though.

Yeah, but this may lead to situations where you find yourself using type hints for more than you actually need. I usually refer to documentation instead. Of course this is a personal preference, 🙂

I just wanted to convey that one should not blindlessly use type hints unless one really needs it. Typed GDScript is optional and should stay that way.

@chucklepie
Copy link
Author

FYI, that's definitely not a benign error

@akien-mga I'm sure you know a lot more than me ;-), and maybe I wasn't explicit enough, but I'm just referring to the well known messages from Godot when a node is deleted but the code tries to resume back from yield. Godot just ignores this whether release or debug mode. It can't do anything else really because you can't code around a return to a yielded bit of code...

@lawnjelly lawnjelly modified the milestones: 3.5, 3.x Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants