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

MacOS runtime warnings regarding access of NSView/NSWindow properties from a non-main thread #7393

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Commits on Mar 12, 2024

  1. Resolve Xcode runtime warnings regarding access of NSView/NSWindow pr…

    …operties from a non-main thread
    
    This issue presents when rendering from a thread that is other than the window thread, more easily reproduced when disabling vsync
    
    This commit aims to populate the relevant data into backend_data, by way of dispatch_async (ocurring on the main thread). Those particular backend data items are protected by an NSlock
    
    There may be more elegant ways to do this
    
    Main Thread Checker
    imgui/backends/imgui_impl_osx.mm:608 -[NSView window] must be used from main thread only
    imgui/backends/imgui_impl_osx.mm:608 -[NSWindow backingScaleFactor] must be used from main thread only
    imgui/backends/imgui_impl_osx.mm:609 -[NSView bounds] must be used from main thread only
    tim-rex committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    bda15db View commit details
    Browse the repository at this point in the history
  2. Resolve Xcode runtime warnings regarding access of NSView/NSWindow pr…

    …operties from a non-main thread
    
    This issue presents when rendering from a thread that is other than the window thread, more easily reproduced when disabling vsync
    
    This commit aims to populate the relevant data into backend_data, by way of dispatch_async (ocurring on the main thread). Those particular backend data items are protected by an NSlock
    
    There may be more elegant ways to do this
    
    Main Thread Checker
    imgui/backends/imgui_impl_osx.mm:608 -[NSView window] must be used from main thread only
    imgui/backends/imgui_impl_osx.mm:608 -[NSWindow backingScaleFactor] must be used from main thread only
    imgui/backends/imgui_impl_osx.mm:609 -[NSView bounds] must be used from main thread only
    tim-rex committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    1a11a31 View commit details
    Browse the repository at this point in the history

Commits on Mar 14, 2024

  1. Needed a little more work to resolve a number of outstanding thread s…

    …anitiser concerns
    
    This is a little nasty..
    I'm trying to keep all changes localised to imgui_impl_osx.mm
    
    Ideally the ImGui_IO_lock would live within ImGuiIO but I didn't want to muddy the waters
    
    Perhaps better if this lock primitive is delivered through BackendPlatformUserData, and only used where provided
    
    This change requires the client platform to explicitly lock the primitive from outside of ImGui around ImGui::NewFrame specifically, and additionally from anywhere on the client side (external to ImGui) that concurrently hooks into ImGuiIO
    
    That requires the client to define an extern lock (and use it appropriately)
     extern NSlock *ImGui_IO_lock
    
    If this lock were native to ImGui we could have ImGui::NewFrame() handle the lock on our behalf, negating the need for client side locking
    tim-rex committed Mar 14, 2024
    Configuration menu
    Copy the full SHA
    c0623e9 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a30bc7e View commit details
    Browse the repository at this point in the history
  3. Revert unnecessary cruft

    tim-rex committed Mar 14, 2024
    Configuration menu
    Copy the full SHA
    7360718 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    756feb8 View commit details
    Browse the repository at this point in the history