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

Multiple calls of ConnectFromApp results in multiple contextHooks being added #37

Closed
TonyAlbrecht opened this issue Aug 19, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@TonyAlbrecht
Copy link

Hey Sammy, I love what you've done with netImgui, but I think I've found a bug.

Whenever ConnectFromApp() is called, it Disconnects() and then reconnects and calls client.ContextInitialize() which adds a new context hook (if NETIMGUI_IMGUI_CALLBACK_ENABLED is defined). Currently, the Disconnect doesn't remove the hook, so we end up with a new hook being added every time ConnectFromApp() is called.

You can repro this by running a client, connecting to a server then shutting the server down and then starting it and reconnecting. Every time you do this, a new hook is added and the result is that the server only displays a valid update once every 'N' frames.

Checking mhImguiHookNewframe in ContextInitialize() and only adding a new hook if it's zero works, as should removing the hook in Disconnect() (currently the destructor for ClientInfo is the only place that removes the hook.)

@sammyfreg sammyfreg added the bug Something isn't working label Aug 19, 2022
@sammyfreg
Copy link
Owner

Thank you for the report. Should be easy enough to fix.

@sammyfreg
Copy link
Owner

Which version of NetImgui are you using?

sammyfreg added a commit that referenced this issue Aug 20, 2022
Fix multiple Context Hook callback added to Imgui context, after a reconnect.
@sammyfreg
Copy link
Owner

Issue has been fixed: 74d0be3

Normally, the hook cleanup happen in NewFrame(). As long as it is always called, there should not be any problem. Once I tried with the 'NoBackend' sample (only draw where there's an active connection) , I was able to reproduce the issue and fix it accordingly.

sammyfreg added a commit that referenced this issue May 4, 2023
* Bugfix #37

Fix multiple Context Hook callback added to Imgui context, after a reconnect.

* Prevent Server from saving a imgui.ini file

This could conflict with other imgui application in same folder, and the Server doesn't really need any Imgui settings saved

* Fixes for Linux build

-Invalid GPU resource release on Com Thread
-TextureId cast error
-Unneeded Windows specific include

* Fix some textureid cast error on GCC

* Socket 'Force Listen' now optional

Default is unused. Prevents having 2 running NetImgui Servers listening on same port.
Seems like the 'force listen' isn't  needed on Windows/Linux, but can still toggle it on if needed.

* Updated for Dear ImGui 1.89 support

-Small changes done to inputs

* OffsetPointer fix

Possible error for platorm using top bit in 64bits in VirtualAddress space

* Removed 'unused const' warning introduced in VisualStudio 17.4.4

Fix the CI

* Revert to wrongly submitted loader file during last Dear ImGui backend update

* Upgrade DearImgui 1.89.5

* Version 1.9 Release

* Update msbuild_vs2022_dev.yml

updated msbuild setup

* Update msbuild_vs2022_dev.yml

Update to dotnet installed (needed for sharpmake)

* Update msbuild_vs2022_dev.yml

* Update msbuild_vs2022_dev.yml

* Update msbuild_vs2022_dev.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants