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

VideoStreamPlayer causes random crashes on a Windows export without "Export with Debug" #78788

Closed
Freecreativename opened this issue Jun 28, 2023 · 9 comments · Fixed by #78987 or #78988

Comments

@Freecreativename
Copy link

Godot version

4.1.beta3, 4.0.3.stable

System information

Godot v4.1.beta3 - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3070 Ti (NVIDIA; 31.0.15.3598) - Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz (6 Threads)

Issue description

The game crashes on a Windows export without "Export with Debug" when I use VideoStreamPlayer node as a background in my scene.

I have created 2 simple scenes with VideoStreamPlayer and a button in each to switch between them. When I run the game in the editor, it works fine, when I export it with debug it works fine. As soon as I untick "Export with Debug" the game crashes randomly, sometimes after a few button clicks(changing scenes), sometimes on the first click... The console gives no errors whatsoever...

Tried to do it in both: Godot 4.0.3 and 4.1 beta3, the result is the same.

I have also recreated this in Godot 3.5.2, the exported game without "Export with Debug" works fine, without crashes at all.

I have spent 4-5 hours yesterday searching internet and trying to fix it, but I couldn't. Tried different ffmpeg builds to convert the video, tried different video framerates, with audio and without audio... Looks like it's a Godot 4 issue.

Steps to reproduce

1 - create a scene, add VideoStreamPlayer node, assign your video to it.
2 - create another scene with a VideoStreamPlayer node and assign your video to it.
3 - create buttons on each scene to switch between them.
4 - export your project for windows without "Export with Debug"
5 - play the game, after switching the scenes a couple of time, the game will crash.

Minimal reproduction project

Crash_Test_3.zip

@akien-mga
Copy link
Member

Tested the MRP on Linux and I can't reproduce a crash with the Linux release export template or the Windows release export template (through Wine), so this may be Windows specific.

With the Linux template, I get these errors raised occasionally when switching scenes, which can relate to what would be causing a crash on Windows:

ERROR: Condition "slot >= slot_max" is true. Returning: nullptr
   at: get_instance (./core/object/object.h:986)

@Freecreativename
Copy link
Author

I have just played the exported game on Windows 8.1 and didn't get any crashes, although I have switched scenes about 100 times... Then I closed the game with Alt+F4 and reopened it. I got a crash after 3 clicks... Weird...

Tested the MRP on Linux and I can't reproduce a crash with the Linux release export template or the Windows release export template (through Wine), so this may be Windows specific.

With the Linux template, I get these errors raised occasionally when switching scenes, which can relate to what would be causing a crash on Windows:

ERROR: Condition "slot >= slot_max" is true. Returning: nullptr
   at: get_instance (./core/object/object.h:986)

What is causing this error? Do you know how to fix it?

@akien-mga
Copy link
Member

This error signals an internal engine bug, it's not something you're doing wrong and can fix, at most you can try to change how you change scenes to work it around.

godot/core/object/object.h

Lines 982 to 986 in 9a09ee5

_ALWAYS_INLINE_ static Object *get_instance(ObjectID p_instance_id) {
uint64_t id = p_instance_id;
uint32_t slot = id & OBJECTDB_SLOT_MAX_COUNT_MASK;
ERR_FAIL_COND_V(slot >= slot_max, nullptr); // This should never happen unless RID is corrupted.

@Freecreativename
Copy link
Author

I'm actually a beginner with Godot, so I don't really know another way to change the scenes. Could you, please, give me an example based on the MRP?

@akien-mga
Copy link
Member

You can do something like this:

func _on_button_pressed():
	var new_scn = load("res://scene_2.tscn").instantiate()
	$/root.add_child(new_scn)
	self.queue_free()

And likewise for main.tscn.

This adds the new scene to the root, and then frees the old scene after a delay, which seems to prevent the error in my test, so it might fix the crash on Windows.

change_scene_to_file seems to be too eager freeing the old scene while it's still in use maybe.

@Freecreativename
Copy link
Author

You can do something like this:

func _on_button_pressed():
	var new_scn = load("res://scene_2.tscn").instantiate()
	$/root.add_child(new_scn)
	self.queue_free()

And likewise for main.tscn.

This adds the new scene to the root, and then frees the old scene after a delay, which seems to prevent the error in my test, so it might fix the crash on Windows.

change_scene_to_file seems to be too eager freeing the old scene while it's still in use maybe.

Thanks for your reply! Sadly your workaround didn't fix random crashes, checked it on Windows 10 and Windows 8.1.

@YuriSizov
Copy link
Contributor

Reopening, because #78987 is getting reverted.

@YuriSizov YuriSizov reopened this Jul 31, 2023
@YuriSizov YuriSizov modified the milestones: 4.2, 4.x Nov 15, 2023
@akien-mga
Copy link
Member

This might have been fixed by #78988. At least for me the errors reported in #78788 (comment) are no longer reproduced in 4.2-rc1.

Could you test to confirm whether 4.2-rc1 (or any later version when you get to test) solves the crash you had on Windows?

@akien-mga
Copy link
Member

Based on my tests I'll close this as fixed by #78988, but please let us know if you still reproduce that crash in 4.2-rc1 or later.

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