appsinacup/godot-rapier-physics

Condition "monitored_objects.has(handle_pair_hash)" is true

garf opened this issue ยท 19 comments

garf commented

Describe the bug
Engine shows these errors in debug console

E 0:00:18:0202   RapierArea2D::on_body_enter: Condition "monitored_objects.has(handle_pair_hash)" is true.
  <C++ Source>   src\bodies\rapier_area_2d.cpp:50 @ RapierArea2D::on_body_enter()

To Reproduce
Steps to reproduce the behavior:
Just use it to detect collisions

Expected behavior
No errors generated

Screenshots
image

Environment (please complete the following information):

  • OS: Windows
  • Version: 0.6.20 (Faster version with SIMD)
  • Godot Version: v4.3.dev6.mono.official [89850d553]

Can you upload a project, it's not immediately obvious what Just use it to detect collisions means. Or add more information at To reproduce field. Thanks

Looks like it's related to areas somehow?

garf commented

@Ughuuu I added you as a collaborator to the repo. To reproduce you just have to start the game and when the character starts to hit the enemies or collide with them, you will see errors in debug panel.
Thank you!

Tested your project, it seems like it would be better to disable the run on separate thread. Not 100% tested with the separate thread thingy, but at least on my machine it generates crash at times.
As for the error, seems like it's just an error generated by the fact that the object is removed when the area event happens. I think I can safely remove that error warning.

garf commented

@Ughuuu I couldn't find time yet to make a simpler project. Thank you so much for testing it with an actual game! <3

garf commented

BTW, I tried to disable a separate thread, and it still crashes from time to time. Have no idea why. Also logs say nothing. Will check further. Thank you again for testing!

Hm, I wonder if I can reproduce somehow. About how often would you say the crash happens, or after how long time?

garf commented

Frequently. Usually after a minute or two of playing.

My guess is it's because of the asserts most likely. There are a lot of asserts in the rapier wrapper.
After the rewrite of the code to rust, I will correctly handle these cases and not do asserts any more.
As a workaround, what you can do for now is change the .gdextension file to change in the editor to use the release version of the addon.
Eg. if you are on mac you would change from this:

macos.debug = "res://addons/godot-rapier2d/bin/libphysics_server_rapier2d.macos.template_debug.framework"
macos.release = "res://addons/godot-rapier2d/bin/libphysics_server_rapier2d.macos.template_release.framework"

to this:

macos.debug = "res://addons/godot-rapier2d/bin/libphysics_server_rapier2d.macos.template_release.framework"
macos.release = "res://addons/godot-rapier2d/bin/libphysics_server_rapier2d.macos.template_release.framework"

Or even easier, replace all template_debug in the extension with template_release.
The file name in question is godot-rapier2d.gdextension.

garf commented

Thank you! I will try to do it.

Has the fix reached the SIMD package on the asset library yet? I'm still facing this

It's possible after the rewrite the issue reappeared. The addon was rewritten from cpp to rust.

However if the issue is still present open a new issue and put a reproducible example so i can debug it. Upload it as a zip rather than a private repo or anything.

Thanks

Actually on the asset store it might not be latest version, you can try the latest from github first maybe also.

I think I'm having the same issue as the original poster here though. In the commit just before migrating the body handling to rust, the assertion is replaced by returning early:
6041474

But then in the rust rewrite, this is made back into throwing an error:

godot_error!("Body is already being monitored");

No release was made in between changing the cpp version to remove the assertion, and replacing everything with rust, so there is no github release in which this doesn't happen. I tried the latest (prerelease) version where everything is rust and the linked error was being thrown. I'm currently trying to compile a version after the change was made to the cpp source to see if it will stop (will update this comment when I've done so). I don't have a rust compiler and found the physics to be more stable in the cpp version anyway. Removing the linked error in the rust version would probably also "fix" it.

As for a repro project, I annoyingly can't figure out what triggers it. Seems to only be happening in my full game, which I'd rather not share. I appreciate this isn't very helpful, so sorry about that :(

Best of luck

Right, i see, so removing the error is the fix probably then.

I'm currently trying to compile a version after the change was made to the cpp source

I couldn't get it to compile properly, but oh well. Errors are annoying but I can live with them for now :)

so removing the error is the fix probably then.

I would guess, seemed to be the "fix" marked for this issue originally

You are trying to compile from C++ code or Rust code? The Rust one you get compile errors? Are you following the steps for build form the documentation?

Ah, right, there are some linking errors on main i am trying to fix. Not sure why they appear. They are only on windows.

Build should be fixed now.