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

SDL_StopTextInput crashes on macOS when called from another thread #11447

Open
squidbus opened this issue Nov 11, 2024 · 0 comments
Open

SDL_StopTextInput crashes on macOS when called from another thread #11447

squidbus opened this issue Nov 11, 2024 · 0 comments
Milestone

Comments

@squidbus
Copy link

Using SDL 3, calling SDL_StopTextInput from another thread causes the following crash on macOS:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[HIRunLoopSemaphore wait:] has been invoked on a secondary thread; the problem is likely in a much shallower frame in the backtrace'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007ff808cc6f4e __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007ff8087b0f12 objc_exception_throw + 62
	2   Foundation                          0x00007ff809ca6c41 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 362
	3   HIServices                          0x00007ff80f4d993a -[HIRunLoopSemaphore wait:] + 400
	4   HIToolbox                           0x00007ff814884580 __62-[IMKInputSessionXPCInvocation_Modern invocationAwaitXPCReply]_block_invoke + 100
	5   HIToolbox                           0x00007ff8148850fc +[IMKInputSession_Modern withActivity:performActions:] + 934
	6   HIToolbox                           0x00007ff814886a56 -[IMKInputSession_Modern deactivate] + 1118
	7   HIToolbox                           0x00007ff814816180 IMKInputSessionDeactivate + 36
	8   HIToolbox                           0x00007ff81481567a DeactivateInputMethodInstance + 58
	9   HIToolbox                           0x00007ff8147ffd88 utDeactivateAllSelectedIMInDocIterator + 82
	10  CoreFoundation                      0x00007ff808c1aba8 CFArrayApplyFunction + 62
	11  HIToolbox                           0x00007ff8147ffd27 utDeactivateAllSelectedIMInDoc + 132
	12  HIToolbox                           0x00007ff8147fb25f MyDeactivateTSMDocument + 381
	13  HIToolbox                           0x00007ff8147fb399 DeactivateTSMDocument + 75
	14  AppKit                              0x00007ff80c6b6c02 -[NSTextInputContext deactivate] + 246
	15  AppKit                              0x00007ff80c4dff2d +[NSTextInputContext currentInputContext_withFirstResponderSync:] + 357
	16  AppKit                              0x00007ff80c4f107b -[NSView _setWindow:] + 711
	17  AppKit                              0x00007ff80c51c774 -[NSView removeFromSuperview] + 212
	18  shadps4                             0x0000020000a41d0f Cocoa_StopTextInput + 127
	19  shadps4                             0x0000020000a01c7b SDL_StopTextInput_REAL + 75
	20  shadps4                             0x0000020000013974 _ZN5ImGui3SdlL18PlatformSetImeDataEP12ImGuiContextP13ImGuiViewportP20ImGuiPlatformImeData + 84
	21  shadps4                             0x00000200006c5795 _ZN5ImGui8EndFrameEv + 597
	22  shadps4                             0x00000200006c70d7 _ZN5ImGui6RenderEv + 55
	23  shadps4                             0x0000020000010d59 _ZN5ImGui4Core6RenderERKN2vk13CommandBufferEPN6Vulkan5FrameE + 41
	24  shadps4                             0x00000200005f75dc _ZN6Vulkan14RendererVulkan7PresentEPNS_5FrameE + 156
	25  shadps4                             0x00000200004279cf _ZN9Libraries8VideoOut14VideoOutDriver4FlipERKNS1_7RequestE + 47
	26  shadps4                             0x000002000042840b _ZN9Libraries8VideoOut14VideoOutDriver13PresentThreadENSt3__110stop_tokenE + 379
	27  shadps4                             0x00000200004291a1 _ZNSt3__114__thread_proxyB8ne180100INS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEZN9Libraries8VideoOut14VideoOutDriverC1EjjE3$_0NS_10stop_tokenEEEEEEPvSD_ + 81
	28  libsystem_pthread.dylib             0x00007ff808b73253 _pthread_start + 99
	29  libsystem_pthread.dylib             0x00007ff808b6ebef thread_start + 15
)
libc++abi: terminating due to uncaught exception of type NSException

Would like to ask for one of the following:

  • For SDL to handle dispatching the appropriate calls to the main thread to avoid these issues.
  • For SDL to document that this function (and possibly related input functions) should be called from the main thread.
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