Open pdesaulniers opened 3 years ago
Perhaps this is due to ImGui's reliance on static variables?
Just checked it, it's because GL2/3 backend files don't support multiple contexts.
void ImGui::ErrorCheckNewFrameSanityChecks(): l'assertion « g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8()?" » a échoué.
I found a related PR which stores context-specific data. If I understand right, this is only a matter of implementing the same mechanism in these other backends. https://github.com/ocornut/imgui/pull/3934
I've just made this patch, it should enable OpenGL2 to work
imgui-opengl2.diff.txt
imgui-opengl2.diff.txt
I can still reproduce the issue with the patch. However, Valgrind now reports an uninitialised value when I open the UI:
==18322== Use of uninitialised value of size 8
==18322== at 0x263B0B5E: ImHashData(void const*, unsigned long, unsigned int) (imgui.cpp:1498)
==18322== by 0x2642C0DF: ImGui_ImplOpenGL2_GetID() (imgui_impl_opengl2.cpp:68)
==18322== by 0x2642C0EE: ImGui_ImplOpenGL2_New() (imgui_impl_opengl2.cpp:73)
==18322== by 0x2642C1CB: ImGui_ImplOpenGL2_Init() (imgui_impl_opengl2.cpp:102)
==18322== by 0x263AD89D: DISTRHO::ImGuiUI::Impl::setupGL() (ImGuiUI.cpp:276)
==18322== by 0x263AD63D: DISTRHO::ImGuiUI::Impl::Impl(DISTRHO::ImGuiUI*) (ImGuiUI.cpp:230)
==18322== by 0x263ACEBA: DISTRHO::ImGuiUI::ImGuiUI(int, int) (ImGuiUI.cpp:59)
==18322== by 0x263AC913: DISTRHO::UISimpleGain::UISimpleGain() (UISimpleGain.cpp:37)
==18322== by 0x263ACCC7: DISTRHO::createUI() (UISimpleGain.cpp:125)
==18322== by 0x26449199: DISTRHO::createUiWrapper(void*, DGL::Window*) (DistrhoUIInternal.hpp:173)
==18322== by 0x26449226: DISTRHO::UIExporterWindow::UIExporterWindow(DGL::Application&, long, double, void*) (DistrhoUIInternal.hpp:184)
==18322== by 0x26449618: DISTRHO::UIExporter::UIExporter(void*, long, void (*)(void*, unsigned int, bool), void (*)(void*, unsigned int, float), void (*)(void*, char const*, char const*), void (*)(void*, unsigned char, unsigned char, unsigned char), void (*)(void*, unsigned int, unsigned int), float, void*, char const*) (DistrhoUIInternal.hpp:272)
Oops you're right, thanks for catching this one
return ImHashData(context, sizeof(void*));
change to
return ImHashData(&context, sizeof(void*));
Thanks, it works! :tada:
Oops, now I get an error when I click on the arrow in the header (at the left of the "Simple gain" label):
simplegain: ../../imgui/imgui.cpp:7185: void ImGui::ErrorCheckEndFrameSanityChecks(): Assertion `(g.CurrentWindowStack.Size == 1) && "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?"' failed.
==19807==
==19807== Process terminating with default action of signal 6 (SIGABRT): dumping core
==19807== at 0x4F10EF5: raise (in /usr/lib/libc-2.33.so)
==19807== by 0x4EFA861: abort (in /usr/lib/libc-2.33.so)
==19807== by 0x4EFA746: __assert_fail_base.cold (in /usr/lib/libc-2.33.so)
==19807== by 0x4F09645: __assert_fail (in /usr/lib/libc-2.33.so)
==19807== by 0x12966C: ImGui::ErrorCheckEndFrameSanityChecks() (imgui.cpp:7185)
==19807== by 0x11DCA4: ImGui::EndFrame() (imgui.cpp:4385)
==19807== by 0x11E0DC: ImGui::Render() (imgui.cpp:4461)
==19807== by 0x1106BD: DISTRHO::ImGuiUI::onDisplay() (ImGuiUI.cpp:90)
==19807== by 0x1D1FDB: DGL::Widget::PrivateData::display(unsigned int, unsigned int, double, bool) (WidgetPrivateData.cpp:88)
==19807== by 0x1CED8B: DGL::Window::PrivateData::onPuglDisplay() (Window.cpp:926)
==19807== by 0x1CFD60: DGL::Window::PrivateData::onDisplayCallback(PuglViewImpl*) (Window.cpp:1295)
==19807== by 0x1CBA47: puglDisplay (pugl_x11.c:397)
Aborted (core dumped)
I can reproduce the issue when running a single instance of the plugin.
EDIT: my bad, this crash is unrelated to the issue at hand. I didn't notice it earlier because I was running a release build with assertions disabled
Fixed also in the latest commit, thanks
To reproduce:
As soon as we open the second UI, Carla crashes:
Perhaps this is due to ImGui's reliance on static variables?