Skip to content
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

Empty render loop panics #216

Open
etra0 opened this issue Dec 19, 2024 · 8 comments
Open

Empty render loop panics #216

etra0 opened this issue Dec 19, 2024 · 8 comments

Comments

@etra0
Copy link
Contributor

etra0 commented Dec 19, 2024

While I was updating litcher, I noticed that if you have an empty render loop it panics!

struct MyRender;

impl ImguiRenderLoop for MyRender {
  fn render(&mut self, ui: &mut imgui::Ui) { println!("Rendering!"); }
}

Prints "Rendering!" once then panics

@etra0
Copy link
Contributor Author

etra0 commented Dec 21, 2024

Oh, this seems to be a dealbreaker for my update. As soon as I hide all the gui also crashes. Will see if I can create a minimal reproduction. This happens on The Witcher 3 DX12.

@veeenu
Copy link
Owner

veeenu commented Dec 21, 2024

I see you use imgui 0.12 in your branch, which is the latest published release. Unfortunately on recent Rust that leads to a panic due to how slices are interpreted, which is fixed but has not yet been released. I believe having an empty draw list could trigger that issue.

What happens if you pin imgui to the same commit I use in hudhook?

@etra0
Copy link
Contributor Author

etra0 commented Dec 21, 2024

It doesn't seem possible? It looks like imgui on crates.io depends on imgui 0.12, so if I specify another myself it complains of incompatible versions :(

I get:

    Updating git repository `https://github.com/imgui-rs/imgui-rs`
error: failed to select a version for `imgui-sys`.
    ... required by package `imgui v0.12.0`
    ... which satisfies dependency `imgui = "^0.12"` (locked to 0.12.0) of package `hudhook v0.8.0`
    ... which satisfies dependency `hudhook = "^0.8.0"` (locked to 0.8.0) of package `litcher v0.3.8 (C:\Users\Sebastian\Documents\work\tw3lit)`
versions that meet the requirements `^0.12.0` (locked to 0.12.0) are: 0.12.0

the package `imgui-sys` links to the native library `imgui`, but it conflicts with a previous package which links to `imgui` as well:
package `imgui-sys v0.12.0 (https://github.com/imgui-rs/imgui-rs?rev=cb8beeb#cb8beeb7)`
    ... which satisfies git dependency `imgui-sys` of package `imgui v0.12.0 (https://github.com/imgui-rs/imgui-rs?rev=cb8beeb#cb8beeb7)`
    ... which satisfies git dependency `imgui` of package `litcher v0.3.8 (C:\Users\Sebastian\Documents\work\tw3lit)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the `links = "imgui"` value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

failed to select a version for `imgui-sys` which could resolve this conflict

which honestly I declare myself incompetent to solve, lol

@etra0
Copy link
Contributor Author

etra0 commented Dec 21, 2024

ok, doing

diff --git a/Cargo.toml b/Cargo.toml
index e315e00..278af66 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,11 +19,17 @@ windows-sys = {version = "0.35", features = [
   "Win32_System_Console",
 ]}
 simple_injector = { git = "https://github.com/etra0/simple_injector" }
+imgui = { git = "https://github.com/imgui-rs/imgui-rs", rev = "cb8beeb" }
 hudhook = "0.8.0"
-imgui = "0.12"
+
+
 lazy-re = "0.1.1"
 anyhow = "1.0.65"
 
+[replace]
+"imgui:0.12.0" = { git = "https://github.com/imgui-rs/imgui-rs", rev = "cb8beeb" }
+"imgui-sys:0.12.0" = { git = "https://github.com/imgui-rs/imgui-rs", rev = "cb8beeb" }
+
 [build-dependencies]
 embed-resource = "1.8"

seems to be working for now but I will hold the release until this is fixed. That was indeed the issue, thanks!

@veeenu
Copy link
Owner

veeenu commented Dec 21, 2024

Sometimes in cases like this it's helpful to nuke Cargo.lock, chances are there was the released version fighting with the pinned one.

I agree it is a bit unfortunate to have to release crates depending on a git commit, but there haven't been new releases of imgui-rs in a few months now and I'm not sure what the roadmap looks like, but I don't think a new release will happen soon there. I'd release anyway if I were you -- litcher is a freestanding application so once it's compiled there are no further dependency risks to manage 😁

@etra0
Copy link
Contributor Author

etra0 commented Dec 21, 2024

I actually did try just deleting Cargo.lock but didn't help.

I'll upload a pre-release build because I'm curious if that would fix W11 isues!

@etra0
Copy link
Contributor Author

etra0 commented Dec 23, 2024

Just as an addendum to this -- after this update, I've received reports that now works on W11 with the GPU scheduler, yay!

@veeenu
Copy link
Owner

veeenu commented Dec 23, 2024

"Your stuff works now" is as neat a christmas gift as I can get 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants