Page 1 of 1

NSWindow should only be instantiated on the main thread

Posted: Fri Jun 07, 2024 10:47 am
by Clint

Hi guys,

This is my first time trying Faceswap on Apple Silicon. The extraction step was blissful; however, the training stopped immediately with this error.
I tried to find information on the forum and outside, but nothing relevant.

Any clue?

Code: Select all

Loading...
Setting Faceswap backend to APPLE_SILICON
Metal device set to: Apple M1 Max

systemMemory: 32.00 GB
maxCacheSize: 10.67 GB

06/07/2024 12:17:03 INFO     Log level set to: INFO
06/07/2024 12:17:04 INFO     Model A Directory: '/Users/user/Desktop/Final/inputA 512' (9687 images)
06/07/2024 12:17:04 INFO     Model B Directory: '/Users/user/Desktop/Final/inputB 512' (12216 images)
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow should only be instantiated on the main thread!'
*** First throw call stack:
(
0   CoreFoundation                      0x00000001898ca800 __exceptionPreprocess + 176
Process exited.1   libobjc.A.dylib                     0x00000001893c1eb4 objc_exception_throw + 60

2   CoreFoundation                      0x00000001898efb4c _CFBundleGetValueForInfoKey + 0
3   AppKit                              0x000000018d03f538 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 188
4   AppKit                              0x000000018d03f470 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 48
5   libtk8.6.dylib                      0x0000000105dd8230 TkMacOSXMakeRealWindowExist + 536
6   libtk8.6.dylib                      0x0000000105dd7e94 TkWmMapWindow + 76
7   libtk8.6.dylib                      0x0000000105d35238 MapFrame + 76
8   libtcl8.6.dylib                     0x0000000105c56dec TclServiceIdle + 88
9   libtcl8.6.dylib                     0x0000000105c371e0 Tcl_DoOneEvent + 120
10  libtk8.6.dylib                      0x0000000105dc8e80 TkpInit + 792
11  libtk8.6.dylib                      0x0000000105d2dcd0 Initialize + 2424
12  _tkinter.cpython-310-darwin.so      0x00000001059c60a4 Tkapp_New + 876
13  _tkinter.cpython-310-darwin.so      0x00000001059c5b18 _tkinter_create + 648
14  python3.10                          0x000000010500f880 cfunction_vectorcall_FASTCALL + 200
15  python3.10                          0x00000001050ad540 call_function + 524
16  python3.10                          0x00000001050a8e60 _PyEval_EvalFrameDefault + 24940
17  python3.10                          0x00000001050a2364 _PyEval_Vector + 2036
18  python3.10                          0x0000000104fbb850 _PyObject_FastCallDictTstate + 320
19  python3.10                          0x0000000104fbc454 _PyObject_Call_Prepend + 176
20  python3.10                          0x0000000105033394 slot_tp_init + 116
21  python3.10                          0x000000010502bd64 type_call + 456
22  python3.10                          0x0000000104fbb59c _PyObject_MakeTpCall + 612
23  python3.10                          0x00000001050ad5d8 call_function + 676
24  python3.10                          0x00000001050a8e60 _PyEval_EvalFrameDefault + 24940
25  python3.10                          0x00000001050a2364 _PyEval_Vector + 2036
26  python3.10                          0x0000000104fbb7ac _PyObject_FastCallDictTstate + 156
27  python3.10                          0x0000000104fbc454 _PyObject_Call_Prepend + 176
28  python3.10                          0x0000000105033394 slot_tp_init + 116
29  python3.10                          0x000000010502bd64 type_call + 456
30  python3.10                          0x0000000104fbbfb0 _PyObject_Call + 148
31  python3.10                          0x00000001050a9658 _PyEval_EvalFrameDefault + 26980
32  python3.10                          0x00000001050a2364 _PyEval_Vector + 2036
33  python3.10                          0x00000001050ad540 call_function + 524
34  python3.10                          0x00000001050a8e38 _PyEval_EvalFrameDefault + 24900
35  python3.10                          0x00000001050a2364 _PyEval_Vector + 2036
36  python3.10                          0x00000001050ad540 call_function + 524
37  python3.10                          0x00000001050a8e38 _PyEval_EvalFrameDefault + 24900
38  python3.10                          0x00000001050a2364 _PyEval_Vector + 2036
39  python3.10                          0x0000000104fbed10 method_vectorcall + 344
40  python3.10                          0x0000000105174830 thread_run + 180
41  python3.10                          0x0000000105110230 pythread_wrapper + 48
42  libsystem_pthread.dylib             0x0000000189779034 _pthread_start + 136
43  libsystem_pthread.dylib             0x0000000189773e3c thread_start + 8
)
libc++abi: terminating due to uncaught exception of type NSException


Re: NSWindow should only be instantiated on the main thread

Posted: Fri Jun 07, 2024 4:51 pm
by torzdf

Hmmm. This looks very much Apple Silicon specific. Unfortunately I do not own a Mac to be able to test/troubleshoot.

I have recently put Faceswap 3 into beta, so if you are feeling adventurous, you could test that out and see if your issue persists: viewtopic.php?t=3010


Re: NSWindow should only be instantiated on the main thread

Posted: Fri Jun 07, 2024 6:03 pm
by Clint

Thank you for your reply. I'll try the beta and continue investigating on Apple side.


Re: NSWindow should only be instantiated on the main thread

Posted: Tue Jun 11, 2024 10:58 pm
by TCGPRO

I had the same exact problem, Running M1 Pro chip.

I unchecked Preview, and it worked.


Re: NSWindow should only be instantiated on the main thread

Posted: Thu Jun 13, 2024 8:04 am
by Clint

Doesn't work either with the Beta. It seems to be Apple'side; the Main Thread Checker is enabled :
Image

I'll see if I can deactivate it (not my screenshot)