-
Notifications
You must be signed in to change notification settings - Fork 27
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
I get failed to reload #9
Comments
What errors are you seeing? Could you please include the errors generated here. |
Well, I dont see errors (as a backtrace)
If you know how can I debug I would give a try on win... Wel it just stops there, there is no termination of the program, I need to Ctrl+C and enter to exit. |
And as I have said, it try to reload almost at the same time I hit It is a problem of timming, I hit sometimes the sleep So I wonder what would will be the correct "momment" to load (not time based). |
When I test now I actually get the same issue. I will try to look at this. |
Maybe the "timestamp" of files is now changed before building? or something like that? if prior testing did not result on this "misses". |
Might be. I have some code in there to handle if I can't load the file. Also I always copy the file to a separate directory and load it from there (you can't write an open dll on windows) I will try to investigate it but right now a bit busy but I will try to do it next week unless I get some free time this one. |
@emoon if oyu provide a little direction I could try :) |
Oh crap. I totally forgot about this. Let me get back to you. |
Hi again, So the way this library works:
The reason for this code is that Windows doesn't allow for modifying already loaded dlls which this works on macOS and Linux for example. I have a bunch of code in there that should ensure that reload/copy of the file should work but there might be some cases that doesn't work. Like sometimes when you get a notification that a file has changed it's actually not possible to copy it yet. I have some code that tries to deal with this by checking we can read from it. If we can't we sleep for a while and try again with fixed number. If this still fails I just bail and say fail reload. Hopefully this gives you an overview of how it works. If you have any more specific question I will love to help you out and I really appreciate that you want to take a look at this :) |
@tyoc213 You could also try adding a delay to the |
@emoon hmm. It might be a safer to watch the |
That won't work if you produce dynamic libs from somewhere else than cargo tho. |
It could be added as an optional feature. Also I think we could look for |
Yeah that might work but I would rather have the general case be reliable that this wouldn't be needed. |
I think the general case would need to wait X seconds after the last detected change, before reloading. While testing I have seen multiple events trigger a reload, even when using the Debounce watcher. It doesn't seem to be easy to be 100% sure that the compiler has finished writing the library. |
Yeah I guess so :/ It's annoying that there seems to be no reliable way to do this. Maybe wait, hash file, wait rehash to see if file has still changed may be a way forward? |
watching |
yes. Hashing would be good. Could do the hash check after shadow copying the lib.
|
Something like that yeah |
Someone told me to look at https://github.com/fungos/cr for reference as they say it works there. Might be interesting to see if they have solved these problems in a good way there. |
One important feature from Calling |
I see |
aah. They rollback to the previous library version if the reload fails. Also they validate the library file sections and reload data in the sections. Seems it would be easier to just wrap |
Yeah that might be a good idea |
I might look into wrapping For now, versioning the library copy on each reload, hash checks, and leaking/forgetting the previous instance would help a lot. |
Indeed. Sounds good 👍 |
Any update on this? :) Isn't it the case that this crate only gets notified by the OS when the dll file was closed after writing to it? In that case, why would debounce be necessary? Btw, this recent article goes into detail about the issue that the lib is not reloading due to the TLS destructor: |
@Boscop I ran into those same TLS destructor issues over a year ago fungos/cr#35 while making a Rust binding for |
I've made new tool that fixes thread-locals issue and more: https://github.com/xxshady/relib |
It starts tryng to load the lib even when still compiling packages (for example if I do cargo build --release) it start downloading things, then building and I get the error while it is still building.
Windows 10 here.
The text was updated successfully, but these errors were encountered: