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

Error reported using '_GenerateBlock' of 'C #' #664

Open
langyaWang22 opened this issue Jun 15, 2024 · 3 comments
Open

Error reported using '_GenerateBlock' of 'C #' #664

langyaWang22 opened this issue Jun 15, 2024 · 3 comments

Comments

@langyaWang22
Copy link

GDScript terrain is normal without any errors.
The terrain of "C #" is normal, but it keeps reporting errors.

C# code

using Godot;

public partial class MyVoxelGenerator : VoxelGeneratorScript
{
	public override void _GenerateBlock(VoxelBuffer outBuffer, Vector3I originInVoxels, int lod)
	{
		float oh = originInVoxels.Y;

		if (oh > 0) outBuffer.Fill(0, (int)VoxelBuffer.ChannelId.ChannelType);
		else outBuffer.Fill(1, (int)VoxelBuffer.ChannelId.ChannelType);
	}
}

GDScript code

extends VoxelGeneratorScript

func _generate_block(out_buffer: VoxelBuffer, origin_in_voxels: Vector3i, lod: int):
	var oh=origin_in_voxels.y
	if oh>0:
		out_buffer.fill(0,VoxelBuffer.CHANNEL_TYPE)
	else:
		out_buffer.fill(1,VoxelBuffer.CHANNEL_TYPE)

error message

E 0:00:01:0994   zylann::godot::CheckRefCountDoesNotChange::~CheckRefCountDoesNotChange: Holding a reference to the passed VoxelBuffer outside zylann::voxel::VoxelGeneratorScript::generate_block is not allowed (count before: 1, count after: 2)
  <C++ 源文件>      D:\a\godot_voxel\godot_voxel\modules\voxel\generators\../util/godot/check_ref_ownership.h:37 @ zylann::godot::CheckRefCountDoesNotChange::~CheckRefCountDoesNotChange()

godot

OS: Windows 10
Graphics card: AMD RX480
Godot version: 4.2.2
Module version: https://github.com/Zylann/godot_voxel/actions/runs/9524664823
Renderer used: Vulkan

@Zylann
Copy link
Owner

Zylann commented Jun 15, 2024

This is a known issue when you use C# to implement certain functions of the module. The garbage collector prevents from doing sanity checks over Godot RefCounted classes.
You may turn them off in your project settings: voxel/ownership_checks
https://voxel-tools.readthedocs.io/en/latest/getting_the_module/#ownership-checks

@langyaWang22
Copy link
Author

This is a known issue when you use C# to implement certain functions of the module. The garbage collector prevents from doing sanity checks over Godot RefCounted classes. You may turn them off in your project settings: voxel/ownership_checks https://voxel-tools.readthedocs.io/en/latest/getting_the_module/#ownership-checks

Thank you. Turning off the "voxel/ownership_checks" option will have an impact on other parts of the engine. Will it cause memory leaks? What should I pay attention to when using "C #". Can you also build the "godot.windows.template_release.x86_64.exe" file for the "Mono Builds" version in "Actions"?

@Zylann
Copy link
Owner

Zylann commented Jun 15, 2024

Turning off the "voxel/ownership_checks" option will have an impact on other parts of the engine

Not really.

Will it cause memory leaks?

No, it just turns off a warning that exists in case you make the mistake of keeping a reference to an object you were not supposed to. That's the case of VoxelBuffers that are passed to _generate_block custom implementations for example. But it's impossible to check that with C#.
Keeping the reference itself is not always the real problem, but it's more that the module makes no guarantees that this object will be safe to access outside of the specific call to _generate_block where it was passed.

What should I pay attention to when using "C #".

I don't know about other C# specific stuff off top of my head.

Can you also build the "godot.windows.template_release.x86_64.exe" file for the "Mono Builds" version in "Actions"?

I can't do that anymore: https://voxel-tools.readthedocs.io/en/latest/getting_the_module/#c-support

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

No branches or pull requests

2 participants