-
Notifications
You must be signed in to change notification settings - Fork 42
Improve eject() crashes on DX12
#231
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
Conversation
|
Hey, thank you so much for your contribution! This is great and it would be great to have such a synchronization mechanism for all other backends too. Busy looping is probably not the way to go although arguably it'll only ever briefly happen once at eject which could result in a brief stutter (1s in tragic situations where you just can't get the thread running the unapply). But I am afraid that it could result in a deadlock in single threaded games. An alternative mechanism which could be a bit more lightweight could be to actually switch to a single atomic boolean, something along the lines of Another alternative yet could be to just have |
|
The code has been updated to replace busy loops with the EJECT_REQUESTED approach as suggested. This runs most of the ejection code synchronously during Present. The DLL ejection then happens in a separate thread which waits for none of the hooked functions to be running before ejecting the DLL. |
|
Hi, I haven't forgotten this, I've just been impossibly busy and couldn't really devote any time at all to open source lately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this!
I tested this against darksoulsiii-practice-tool and eldenring-practice-tool and it works flawlessly every time. I would just like a bit of extra clarity on one point, but otherwise LGTM.
And sorry it took a long time, but it's been hard to carve spare time lately.
|
I don't understand why the |
|
Haven't had the chance to try this out, but thank you for this, looks like it is working flawlessly! :) |
Github is telling me that you need to approve the running of the lint step |
83e579b to
ef02cc5
Compare
veeenu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you so much for this 🙌
Some of the lint errors are newer ones that come from the library itself and not this commit, so I fixed those and took the chance to bump the version number so we can issue a new release.
Feel free to rebase and address the few ones remaining, then we can merge in!
Removing hooks during Present avoids Present being called during the process of hooks being removed, which causes a lot of crashes
Replaces busy loops with a single threaded approach for running most of the ejection code during Present. The DLL ejection then happens in a separate thread which waits for none of the hooked functions to be running before ejecting the DLL
ef02cc5 to
a078ee2
Compare
veeenu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
This PR reduces eject crashes by restricting the Minhook disable/uninitialize to the end of the Present call. This prevents it happening at a time when Present is wanting to use the resources that are being unhooked.
I'm fully expecting to make a lot of changes to this code, but thought I'd make a draft PR in case you have any advice on whether this is a reasonable approach.
I'm not very happy with the way synchronisation between the unhook thread and the present thread is done, but it was easy for a proof of concept.
This changes the number of crashes I get on eject while playing Shadow of the Tomb Raider with DX12 from ~30% of the time to 0% (so far).