Feature: Code Hot-Reloading #43
Comments
@CooCooCaCha This would be an awesome feature to have! Thank you for the suggestion. To get your example compiling on my system, I had to change line 21 of main.rs from "libgame.dylib" to "libgame.so". Unfortunately, even then it doesn't quite work on my machine (64-bit Arch Linux). Please see this screencast for details. |
@ebkalderon Yeah this was a quick and dirty example so I didn't test it beyond getting it to work on OSX. My apologies, I should have probably done OS detection to make sure the right filename is loaded. Also, when I look at your screencast I get a broken link with a bunch of porn ads lol. |
I am genuinely sorry about that. I have an ad-blocker in place, so I was unaware of all the ads. I had to find a place to host the screencast since GitHub issues do not allow WebM video attachments. I'll look for somewhere else to host it. Update: I've changed the link above to point directly to the WebM file instead of the website. Please let me know if it works for you. |
@ebkalderon So this is actually working as intended. The issue you're getting in the screencast is because the dynamic library gets rebuilt and restarted for every file system event. For some reason when a file gets saved the event channel gets a ton of events. I haven't looked into it much yet but I think there are easy ways to fix it. Namely 1) filtering events or 2) making sure the file contents actually changed. |
Also, I don't think energy should be put into this feature until the amethyst architecture has settled. |
Of course, but it will definitely be kept in mind for the future. |
this feature is great but seems hard to implement. another feature is to watch yaml configuration file only. it would be useful to be able to adjust game constant like character velocity in real time. Well I'm not sure if it's that much useful as it is very easy to just restart the game... |
Being able to hot reload logic as well as data makes iterating on games much faster. I've come to value this immensely after playing around with unreal engine. Personally I'd like to have both yaml and rust hot-reloading. For example, you could have AI logic units written in rust and configured in yaml. You could then load up the game, find an AI agent, and tweak it right there. |
This is awesome. However, we need to somehow keep states over reload (e.g. graphics context and resources). Or support hot reload for some parts of the engine (shards) like game logic only. |
@lschmierer I definitely think logic would be the best place to start. Data is much more difficult. In a way, hot-reloading data is similar to a database migration. You are basically changing the schema of your components. You also have to consider the dependencies between components and the systems that use them. Once a component changes, dependent systems will need to be recompiled along with the component. Also, you would need to reload the entities that use the component. That way, the game logic could initialize the new component however it sees fit. |
Why? In most cases you will just change - to stay in your analogy - the data within the table, not the schema. For example hot swapping a mesh or a texture seems much easier to me than hot swapping code. |
There has been some work on hot-swapping individual functions in Rust before, it's actually pretty impressive how simple it is, although I don't know if it only works with free functions or not. https://github.com/draivin/rust-hotswap |
This issue is worked on in #266 |
This issue is about the reloading of code, reopening. |
I could see this work when modifying a system, but not really for any other code. Is this even possible in rust? |
Yes, it is and I already did some experiments with it. My plan is to solve this with the node system (vnodes), but I don't have time for programming for a couple of weeks. |
I believe it's better to make it explicit by renaming this issue to "Feature: Code Hot-Reloading" and prevent misunderstandings again. |
thanks |
Closing this due to age and lack of work on it. If there is demand for it, we'll put it on the roadmap. |
No description provided.
The text was updated successfully, but these errors were encountered: