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

Several constants (enums) are not loaded from GetFunc #7

Closed
Levitanus opened this issue Dec 26, 2022 · 4 comments
Closed

Several constants (enums) are not loaded from GetFunc #7

Levitanus opened this issue Dec 26, 2022 · 4 comments

Comments

@Levitanus
Copy link

I'm working on rust bindings, and, generally, everything works. But several constants are still not loaded, while the most part of the API is.

I can not say, I suffer from this right now, but I'm interested, what can be matter. Loading happens after all user plugins are initialized.

Arch Linux x86-64, ReaImGui 0.8.1 (I just grab the latest release for bindings generation)

Here is the list:

can not load constant: ImGui_ConfigFlags_NavNoCaptureKeyboard
Can not load constant: ImGui_ConfigVar_DockingNoSplit
Can not load constant: ImGui_ConfigVar_DockingTransparentPayload
Can not load constant: ImGui_ConfigVar_DockingWithShift
Can not load constant: ImGui_ConfigVar_DragClickToInputText
Can not load constant: ImGui_ConfigVar_Flags
Can not load constant: ImGui_ConfigVar_HoverDelayNormal
Can not load constant: ImGui_ConfigVar_HoverDelayShort
Can not load constant: ImGui_ConfigVar_InputTextCursorBlink
Can not load constant: ImGui_ConfigVar_InputTextEnterKeepActive
Can not load constant: ImGui_ConfigVar_InputTrickleEventQueue
Can not load constant: ImGui_ConfigVar_KeyRepeatDelay
Can not load constant: ImGui_ConfigVar_KeyRepeatRate
Can not load constant: ImGui_ConfigVar_MacOSXBehaviors
Can not load constant: ImGui_ConfigVar_MouseDoubleClickMaxDist
Can not load constant: ImGui_ConfigVar_MouseDoubleClickTime
Can not load constant: ImGui_ConfigVar_MouseDragThreshold
Can not load constant: ImGui_ConfigVar_ViewportsNoDecoration
Can not load constant: ImGui_ConfigVar_WindowsMoveFromTitleBarOnly
Can not load constant: ImGui_ConfigVar_WindowsResizeFromEdges
Can not load constant: ImGui_HoveredFlags_DelayNormal
Can not load constant: ImGui_HoveredFlags_DelayShort
Can not load constant: ImGui_HoveredFlags_NoNavOverride
Can not load constant: ImGui_HoveredFlags_NoSharedDelay
Can not load constant: ImGui_Key_0
Can not load constant: ImGui_Key_1
Can not load constant: ImGui_Key_2
Can not load constant: ImGui_Key_3
Can not load constant: ImGui_Key_4
Can not load constant: ImGui_Key_5
Can not load constant: ImGui_Key_6
Can not load constant: ImGui_Key_7
Can not load constant: ImGui_Key_8
Can not load constant: ImGui_Key_9
Can not load constant: ImGui_Key_A
Can not load constant: ImGui_Key_Apostrophe
Can not load constant: ImGui_Key_B
Can not load constant: ImGui_Key_Backslash
Can not load constant: ImGui_Key_Backspace
Can not load constant: ImGui_Key_C
Can not load constant: ImGui_Key_CapsLock
Can not load constant: ImGui_Key_Comma
Can not load constant: ImGui_Key_D
Can not load constant: ImGui_Key_Delete
Can not load constant: ImGui_Key_DownArrow
Can not load constant: ImGui_Key_E
Can not load constant: ImGui_Key_End
Can not load constant: ImGui_Key_Enter
Can not load constant: ImGui_Key_Equal
Can not load constant: ImGui_Key_Escape
Can not load constant: ImGui_Key_F
Can not load constant: ImGui_Key_F1
Can not load constant: ImGui_Key_F10
Can not load constant: ImGui_Key_F11
Can not load constant: ImGui_Key_F12
Can not load constant: ImGui_Key_F2
Can not load constant: ImGui_Key_F3
Can not load constant: ImGui_Key_F4
Can not load constant: ImGui_Key_F5
Can not load constant: ImGui_Key_F6
Can not load constant: ImGui_Key_F7
Can not load constant: ImGui_Key_F8
Can not load constant: ImGui_Key_F9
Can not load constant: ImGui_Key_G
Can not load constant: ImGui_Key_GraveAccent
Can not load constant: ImGui_Key_H
Can not load constant: ImGui_Key_Home
Can not load constant: ImGui_Key_I
Can not load constant: ImGui_Key_Insert
Can not load constant: ImGui_Key_J
Can not load constant: ImGui_Key_K
Can not load constant: ImGui_Key_Keypad0
Can not load constant: ImGui_Key_Keypad1
Can not load constant: ImGui_Key_Keypad2
Can not load constant: ImGui_Key_Keypad3
Can not load constant: ImGui_Key_Keypad4
Can not load constant: ImGui_Key_Keypad5
Can not load constant: ImGui_Key_Keypad6
Can not load constant: ImGui_Key_Keypad7
Can not load constant: ImGui_Key_Keypad8
Can not load constant: ImGui_Key_Keypad9
Can not load constant: ImGui_Key_KeypadAdd
Can not load constant: ImGui_Key_KeypadDecimal
Can not load constant: ImGui_Key_KeypadDivide
Can not load constant: ImGui_Key_KeypadEnter
Can not load constant: ImGui_Key_KeypadEqual
Can not load constant: ImGui_Key_KeypadMultiply
Can not load constant: ImGui_Key_KeypadSubtract
Can not load constant: ImGui_Key_L
Can not load constant: ImGui_Key_LeftAlt
Can not load constant: ImGui_Key_LeftArrow
Can not load constant: ImGui_Key_LeftBracket
Can not load constant: ImGui_Key_LeftCtrl
Can not load constant: ImGui_Key_LeftShift
Can not load constant: ImGui_Key_LeftSuper
Can not load constant: ImGui_Key_M
Can not load constant: ImGui_Key_Menu
Can not load constant: ImGui_Key_Minus
Can not load constant: ImGui_Key_N
Can not load constant: ImGui_Key_NumLock
Can not load constant: ImGui_Key_O
Can not load constant: ImGui_Key_P
Can not load constant: ImGui_Key_PageDown
Can not load constant: ImGui_Key_PageUp
Can not load constant: ImGui_Key_Pause
Can not load constant: ImGui_Key_Period
Can not load constant: ImGui_Key_PrintScreen
Can not load constant: ImGui_Key_Q
Can not load constant: ImGui_Key_R
Can not load constant: ImGui_Key_RightAlt
Can not load constant: ImGui_Key_RightArrow
Can not load constant: ImGui_Key_RightBracket
Can not load constant: ImGui_Key_RightCtrl
Can not load constant: ImGui_Key_RightShift
Can not load constant: ImGui_Key_RightSuper
Can not load constant: ImGui_Key_S
Can not load constant: ImGui_Key_ScrollLock
Can not load constant: ImGui_Key_Semicolon
Can not load constant: ImGui_Key_Slash
Can not load constant: ImGui_Key_Space
Can not load constant: ImGui_Key_T
Can not load constant: ImGui_Key_Tab
Can not load constant: ImGui_Key_U
Can not load constant: ImGui_Key_UpArrow
Can not load constant: ImGui_Key_V
Can not load constant: ImGui_Key_W
Can not load constant: ImGui_Key_X
Can not load constant: ImGui_Key_Y
Can not load constant: ImGui_Key_Z
Can not load constant: ImGui_Mod_Alt
Can not load constant: ImGui_Mod_Ctrl
Can not load constant: ImGui_Mod_None
Can not load constant: ImGui_Mod_Shift
Can not load constant: ImGui_Mod_Shortcut
Can not load constant: ImGui_Mod_Super
Can not load constant: ImGui_Key_MouseLeft
Can not load constant: ImGui_Key_MouseMiddle
Can not load constant: ImGui_Key_MouseRight
Can not load constant: ImGui_Key_MouseWheelX
Can not load constant: ImGui_Key_MouseWheelY
Can not load constant: ImGui_Key_MouseX1
Can not load constant: ImGui_Key_MouseX2
Can not load constant: ImGui_InputTextFlags_EscapeClearsAll

That is how I load them:

Key_MouseRight: unsafe {
    match plugin_context
        .GetFunc(c_str_macro::c_str!("ImGui_Key_MouseRight").as_ptr())
        .is_null()
    {
        true => {
            eprintln!("Can not load constant: {}", "ImGui_Key_MouseRight");
            None
        }
        false => Some((ConstLoader {
            f: std::mem::transmute(
                plugin_context
                    .GetFunc(c_str_macro::c_str!("ImGui_Key_MouseRight").as_ptr()),
            ),
        }
        .f)()),
    }
},

ConstLoader is just a container for C-function type:

struct ConstLoader {
    f: extern "C" fn() -> i32,
}
@cfillion
Copy link
Owner

cfillion commented Dec 27, 2022

Loading happens after all user plugins are initialized.

Are you sure? (Can double-check by setting a breakpoint on ReaImGui's API::announceAll).

Constants are the same as regular functions, so I can't think of another way only those would fail to load.

The C++ binding works around initialization order issues by fetching the function pointer (and caching constant values) upon first use. There are other ways to delay the import until all plugins have been loaded, such as registering a one-shot timer (plugin_register("timer", callback) <-- not one-shot, callback needs to unregister itself with "-timer").

EDIT: All the functions listed above were added in v0.6 or later. Maybe you're running v0.5.9 or .10?

@Levitanus
Copy link
Author

v0.5.x?

Do You mean Reaper? No, I've just migrated everything to v6.73 + last extension SDK + last ReaImGui...

There are other ways to delay the import until all plugins have been loaded

I make a struct, that keeps all pointers, that is loaded from plugin context. Currently, I load it with action, that registers timer, and drop, when timer stops (unregisters).
I haven't checked yet if all regular functions are loaded, this needs to tweak template, so, maybe, will try tomorrow on the fresh head.

@cfillion
Copy link
Owner

cfillion commented Dec 27, 2022

Do You mean Reaper? No, I've just migrated everything to v6.73 + last extension SDK + last ReaImGui...

No, ReaImGui. That particular list of missing constant functions is consistent with running a version after v0.5.8 but before v0.6. Another hint that may be the case is the window isn't semi-transparent in the YouTube video on the forum (transparency was implemented in v0.7). EDIT: Also the wrong mouse cursor over the resize handle, which was fixed in v0.6.

@Levitanus
Copy link
Author

Thank You, yes, that's true. So, I have to tweak GitHub API links instead)

That's strange, I use: https://github.com/cfillion/reaimgui/releases/latest/download/ + file name

cfillion added a commit that referenced this issue Mar 23, 2024
Stack trace of the ~1s hang on the second call to GDKOpenGL::render:

    #0  0x00007ffff7a080bf in __GI___poll
        (fds=fds@entry=0x7fffffffc388, nfds=nfds@entry=1, timeout=timeout@entry=-1)
        at ../sysdeps/unix/sysv/linux/poll.c:29
    #1  0x00007ffff76d620b in poll (__timeout=-1, __nfds=1, __fds=0x7fffffffc388)
        at /usr/include/bits/poll2.h:39
    #2  _xcb_conn_wait
        (c=c@entry=0x11c0140, vector=vector@entry=0x0, count=count@entry=0x0, cond=<optimized out>)
        at /usr/src/debug/libxcb/libxcb-1.16.1/src/xcb_conn.c:510
    #3  0x00007ffff76d829b in _xcb_conn_wait
        (count=0x0, vector=0x0, cond=<optimized out>, c=0x11c0140)
        at /usr/src/debug/libxcb/libxcb-1.16.1/src/xcb_conn.c:476
    #4  xcb_wait_for_special_event (c=0x11c0140, se=0x35bca30)
        at /usr/src/debug/libxcb/libxcb-1.16.1/src/xcb_in.c:806
    #5  0x00007ffff5dad3bf in dri3_wait_for_event_locked ()
        at ../mesa-24.0.3/src/loader/loader_dri3_helper.c:591
    #6  dri3_wait_for_event_locked () at ../mesa-24.0.3/src/loader/loader_dri3_helper.c:572
    #7  0x00007ffff5dada12 in loader_dri3_wait_for_sbc ()
        at ../mesa-24.0.3/src/loader/loader_dri3_helper.c:664
    #8  loader_dri3_swapbuffer_barrier () at ../mesa-24.0.3/src/loader/loader_dri3_helper.c:2343
    #9  0x00007fffc48308da in dri_st_framebuffer_flush_swapbuffers ()
        at ../mesa-24.0.3/src/gallium/frontends/dri/dri_drawable.c:143
    #10 0x00007fffc48f6a99 in st_manager_flush_swapbuffers ()
        at ../mesa-24.0.3/src/mesa/state_tracker/st_manager.c:1270
    #11 st_finish () at ../mesa-24.0.3/src/mesa/state_tracker/st_cb_flush.c:85
    #12 0x00007fffc4a36421 in st_glFinish ()
        at ../mesa-24.0.3/src/mesa/state_tracker/st_cb_flush.c:109
    #13 _mesa_Finish () at ../mesa-24.0.3/src/mesa/main/context.c:1660
    #14 0x00007ffff6de8e8c in gdk_x11_gl_context_end_frame
        (context=0x32f8650 [GdkX11GLContext], painted=0x372ee50, damage=<optimized out>)
        at ../gtk/gdk/x11/gdkglcontext-x11.c:263
    #15 0x00007ffff6da4f6d in gdk_gl_context_end_frame
        (damage=0x0, painted=0x372ee50, context=0x32f8650 [GdkX11GLContext])
        at ../gtk/gdk/gdkglcontext.c:396
    #16 gdk_window_end_paint_internal (window=window@entry=0x3037a50 [GdkX11Window])
        at ../gtk/gdk/gdkwindow.c:3072
    #17 0x00007ffff6da50f7 in gdk_window_end_draw_frame
        (context=0x35bde50 [GdkDrawingContext], window=0x3037a50 [GdkX11Window])
        at ../gtk/gdk/gdkwindow.c:3311
    #18 gdk_window_end_draw_frame
        (window=0x3037a50 [GdkX11Window], context=0x35bde50 [GdkDrawingContext])
        at ../gtk/gdk/gdkwindow.c:3294
    #19 0x00007fffd782938e in GDKOpenGL::render (this=0x30134b0, userData=0x0)
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