GodotSteam: Godot Crash when starting from steam client (when GodotSteam GDExtension)

Describe the bug

AppID: 1955200 in pre-release

Game crash to desktop only when started from steam client Godot Log is empty or is cut just before the Steam.steamInit()

  • Running the game from file system (downloaded from steam) prevent the crash but steam init sometimes return “game not owned”
  • Running the game in debug from godot editor works great (and all achievement / stats are working)

To Reproduce

My current steam init script:

func _ready() -> void:
	
	# return #	disable due to crash on startup from steam
	
	#  Connect some signals
	Steam.connect("current_stats_received", self, "_steam_Stats_Ready", [], CONNECT_ONESHOT)
	
	SettingsGameplay.connect("AchievementAchieved", self, "on_achievement_achieved")
	SettingsGameplay.connect("PlayerStatChanged", self, "on_player_stat_changed")
	
	# Initialize Steam
	var INIT: Dictionary = Steam.steamInit() #add false to steamInit(false) to not pull player stats
	print("[STEAM] Did Steam initialize?: "+str(INIT))
	if INIT['status'] != 1:
		# If Steam fails to start up, shut down the app
		print("[STEAM] Failed to initialize Steam. "+str(INIT['verbal'])+" ignoring...")
		IS_ONLINE = false
		return
		# get_tree().quit()

	#Is the user online?
	IS_ONLINE = Steam.loggedOn()
	# Get the user's Stean name and ID
	STEAM_ID = Steam.getSteamID()
	STEAM_NAME = Steam.getPersonaName()
	# Is this app owned or is it a free weekend?
	IS_OWNED = Steam.isSubscribed()
	IS_FREE_WEEKEND = Steam.isSubscribedFromFreeWeekend()

On crash --> the print("[STEAM] Did Steam initialize?: "+str(INIT)) is never done

Expected behavior

Starting the game from the steam client, the file system or the godot engine should behave the same.

Screenshots

image

Desktop (please complete the following information):

  • OS: Windows
  • Version 11

Version of Godot:

Godot 3.5.2 stable official LTS

Version of GodotSteam:

GDExtension Godot 3.5.2 - Steamworks 1.57 - GodotSteam 3.19.3

using default Godot export templates

Additional context

-Adding a -v to the start argument in steam allows to have a bit of log but it stop abruptly in the middle of writing a line of resources load just before the steam init.

  • This is my first use of godot steam, I wouldn’t be suprised if the problem is me using it wrong.

  • example of cut log:

Godot Engine v3.5.2.stable.official.170ba337a - https://godotengine.org
Using GLES3 video driver
OpenGL ES 3.0 Renderer: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2
Async. shader compilation: OFF
OpenGL ES 2D Batching: ON
Batching Options:
	max_join_item_commands 16
	colored_vertex_format_threshold 0.25
	batch_buffer_size 16384
	light_scissor_area_threshold 1
	item_reordering_lookahead 4
	light_max_join_items 32
	single_rect_fallback False
	debug_flash False
	diagnose_frame False

(...)
Loading resource: res://addons/gift/gift_node.gdc
Loading resource: res://addons/gift/util/sender_data.gdc
Loading resource: res://addons/gift/util/image_cache.gdc
Loading resource: res://addons/gift/placeholder.png
Loading resource: res://addons/gift/util/cmd_data.gdc
Loading resource: res://addons/gift/util/cmd_info.gdc
Loading resource: res:

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 22 (12 by maintainers)

Most upvoted comments

Just confirmed it works on Windows 11. Same code using the GDNative extension from the Asset lib.

All good! The plug-ins get confusing sometimes, haha. Hmm, OK, so it is isolated to GDNative; good to know. I also use Ubuntu so it’ll be easy to test. If possible, feel free to run a test with GDNative on another OS. Some weird issues seem to only exist on certain operating systems for whatever reason; some we can fix by strangely editing how certain functions works. I have no idea why that is though.

I will try to get it tested this weekend to see about duplicating it and tracking down why.

Oh, Yes. Sorry. Got my wires crossed. It’s the GDNative version.

Yes, the achievements were added and published. I’m now executing it with the pre-compiled editor and it works just fine. I can get and trigger achievements without problems. The GDNative plugin in the vanilla editor still crashes.

I’m happy to execute samples on my machine if you need help gathering more info. I’ll try to run it from another OS to check if the problem is caused because of my steamworks account, hardware or the OS itself. Thanks.

I agree with you. It’s a very niche issue so if it’s too complicate to replicate, investigate and fix, just a warning in the tutorial should be enough.

In case a game dev need to pull a large amount of achievement at start-up, it’s easy enough to switch from the plugin to the pre-compiled editor + template.

Thanks a lot for your help on this issue! Your project is amazing and extremely easy to use! Good job to all the team.

Hmm, maybe. Usually the two are on par with each other and their code-base is pretty much identical with some minor differences in how GDExtension works. This may not be a problem we can fix, in this case. I’ll dig around more on it and see what I can find! Might be something we just have to warn about for the time being.

Thanks for all the extra details!

Hello @Gramps,

Thanks a lot for your support !

While writing this answer, I found more information about the crash to desktop.

I am pulling 60 achievements in the call-back “current_stats_received”. This seems to be too much and crash the game.

Adding a yield(get_tree().create_timer(1.0), "timeout") between each Steam.getAchievement call sometimes prevent the crash. I make a clean godot project for you if you want to reproduce the issue: GodotSteamCrash.zip

PS: I am happy to send you via private message a steam key of the game if you need to test with the same appid. Let me know

However this yield solution doesn’t work consistently and I am not certain the timing will be valid on every player computer. I tested multiple times and smaller delay time tend to crash. (0.5 -> crash)

  • Is there a better signal from the godotsteam that I can yield on?
  • Or is there a better way to retrieve the state of many achievements?

To answer your question above: Are you using the GDExtension version or the pre-compiled editor/templates?

I believe I am using the GDExtension plugin. The link I gave you seems incorrect. My Godot is standard and I do not use extra export templates.

Here is a screenshot of what I am using:

image

Q: Seeing as how you run it from Steam, I’m guessing you have your packages set up correctly and this account is listed as a developer account in Steamworks? Sometimes people don’t have the packages and depots set up right.

I tried it with multiple account and had the same crash:

  • With the main account owner of the app in https://partner.steamgames.com/
  • With a separate account listed as a developer on the app
  • With an account that only have a steam key

I assume my packages and depots are setup correctly as everything else works with them.


By the way, this is not an urgent or blocking issue for me as my code automatically deduce completed achievements based on the steam stats. I have a workaround.

However I am fully available if you wish to investigate the root cause of the issue as it may happen to other devs as well.

Hey there! Are you using the GDExtension version or the pre-compiled editor/templates? The link you show is for the pre-compiled editor and templates.

If you’re using the GDExtension plugin, you don’t need the pre-compiled stuff. Just the normal Godot templates.

Seeing as how you run it from Steam, I’m guessing you have your packages set up correctly and this account is listed as a developer account in Steamworks? Sometimes people don’t have the packages and depots set up right.

Let me know about those two things and we can figure it out!