Copying DLL while engine is running

Copying DLL while engine is running

Anonymous
Not applicable
877 Views
11 Replies
Message 1 of 12

Copying DLL while engine is running

Anonymous
Not applicable

Hello,
I am starting to write a lot of gameplay code in C using the Plugin SDK, which works like a charm. I have a process set up where it copies the DLL into the plugin directory after building. However when the engine is running the process fails since the file is in use(the same happens when copying it manually)
I guess this makes sense, but it is definitely very disrupting since I constantly have to close the engine, copy the dll and then restart the project. I have tried terminating the engine process but that did not work either. Is there a known streamlined workflow which will allow me to test and develop at the same time? If not, is there a possibility of something like that might be added in the future? 

Thank you very much!

Reply
Reply
0 Likes
878 Views
11 Replies
Replies (11)
Message 2 of 12

Anonymous
Not applicable

I have the exact same problem and would also be interested in hearing if there's any solution

Reply
Reply
0 Likes
Message 3 of 12

_robbs_
Alumni
Alumni

Yes, you can reload your dll files without shutting down the engine.

 

As you noticed, in v1.6 the dlls in the plugins directory are frozen while the engine is running, so your build process can't directly overwrite them with new copies. Instead, you make your build process copy your dlls to some other folder, and give that folder to the engine as a "hot reload" directory. If the engine sees in this hot reload directory a newer version of a dll that it has already loaded, it will load up that newer dll automatically.

 

have a look at this page:

 

http://help.autodesk.com/view/Stingray/ENU/?guid=__sdk_help_reload_html

 

this process works, but it's a little clunky still. We have a few improvements to come in 1.7,  including exposing more control over engine plug-in loading to Lua.

 

edit: also, it's great to hear that you're using the plugin SDK! We'd love to hear more detail about what you're using it for, and any feedback you have on it!

Reply
Reply
0 Likes
Message 4 of 12

Anonymous
Not applicable

So basically you'd need to define two locations A and B and while the engine is using the other your build location spits the binaries to the other and then you swap. Hope you have a flexible build system (;

Reply
Reply
0 Likes
Message 5 of 12

_robbs_
Alumni
Alumni

it's not that bad, you can output to the hot-reload location, then copy the dll to the plugins directory as a post-build step. If the engine is running, that copy will fail, but you'll still have it to hot-reload.

Reply
Reply
0 Likes
Message 6 of 12

_robbs_
Alumni
Alumni

The trickier part is making sure that your plug-in resumes its state correctly after being reloaded.

Reply
Reply
0 Likes
Message 7 of 12

Anonymous
Not applicable

Don't mean to hijack the thread, but also is there a way to specify that my custom plugin should be included in the deployment package. Currently the editor doesn't understand and every time I deploy I have to manually copy my custom plugin dlls to the output folder.

 

Reply
Reply
0 Likes
Message 8 of 12

_robbs_
Alumni
Alumni

Yes and no.

 

For yourself, yes -- you can edit the engine/<platform>/<config>/package.manifest file, which tells the deployer what files to ship with the project. Add the relative path and filename of the .dll to the list of files in this manifest along with the other plug-in entries, and save the changes.

 

But since this is in the Stingray install folder, it's only done on your machine for a specific Stingray version. If you distribute your plug-in for other people to use, they'd have to make the same change on their end. And when you upgrade to a new Stingray you'll have to make the change again.

That's something we know we need to improve.

Reply
Reply
0 Likes
Message 9 of 12

Anonymous
Not applicable

Hello,
thanks for the quick reply. However it does not seem to work for me. Do I need to enable hot reloading somewhere else? because in the doc it says

set_plugin_hot_reload_directory ( dir )

If a plugin DLL appears in the directory dir that matches the name of an existing plugin 
and that plugin supports the hot reload interface,
the plugin will be copied to replace that DLL and then the plugin will be hot reloaded.

How do I make my plugin support the "hot reloading interface"? Do I need a .plugin file for it to work? 

Regarding your other question: overall  working with the plugin SDK has been quiet cool.  I have been using it to write gameplay code, especially pieces which are quiet heavy on performance. My overall aim is to maybe even have everything written in C at the end of it.(I am personally not a huge fan of dynamically typed languages, especially once the project becomes bigger, making them harder to maintain)

Reply
Reply
0 Likes
Message 10 of 12

_robbs_
Alumni
Alumni

The hot reload interface that description mentions is in the PluginApi. In 1.6 it offers two functions: PluginApi::start_reload() and PluginApi::finish_reload().

 

docs here

 

I just looked at the code, and it seems that your plugin has to implement both of those functions in order to be successfully reloaded. (I'll update the doc to mention that.)

 

So, you have to

 

- implement those functions in your plugin

- start your game

- call Application.set_hot_reload_directory() either in your game's Lua code or by sending that command to the engine from the editor console.

 

after that, any time you rebuild to the hot reload folder, the new dll should get picked up by the game.

Reply
Reply
0 Likes
Message 11 of 12

Anonymous
Not applicable

thanks, we are getting closer 🙂 Now I just keep getting error codes such as "Acess Denied" (error code 5) although i have full permissions for the folder and the file(stingray is started as admin aswell). Additionally if I use a folder on a drive diffrent to that of the install directory i get an error code 17 (ERROR_NOT_SAME_DEVICE:The system cannot move the file to a different disk drive. ).

Reply
Reply
0 Likes
Message 12 of 12

_robbs_
Alumni
Alumni

I'm getting the Access Denied issue as well.

There's been some work done on this feature for 1.7, so this may have been addressed already. Looking into it.

Reply
Reply
0 Likes