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

Adding some sort of installable error handler / callback for improved diagnostics. #477

Open
bryanedds opened this issue May 15, 2024 · 5 comments

Comments

@bryanedds
Copy link

bryanedds commented May 15, 2024

Currently, when anything goes wrong with ImGui.NET invocation, we end up with an AccessViolationException with no diagnostics or asserts or other clues as to what failed. This is particularly problematic for game editors because we intentionally (have to) expose the ImGui API so that it can be called by users to extend editor behavior.

The only error we ever receive when the use invokes the ImGui.NET API incorrectly is an AccessViolationException. Presumably because this is how the .NET runtime handles C++ exceptions and C asserts that might otherwise be meaningful (tho correct me if I'm wrong, maybe in this case it's just a null pointer dereference exception). What I think might be an improvement on either this wrapper API (or perhaps in imgui itself if required) is to expose an OpenGL-like error report handler. That way, we can pass in a lambda that gets called which can intercept at least some diagnostic information because the entire VM goes down from the AVE.

@zaafar
Copy link
Collaborator

zaafar commented May 16, 2024

Does https://github.com/ImGuiNET/ImGui.NET?tab=readme-ov-file#debugging-native-code not work for you?

This requires you to generate debug level binaries (which you can via this repo pipeline: https://github.com/ImGuiNET/ImGui.NET-nativebuild/actions/runs/9106225132) as shown in the screenshot below.

image

once you do all of this, you can put breakpoints in C++/C code.

@zaafar
Copy link
Collaborator

zaafar commented May 16, 2024

What I think might be an improvement on either this wrapper API (or perhaps in imgui itself if required) is to expose an OpenGL-like error report handler. That way, we can pass in a lambda that gets called which can intercept at least some diagnostic information because the entire VM goes down from the AVE.

you want to produce good error messages in production/user environments? Give debug libs a try, i have a feeling you will get pretty awesome error messages when using them.

@bryanedds
Copy link
Author

bryanedds commented May 17, 2024

Does https://github.com/ImGuiNET/ImGui.NET?tab=readme-ov-file#debugging-native-code not work for you?

We don't really want to debug native code and for our end users who use our engine as a black box, we don't want to burden them with this level of IDE configuration. What we're looking for is a simple installable error handler that we can wrap with a run-of-the-mill #if DEBUG statement. Does ImGui itself not expose a function pointer-based global C error handler like this such as is done in OpenGL?

@bryanedds
Copy link
Author

bryanedds commented May 17, 2024

you want to produce good error messages in production/user environments? Give debug libs a try, i have a feeling you will get pretty awesome error messages when using them.

We don't want to use debug-built libraries if we can at all avoid them. It is important to have our engine run usably fast in debug mode as that's where most initial play testing takes place. All we need is to produce a single, simple imgui-specific error log before ImGui takes down the entire runtime with it (IE, not just a generic AccessViolationException). Ideally this wouldn't require an entirely different and significantly slower debug lib build.

@bryanedds bryanedds changed the title Adding some sort of installable error handler / callback for improved debugging. Adding some sort of installable error handler / callback for improved diagnostics. May 17, 2024
@zaafar
Copy link
Collaborator

zaafar commented May 17, 2024

Ideally this wouldn't require an entirely different and significantly slower debug lib build.

we don't want to burden them with this level of IDE configuration.

Does ImGui itself not expose a function pointer-based global C error handler like this such as is done in OpenGL?

I see, fair enough, I think this question needs an answer from maintainers of imgui ( https://github.com/ocornut/imgui ) feel free to post the question there. I am curious as well.

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