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

Feature: Hot-Reloading #43

Open
CooCooCaCha opened this Issue Apr 3, 2016 · 16 comments

Comments

Projects
10 participants
@CooCooCaCha

The idea is fairly self-explanatory. Reload pieces of the game while it is still running. Super useful for debugging and speeding up development.

I wrote a simple example showing how this is possible.
https://github.com/CooCooCaCha/amethyst-hot-reload

The example will compile, load, and run a simple amethyst example at runtime. It will also detect file-system events and reload the new code.

This isn't a fully fleshed-out idea so the architecture is still very much up in the air.

@ebkalderon

This comment has been minimized.

Show comment
Hide comment
@ebkalderon

ebkalderon Apr 4, 2016

Member

@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.

Member

ebkalderon commented Apr 4, 2016

@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.

@CooCooCaCha

This comment has been minimized.

Show comment
Hide comment
@CooCooCaCha

CooCooCaCha Apr 4, 2016

@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.

@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.

@ebkalderon

This comment has been minimized.

Show comment
Hide comment
@ebkalderon

ebkalderon Apr 4, 2016

Member

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.

Member

ebkalderon commented Apr 4, 2016

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.

@CooCooCaCha

This comment has been minimized.

Show comment
Hide comment
@CooCooCaCha

CooCooCaCha Apr 4, 2016

@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.

@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.

@CooCooCaCha

This comment has been minimized.

Show comment
Hide comment
@CooCooCaCha

CooCooCaCha Apr 4, 2016

Also, I don't think energy should be put into this feature until the amethyst architecture has settled.

Also, I don't think energy should be put into this feature until the amethyst architecture has settled.

@ebkalderon

This comment has been minimized.

Show comment
Hide comment
@ebkalderon

ebkalderon Apr 4, 2016

Member

Of course, but it will definitely be kept in mind for the future.

Member

ebkalderon commented Apr 4, 2016

Of course, but it will definitely be kept in mind for the future.

@thiolliere

This comment has been minimized.

Show comment
Hide comment
@thiolliere

thiolliere Apr 5, 2016

this feature is great but seems hard to implement.

another feature is to watch yaml configuration file only.
on a change the shard or core part responsible is informed with the new configuration (through a trait)
And it's up to the shards or core part developer to implement as possible the reset.

it would be useful to be able to adjust game constant like character velocity in real time.
also some shard can implement it quite easily. even if some configuration change would (always?) need a the game to restart.

Well I'm not sure if it's that much useful as it is very easy to just restart the game...

this feature is great but seems hard to implement.

another feature is to watch yaml configuration file only.
on a change the shard or core part responsible is informed with the new configuration (through a trait)
And it's up to the shards or core part developer to implement as possible the reset.

it would be useful to be able to adjust game constant like character velocity in real time.
also some shard can implement it quite easily. even if some configuration change would (always?) need a the game to restart.

Well I'm not sure if it's that much useful as it is very easy to just restart the game...

@CooCooCaCha

This comment has been minimized.

Show comment
Hide comment
@CooCooCaCha

CooCooCaCha Apr 5, 2016

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.

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.

@lschmierer

This comment has been minimized.

Show comment
Hide comment
@lschmierer

lschmierer Apr 11, 2016

Member

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.

Member

lschmierer commented Apr 11, 2016

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.

@CooCooCaCha

This comment has been minimized.

Show comment
Hide comment
@CooCooCaCha

CooCooCaCha Apr 12, 2016

@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.

@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.

@fHachenberg

This comment has been minimized.

Show comment
Hide comment
@fHachenberg

fHachenberg Sep 16, 2016

In a way, hot-reloading data is similar to a database migration. You are basically changing the schema of your components.

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.

In a way, hot-reloading data is similar to a database migration. You are basically changing the schema of your components.

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.

@jFransham

This comment has been minimized.

Show comment
Hide comment
@jFransham

jFransham Dec 16, 2016

Contributor

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

Contributor

jFransham commented Dec 16, 2016

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

@omni-viral

This comment has been minimized.

Show comment
Hide comment
@omni-viral

omni-viral Sep 19, 2017

Member

This issue is worked on in #266

Member

omni-viral commented Sep 19, 2017

This issue is worked on in #266

@omni-viral omni-viral closed this Sep 19, 2017

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Sep 19, 2017

Member

This issue is about the reloading of code, reopening.

Member

torkleyy commented Sep 19, 2017

This issue is about the reloading of code, reopening.

@torkleyy torkleyy reopened this Sep 19, 2017

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro Apr 14, 2018

Collaborator

I could see this work when modifying a system, but not really for any other code. Is this even possible in rust?

Collaborator

jojolepro commented Apr 14, 2018

I could see this work when modifying a system, but not really for any other code. Is this even possible in rust?

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Apr 15, 2018

Member

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.

Member

torkleyy commented Apr 15, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment