Skip to content

OSX backend crashes processing IME events when rendering from DisplayLink #5940

Open
@TheMostDiligent

Description

Version/Branch of Dear ImGui:

Version: 1.89.1
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_osx.mm + custom
Compiler: AppleClang 13.1.6.13160021 (XCode 13.4)
Operating System: MacOS (M1, arm64)

My Issue/Question:

When using DisplayLink, render commands are called from a separate thread that does not allow processing input events. In current implementation, however, ImGui::Render calls ImGui::EndFrame that eventually calls this callback which results in crash:

    io.SetPlatformImeDataFn = [](ImGuiViewport* viewport, ImGuiPlatformImeData* data) -> void
    {
        ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
        if (data->WantVisible)
        {
            [bd->InputContext activate]; <- Crash here
        }
        else
        {
            [bd->InputContext discardMarkedText];
            [bd->InputContext invalidateCharacterCoordinates];
            [bd->InputContext deactivate];
        }
        [bd->KeyEventResponder setImePosX:data->InputPos.x imePosY:data->InputPos.y + data->InputLineHeight];
    };

As an additional note, it would be really nice if there still was an option to handle OSX events manually.

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions