Opened 5 years ago

Closed 3 years ago

Last modified 3 years ago

#5470 closed defect (fixed)

[ATLASUI] Main Thread Checker: UI API called on a background thread: -[NSView initWithFrame:]

Reported by: trompetin17 Owned by: trompetin17
Priority: Should Have Milestone: Alpha 24
Component: Atlas editor Keywords:
Cc: Patch: Phab:D2019

Description

As a developer, every time you try to run in debug mode over osx with xcode, in the output are showing a lot of warning and additionally AtlasUI appears without menu.

The log show this:
TIMER| LoadDLL: 624.501 ms
TIMER| InitVfs: 5.214 ms
Writing the mainlog at /mainlog.html
TIMER| CONFIG_Init: 14.462 ms
Sound: AlcInit success, using Built-in Output
TIMER| shutdown ConfigDB: 1 us
TIMER| resource modules: 531.619 ms
TIMER TOTALS (9 clients)
-----------------------------------------------------
  tc_png_decode: 0 c (0x)
  tc_dds_transform: 0 c (0x)
  tc_transform: 0 c (0x)
  tc_plain_transform: 0 c (0x)
  tc_pool_alloc: 0 c (0x)
  tc_ShaderGLSLLink: 0 c (0x)
  tc_ShaderGLSLCompile: 0 c (0x)
  tc_ShaderValidation: 0 c (0x)
  xml_validation: 0 c (0x)
-----------------------------------------------------
TIMER| shutdown misc: 2.837 ms
TIMER| InitVfs: 6.254 ms
Writing the mainlog at /mainlog.html
TIMER| CONFIG_Init: 13.328 ms
Sound: AlcInit success, using Built-in Output
2019-06-27 11:18:31.411996-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.422715-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.422743-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.422754-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.422773-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.422828-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.422857-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.422879-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.422891-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.422900-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.426154-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.426182-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.426192-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.426208-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.426220-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.428689-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.428720-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-06-27 11:18:31.428745-0500 pyrogenesis_dbg[2120:69494] pid(2120)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
=================================================================
Main Thread Checker: UI API called on a background thread: -[NSView initWithFrame:]
PID: 2120, TID: 69494, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   pyrogenesis_dbg                     0x00000001001372f9 Cocoa_StartTextInput + 265
5   pyrogenesis_dbg                     0x000000010012b678 SDL_StartTextInput_REAL + 184
6   pyrogenesis_dbg                     0x000000010012a7bf SDL_VideoInit_REAL + 895
7   pyrogenesis_dbg                     0x000000010001834d SDL_InitSubSystem_REAL + 317
8   pyrogenesis_dbg                     0x000000010005f4d7 SDL_InitSubSystem + 23
9   pyrogenesis_dbg                     0x00000001023bbdb4 _ZN12AtlasMessage8fInitSDLEPNS_8mInitSDLE + 36
10  pyrogenesis_dbg                     0x00000001023bbd65 _ZN12AtlasMessage16fInitSDL_wrapperEPNS_8IMessageE + 165
11  pyrogenesis_dbg                     0x000000010237e91a _ZL9RunEnginePv + 1210
12  libsystem_pthread.dylib             0x0000000108397dc3 _pthread_body + 126
13  libsystem_pthread.dylib             0x000000010839ae8d _pthread_start + 66
14  libsystem_pthread.dylib             0x0000000108396e11 thread_start + 13
2019-06-27 11:18:31.461298-0500 pyrogenesis_dbg[2120:69494] [reports] Main Thread Checker: UI API called on a background thread: -[NSView initWithFrame:]
PID: 2120, TID: 69494, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   pyrogenesis_dbg                     0x00000001001372f9 Cocoa_StartTextInput + 265
5   pyrogenesis_dbg                     0x000000010012b678 SDL_StartTextInput_REAL + 184
6   pyrogenesis_dbg                     0x000000010012a7bf SDL_VideoInit_REAL + 895
7   pyrogenesis_dbg                     0x000000010001834d SDL_InitSubSystem_REAL + 317
8   pyrogenesis_dbg                     0x000000010005f4d7 SDL_InitSubSystem + 23
9   pyrogenesis_dbg                     0x00000001023bbdb4 _ZN12AtlasMessage8fInitSDLEPNS_8mInitSDLE + 36
10  pyrogenesis_dbg                     0x00000001023bbd65 _ZN12AtlasMessage16fInitSDL_wrapperEPNS_8IMessageE + 165
11  pyrogenesis_dbg                     0x000000010237e91a _ZL9RunEnginePv + 1210
12  libsystem_pthread.dylib             0x0000000108397dc3 _pthread_body + 126
13  libsystem_pthread.dylib             0x000000010839ae8d _pthread_start + 66
14  libsystem_pthread.dylib             0x0000000108396e11 thread_start + 13
=================================================================
Main Thread Checker: UI API called on a background thread: -[NSView superview]
PID: 2120, TID: 69494, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   pyrogenesis_dbg                     0x0000000100137319 Cocoa_StartTextInput + 297
5   pyrogenesis_dbg                     0x000000010012b678 SDL_StartTextInput_REAL + 184
6   pyrogenesis_dbg                     0x000000010012a7bf SDL_VideoInit_REAL + 895
7   pyrogenesis_dbg                     0x000000010001834d SDL_InitSubSystem_REAL + 317
8   pyrogenesis_dbg                     0x000000010005f4d7 SDL_InitSubSystem + 23
9   pyrogenesis_dbg                     0x00000001023bbdb4 _ZN12AtlasMessage8fInitSDLEPNS_8mInitSDLE + 36
10  pyrogenesis_dbg                     0x00000001023bbd65 _ZN12AtlasMessage16fInitSDL_wrapperEPNS_8IMessageE + 165
11  pyrogenesis_dbg                     0x000000010237e91a _ZL9RunEnginePv + 1210
12  libsystem_pthread.dylib             0x0000000108397dc3 _pthread_body + 126
13  libsystem_pthread.dylib             0x000000010839ae8d _pthread_start + 66
14  libsystem_pthread.dylib             0x0000000108396e11 thread_start + 13
2019-06-27 11:18:31.553988-0500 pyrogenesis_dbg[2120:69494] [reports] Main Thread Checker: UI API called on a background thread: -[NSView superview]
PID: 2120, TID: 69494, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   pyrogenesis_dbg                     0x0000000100137319 Cocoa_StartTextInput + 297
5   pyrogenesis_dbg                     0x000000010012b678 SDL_StartTextInput_REAL + 184
6   pyrogenesis_dbg                     0x000000010012a7bf SDL_VideoInit_REAL + 895
7   pyrogenesis_dbg                     0x000000010001834d SDL_InitSubSystem_REAL + 317
8   pyrogenesis_dbg                     0x000000010005f4d7 SDL_InitSubSystem + 23
9   pyrogenesis_dbg                     0x00000001023bbdb4 _ZN12AtlasMessage8fInitSDLEPNS_8mInitSDLE + 36
10  pyrogenesis_dbg                     0x00000001023bbd65 _ZN12AtlasMessage16fInitSDL_wrapperEPNS_8IMessageE + 165
11  pyrogenesis_dbg                     0x000000010237e91a _ZL9RunEnginePv + 1210
12  libsystem_pthread.dylib             0x0000000108397dc3 _pthread_body + 126
13  libsystem_pthread.dylib             0x000000010839ae8d _pthread_start + 66
14  libsystem_pthread.dylib             0x0000000108396e11 thread_start + 13
=================================================================
Main Thread Checker: UI API called on a background thread: -[NSView removeFromSuperview]
PID: 2120, TID: 69494, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   pyrogenesis_dbg                     0x0000000100137360 Cocoa_StartTextInput + 368
5   pyrogenesis_dbg                     0x000000010012b678 SDL_StartTextInput_REAL + 184
6   pyrogenesis_dbg                     0x000000010012a7bf SDL_VideoInit_REAL + 895
7   pyrogenesis_dbg                     0x000000010001834d SDL_InitSubSystem_REAL + 317
8   pyrogenesis_dbg                     0x000000010005f4d7 SDL_InitSubSystem + 23
9   pyrogenesis_dbg                     0x00000001023bbdb4 _ZN12AtlasMessage8fInitSDLEPNS_8mInitSDLE + 36
10  pyrogenesis_dbg                     0x00000001023bbd65 _ZN12AtlasMessage16fInitSDL_wrapperEPNS_8IMessageE + 165
11  pyrogenesis_dbg                     0x000000010237e91a _ZL9RunEnginePv + 1210
12  libsystem_pthread.dylib             0x0000000108397dc3 _pthread_body + 126
13  libsystem_pthread.dylib             0x000000010839ae8d _pthread_start + 66
14  libsystem_pthread.dylib             0x0000000108396e11 thread_start + 13
2019-06-27 11:18:31.777251-0500 pyrogenesis_dbg[2120:69494] [reports] Main Thread Checker: UI API called on a background thread: -[NSView removeFromSuperview]
PID: 2120, TID: 69494, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   pyrogenesis_dbg                     0x0000000100137360 Cocoa_StartTextInput + 368
5   pyrogenesis_dbg                     0x000000010012b678 SDL_StartTextInput_REAL + 184
6   pyrogenesis_dbg                     0x000000010012a7bf SDL_VideoInit_REAL + 895
7   pyrogenesis_dbg                     0x000000010001834d SDL_InitSubSystem_REAL + 317
8   pyrogenesis_dbg                     0x000000010005f4d7 SDL_InitSubSystem + 23
9   pyrogenesis_dbg                     0x00000001023bbdb4 _ZN12AtlasMessage8fInitSDLEPNS_8mInitSDLE + 36
10  pyrogenesis_dbg                     0x00000001023bbd65 _ZN12AtlasMessage16fInitSDL_wrapperEPNS_8IMessageE + 165
11  pyrogenesis_dbg                     0x000000010237e91a _ZL9RunEnginePv + 1210
12  libsystem_pthread.dylib             0x0000000108397dc3 _pthread_body + 126
13  libsystem_pthread.dylib             0x000000010839ae8d _pthread_start + 66
14  libsystem_pthread.dylib             0x0000000108396e11 thread_start + 13
APIC: not unique
UserReport written to userreport_hwdetect.txt
TIMER| RunHardwareDetection: 56.391 ms
TIMER| InitRenderer: 7.025 ms
TIMER| ps_console: 8.167 ms
TIMER| ps_lang_hotkeys: 7.152 ms
GAME STARTED, ALL INIT COMPLETE
2019-06-27 11:18:38.505498-0500 pyrogenesis_dbg[2120:69619] flock failed to lock maps file: errno = 35
2019-06-27 11:18:38.563963-0500 pyrogenesis_dbg[2120:69619] flock failed to lock maps file: errno = 35
2019-06-27 11:18:39.157609-0500 pyrogenesis_dbg[2120:69119] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=2120
2019-06-27 11:18:39.157682-0500 pyrogenesis_dbg[2120:69119] SecTaskCopyDebugDescription: pyrogenesis_dbg[2120]/0#-1 LF=0

Following the message I found the warning is happen in this line: GraphicsSetupHandler.cpp

MESSAGEHANDLER(InitSDL)
{
	UNUSED2(msg);

	// When using GLX (Linux), SDL has to load the GL library to find
	// glXGetProcAddressARB before it can load any extensions.
	// When running in Atlas, we skip the SDL video initialisation code
	// which loads the library, and so SDL_GL_GetProcAddress fails (in
	// ogl.cpp importExtensionFunctions).
	// (TODO: I think this is meant to be context-independent, i.e. it
	// doesn't matter that we're getting extensions from SDL-initialised
	// GL stuff instead of from the wxWidgets-initialised GL stuff, but that
	// should be checked.)
	// So, make sure it's loaded:
	SDL_InitSubSystem(SDL_INIT_VIDEO);
	SDL_GL_LoadLibrary(NULL); // NULL = use default
	// (it shouldn't hurt if this is called multiple times, I think)
}

When SDL_InitSubSystem was called, and when I see threads window I see that this method is called in another thread (please refer to image)

And also atlasUI doesn't have a menu (please refer to image)

Attachments (3)

Screen Shot 2019-06-27 at 11.26.59 AM.png (1.7 MB ) - added by trompetin17 5 years ago.
atlas no menu osx
Screen Shot 2019-06-27 at 11.24.38 AM.png (649.6 KB ) - added by trompetin17 5 years ago.
thread evidence
Screen Shot 2019-06-27 at 11.23.34 AM.png (233.8 KB ) - added by trompetin17 5 years ago.
Warning Evidence

Change History (8)

by trompetin17, 5 years ago

atlas no menu osx

by trompetin17, 5 years ago

thread evidence

by trompetin17, 5 years ago

Warning Evidence

comment:1 by trompetin17, 5 years ago

Owner: set to trompetin17
Patch: D2019

comment:2 by trompetin17, 5 years ago

Patch: D2019Phab:D2019

comment:3 by trompetin17, 5 years ago

Adding documentation https://developer.apple.com/documentation/code_diagnostics/main_thread_checker

Looks like from stacktrace that sdl2 call Cocoa_StartTextInput, and appear that Input is a UI, so that's why the warning show us,

if anybody has another good explanation let us know

comment:4 by wraitii, 3 years ago

Resolution: fixed
Status: newclosed

In 24361:

Remove the Engine threading when using Atlas

MacOS requires some UI-related API calls to happen on the main thread. There are several SDL functions that call UI-things, and those were, since #500 / r10299, in a separate thread.
This crashes on Catalina, instead of simply warning (see #5470).

It is not the first time we had such issues, as originally the Engine was on the main thread and AtlasUI on a separate thread.
That didn't work on MacOS, so the threading was inverted in #500 / r10299, with AtlasUI on the main thread and the Engine in another thread.
Unfortunately, this still wasn't enough.

This formally unthreads the engine, running it on a wxTimer, to avoid these issues.

Future work should focus on:

  • Further decoupling the simulation from the engine itself, as what Atlas really needs is a threaded simulation, not a threaded engine.
  • Making the simulation itself more threaded
  • Making it possible to do tasks asynchronously under Atlas.

Refs #500
Fixes #5470

Differential Revision: https://code.wildfiregames.com/D2752

comment:5 by Stan, 3 years ago

Milestone: BacklogAlpha 24
Note: See TracTickets for help on using tickets.