Closed rktprof closed 5 months ago
Can you share the initSwiftExtension calls you are using?
Can you share the initSwiftExtension calls you are using?
#initSwiftExtension(cdecl: "networking_init", types: [
LocalNetworkListener.self,
LocalNetworkDiscovery.self,
])
(I renamed the Networking ones since initially posting this issue)
#initSwiftExtension(cdecl: "gamecenter_init", types: [
GameCenter.self,
GameCenterFriends.self,
GameCenterLeaderboards.self,
GameCenterAchievements.self,
GameCenterMatchmaking.self,
GameCenterPlayer.self,
GameCenterFriend.self,
LeaderboardPlayer.self,
])
So I've done some more testing with regards to this and it always breaks as soon as I add two extensions, this is running Godot 2.2 and the latest main branch of SwiftGodot
I created a new empty godot project and two minimal extensions
Then I created two extensions
And when I run the project the log output is
Godot Engine v4.2.2.stable.official.15073afe3 - https://godotengine.org
Vulkan API 1.2.231 - Forward Mobile - Using Vulkan Device #0: Apple - Apple M1 Max
Extension 1 present: false
Extension 2 present: true
and an error:
_register_extension_class_internal: Attempt to register extension class 'Extension2Class', which appears to be already registered.
<C++ Error> Condition "ClassDB::class_exists(class_name)" is true.
<C++ Source> core/extension/gdextension.cpp:386 @ _register_extension_class_internal()
Here are all the files project.zip
The challenge is a little more complex than I hoped, see this bug for details
The initial issue was that multiple extension overwrote the global that kept track of the init functions, and we would only ever initialize one. The fix attempt added them to an array, but Godot would call the init function, once per library, and then we would attempt registration twice, which would produce an ugly error.
The fix in 81e92c5fed8ba2a5c4a01be9bdb923758aa9f07d should fix both.
Thank you for the reproducible test case.
I'm experiencing some strange things with having multiple SwiftGodot gdextensions in the same project
Godot 4.2.2 SwiftGodot 0.41.0
Both of the extensions, libGameCenter.dylib and libNetworking.dylib works when they are the only extension available. When I add the Networking extension the GameCenter extension is no longer accessible in the project and I can no longer access any of the classes.
The only error I get is
NetworkBrowser & NetworkListener are the two classes defined in #initSwiftExtension for the Networking extension
Additionally, I think godot messes up some caching because if I remove the gamecenter.gdextension file (but keep libGameCenter.dylib in the folder) and run the game I get the same errors, but now the extension works