Open Nemesisprime opened 5 months ago
I've found another oddity with hot-reloading enabled: I've got a fairly simple project with two classes with a few exported properties to be used by the Godot Editor. When attempting to manually reload the editor (using Project > Reload Current Project) after swapping out binaries, I am seeing a crash.
This only occurs when I have reloadable = true
enabled in my extension, but I am attempting to manually reload the project via the menu item. I am unsure if it's related to the issue I noted above, but its conditions are close enough that I figured commenting here would be better to start.
Hi, im looking to SwiftGodot a time, and I had some problems with hot reloading, for example, don't have documentation, but I saw in some issues how to use, I don't know if I made a wrong configuration, but isn't working. I tested on windows and on Mac, and both are crashing sometimes when hot reload, but I will remake the test on windows. The test:
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package( name: "swift", platforms: [.macOS(.v13)], products: [ // Products define the executables and libraries a package produces, making them visible to other packages. .library( name: "swift", type: .dynamic, targets: ["swift"]), ], dependencies: [ .package(url: "https://github.com/migueldeicaza/SwiftGodot", branch: "main") ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. // Targets can depend on other targets in this package and products from dependencies. .target( name: "swift", dependencies: [ "SwiftGodot", ], swiftSettings: [.unsafeFlags(["-suppress-warnings"])] ), .testTarget( name: "swiftTests", dependencies: ["swift"]), ] )
4. Create bin folder on root
5. Add gdextension file on bin folder
swift.gdextension:
[configuration] entry_symbol = "swift_entry_point" compatibility_minimum = 4.2 reloadable = true
[libraries] macos.debug = "res://swift/.build/arm64-apple-macosx/debug/libswift.dylib"
[dependencies] macos.debug = {"res://swift/.build/arm64-apple-macosx/debug/libSwiftGodot.dylib" : ""}
6. Create a file named Tests and create 2 classes
Tests.swift
```swift
//
// File.swift
//
//
// Created by Emanuel on 20/06/24.
//
import SwiftGodot
@Godot
class Test: Node {
override func _ready() {
GD.print("A")
}
@Callable
func fnc() {
GD.print("B")
}
}
@Godot
class Test2: Node {
override func _ready() {
GD.print("AA")
}
@Callable
func fnc() {
GD.print("BB")
}
}
MyLibrary.swift
// The Swift Programming Language
// https://docs.swift.org/swift-book
import SwiftGodot
let allNodes: [Wrapped.Type] = [Test.self, Test2.self]
#initSwiftExtension(cdecl: "swift_entry_point", types: allNodes)
testing.gd:
extends Node2D
@onready var test = $Test as Test
@onready var test_2 = $Test2 as Test2
func _ready():
test.fnc()
test_2.fnc()
Tests | Crash | Not responding | Lsp | Work |
---|---|---|---|---|
Change function code | ❌ | ❌ | ❓ | ✅ |
Change function parameters | ✅ | - | ❓ | ❓ |
Change function return | ❌ | ❌ | ❌ | ✅ |
Remove function | ❌ | ✅ | ❓ | ❓ |
Add function | ❌ | ❌ | ❌ | ✅ |
Rename function | ❌ | ❌ | ❌ | ✅ |
Remove class | ❌ | ❌ | ❌ | ✅ |
Add class | ❌ | ❌ | ❌ | ✅ |
Rename class | ❌ | ❌ | ❌ | ❓ |
The rename class can't be tested if work, because the hot reload doesn't add the class, I need to reload the engine manually. One thing then i noticed, the engine crash when I close the engine in whatever tests then engine not crashed or not respond. I don't know if have any difference between crash and not responding, but i noticed that. Im sorry by the English and if that is useless, after I will make the same tests on windows.
Given a simple class with export variables:
Assuming it is attached to a Node and the GDExtension is configured with
reloadable = true
, after updating the extension libs and hot reloading occurs, the export variables are no longer exposed/visible in the inspector UI until the editor is reloaded.Seeing this behavior with Godot 4.2.1—I don't see anything about reloadable support in the docs, but saw a few mentions about it in discussion about it so thought this would be worthy to bring up.
Bests!