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

MenuBar Global Menu queue_free() on PopupMenu causes crash during runtime #89066

Closed
mr-dreich opened this issue Mar 1, 2024 · 9 comments · Fixed by #89875
Closed

MenuBar Global Menu queue_free() on PopupMenu causes crash during runtime #89066

mr-dreich opened this issue Mar 1, 2024 · 9 comments · Fixed by #89875

Comments

@mr-dreich
Copy link

mr-dreich commented Mar 1, 2024

Tested versions

Happens only in 4.3.dev4, works fine in 4.3.dev3 and 4.2 stable.

System information

Godot v4.3.dev4 - macOS 14.3.0 - GLES3 (Compatibility) - Apple M1 - Apple M1 (8 Threads)

Issue description

This error does not happen when I run it in Windows.

I can open the project fine, and even run it. But after a while it will crash at runtime in each Renderer. Forward+ and Mobile produce an actual error in the Editor and Compatibility just crashes and I have to refer to the godot.log. The title is the error that Forward and Mobile produce, and here is the log from Compatibility:

Godot Engine v4.3.dev4.official.df78c0636 - https://godotengine.org
OpenGL API 4.1 Metal - 88 - Compatibility - Using Device: Apple - Apple M1

USER ERROR: FATAL: Index p_index = 2 is out of bounds (size() = 2).
   at: get (./core/templates/cowdata.h:205)

================================================================
handle_crash: Program crashed with signal 5
Engine version: Godot Engine v4.3.dev4.official (df78c0636d79c9545a283e0e2a926d623998cc27)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] 1   libsystem_platform.dylib            0x0000000187c11a24 _sigtramp + 56
[2] msdfgen::OverlappingContourCombiner<msdfgen::MultiAndTrueDistanceSelector>::distance() const
[3] ItemList::get_v_scroll_bar()
[4] Node::get_tree() const
[5] MultiplayerAPI::is_server()
[6] PlaceholderExtensionInstance::placeholder_class_recreate_instance(void*, void*)
[7] Node::atr_n(String, StringName const&, int, StringName) const
[8] Node::atr_n(String, StringName const&, int, StringName) const
[9] RendererCompositorRD::_create_current()
[10] void rx::mtl::GetMatrixUniformMetal<unsigned int>(unsigned int, unsigned int*, unsigned int const*, bool)
[11] RendererCompositorRD::_create_current()
[12] 12  dyld                                0x00000001878610e0 start + 2360
-- END OF BACKTRACE --
================================================================

4.3.dev3 works fine.

I thought this might have something to do with a shader so I removed it and it still crashes.

I only found this issue because I wanted to try some of the new global menu additions available in 4.3 that 4.2 does not have so this is a fork of my main from 4.2 which works 100% perfectly.

Steps to reproduce

Open the Editor, press Run, wait until crash.

Minimal reproduction project (MRP)

I will provide if necessary, but this is a long time project that I would prefer not be made public.

@clayjohn
Copy link
Member

clayjohn commented Mar 1, 2024

Unfortunately you are going to have to do a little bit of investigation before we can help you.

Ideally, you would compile the engine with debug symbols so that you can get a proper stack trace. The one you have posted just contains random information and doesn't help us identify the issue.

If you can't do that, you will have to trim down your project to be as small as possible while still recreating the error. We call that an MRP.

Without one of those we can't really do anything as we don't have enough information to go off of.

The title of your post seems unrelated to the content of the post. But the error message that is in the title usually occurs when you try to render an object using a ViewportTexture that points to the Viewport you are trying to render the object into. Doing so is not allowed, hence the error. If you are getting that error consistently, I would start by trying to find places where you might be doing that and fixing them.

@mr-dreich
Copy link
Author

@clayjohn I'll compile with symbols once I get home tonight and report back!

I do have a separate viewport that I eventually take the texture from, but I can't even get to the scene that happens in. If this isn't allowed, its strange it works fine in Windows and in dev3 works both MacOS and windows.

@clayjohn
Copy link
Member

clayjohn commented Mar 2, 2024

I do have a separate viewport that I eventually take the texture from, but I can't even get to the scene that happens in. If this isn't allowed, its strange it works fine in Windows and in dev3 works both MacOS and windows.

The error could be a red herring.

Let me know how your investigation goes!

@mr-dreich
Copy link
Author

mr-dreich commented Mar 2, 2024

@clayjohn Thanks for your advice through this! Here is the MacOS crash log generated after compiling from source with debug symbols enabled.

And a new godot.log:

Godot Engine v4.3.dev.custom_build - https://godotengine.org
OpenGL API 4.1 Metal - 88 - Compatibility - Using Device: Apple - Apple M1
USER ERROR: FATAL: Index p_index = 2 is out of bounds (size() = 2).
   at: get (./core/templates/cowdata.h:205)

================================================================
handle_crash: Program crashed with signal 5
Engine version: Godot Engine v4.3.dev.custom_build
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] 1   libsystem_platform.dylib            0x000000018872da24 _sigtramp + 56
[2] MenuBar::remove_child_notify(Node*) (.cold.1) (in godot.macos.editor.arm64) (menu_bar.cpp:612)
[3] MenuBar::remove_child_notify(Node*) (in godot.macos.editor.arm64) (cowdata.h:0)
[4] Node::remove_child(Node*) (in godot.macos.editor.arm64) (node.cpp:1539)
[5] Node::_notification(int) (in godot.macos.editor.arm64) (node.cpp:0)
[6] Object::_predelete() (in godot.macos.editor.arm64) (object.cpp:200)
[7] SceneTree::_flush_delete_queue() (in godot.macos.editor.arm64) (scene_tree.cpp:1359)
[8] SceneTree::process(double) (in godot.macos.editor.arm64) (scene_tree.cpp:520)
[9] Main::iteration() (in godot.macos.editor.arm64) (main.cpp:0)
[10] OS_MacOS::run() (in godot.macos.editor.arm64) (os_macos.mm:0)
[11] main (in godot.macos.editor.arm64) (godot_main_macos.mm:86)
[12] 12  dyld                                0x000000018837d0e0 start + 2360
-- END OF BACKTRACE --
================================================================

Luckily, this runs fine on dev3 and in its actual development in 4.2, If you need me to do any more testing please let me know. Again, I would be willing to let a trusted user look at my project if need be, but I have spent a lot of time and money on this and its currently for sale on itch.

@clayjohn
Copy link
Member

clayjohn commented Mar 2, 2024

Maybe #86322 is related. Its the only PR touching MenuBar and it seems targeted at macOS. Of course, the issue could be totally unrelated

CC @bruvzg

@mr-dreich
Copy link
Author

I'll disable or remove my MenuBar setup and report back tomorrow.

And I think this is an issue with MacOS, as it works fine on Windows and Linux (Tested it when I got home). So something between dev3 and dev4 for MacOS may be at fault.

@mr-dreich
Copy link
Author

I have removed the MenuBar and it works just fine. Seems the issue is related to what @clayjohn linked.

@mr-dreich
Copy link
Author

mr-dreich commented Mar 2, 2024

I have an update, after finding out that it was a problem with the MenuBar, I went through and started commenting out my MenuBar code and I found out what is causing the issue.

func _ready() -> void:
	if %MenuBar.is_native_menu():
		%MenuBackground.hide()
		%System.queue_free()  <--- This causes the crash

The part in the example is removing the popup menu that would be there if you were in Windows or another non-global menu OS, all the items get moved to the "_apple" global menu and then this is removed since its no longer needed.

I also tried calling %MenuBar.remove_child(%System) and that also crashes. Calling %System.hide() does nothing.

I have fixed it by calling %MenuBar.set_menu_hidden, this might be the preferred way of doing it rather than queue_free.

@mr-dreich mr-dreich changed the title Attempted to use the same texture in framebuffer attachment and a uniform this is not allowed when running project. MenuBar Global Menu queue_free() on PopupMenu causes crash during runtime Mar 5, 2024
@bruvzg bruvzg self-assigned this Mar 25, 2024
@bruvzg
Copy link
Member

bruvzg commented Mar 25, 2024

The part in the example is removing the popup menu that would be there if you were in Windows or another non-global menu OS, all the items get moved to the "_apple" global menu and then this is removed since its no longer needed.

I can't reproduce any issues with removing native menus from MenuBar, please provide minimal project. It's probably caused by some specific condition, and it's not entirely clear what exactly your project is doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Very Bad
Development

Successfully merging a pull request may close this issue.

5 participants