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

Unable to load local directory on Mac OSX #9

Open
Chadius opened this issue Nov 12, 2024 · 5 comments
Open

Unable to load local directory on Mac OSX #9

Chadius opened this issue Nov 12, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Chadius
Copy link

Chadius commented Nov 12, 2024

Environment: Mac OSX 15.1
Browser: Safari, Firefox, Chrome

When I click "Select Local Images" the app crashes.

Network tab says it's trying to make a POST call to "/select_directory", but the request is getting blocked on my end. I think this is a CORS issue where localhost will block other localhost calls.

The browser error looks like this:

    <anonymous> http://localhost:5000/:362
    (Async: promise callback)
    <anonymous> http://localhost:5000/:361

Here's my terminal output.

 * Serving Flask app 'app'
 * Debug mode: off
INFO:werkzeug:WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
INFO:werkzeug:Press CTRL+C to quit
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET / HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /static/style.css HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /static/click.mp3 HTTP/1.1" 206 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /get_images HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /get_rankings HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /serve_image?path=static/images/40e0ab70-0c75-4634-ab8f-1157699f3f8c.jpg HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /serve_image?path=static/images/45e6ea01-257e-4ed0-95e9-7620eb360772.jpg HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /get_current_directory HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /favicon.ico HTTP/1.1" 404 -
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow should only be instantiated on the main thread!'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000018799cec0 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x0000000187482cd8 objc_exception_throw + 88
	2   CoreFoundation                      0x00000001879c154c _CFBundleGetValueForInfoKey + 0
	3   AppKit                              0x000000018b47e6f4 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 260
	4   AppKit                              0x000000018b47e5e4 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 48
	5   libtk8.6.dylib                      0x0000000102c71ba4 TkMacOSXMakeRealWindowExist + 564
	6   libtk8.6.dylib                      0x0000000102c717f0 TkWmMapWindow + 76
	7   libtk8.6.dylib                      0x0000000102bce588 MapFrame + 76
	8   libtcl8.6.dylib                     0x0000000102f9b1a0 TclServiceIdle + 88
	9   libtcl8.6.dylib                     0x0000000102f7b09c Tcl_DoOneEvent + 120
	10  libtk8.6.dylib                      0x0000000102c629c8 TkpInit + 800
	11  libtk8.6.dylib                      0x0000000102bc6f20 Initialize + 2500
	12  _tkinter.cpython-312-darwin.so      0x0000000101b2a1b8 Tcl_AppInit + 92
	13  _tkinter.cpython-312-darwin.so      0x0000000101b29e08 Tkapp_New + 668
	14  _tkinter.cpython-312-darwin.so      0x0000000101b29b68 _tkinter_create_impl + 268
	15  _tkinter.cpython-312-darwin.so      0x0000000101b297e8 _tkinter_create + 276
	16  python3.12                          0x00000001003e29ac cfunction_vectorcall_FASTCALL + 96
	17  python3.12                          0x00000001004eb670 _PyEval_EvalFrameDefault + 221860
	18  python3.12                          0x00000001004125f0 slot_tp_init + 328
	19  python3.12                          0x0000000100406858 type_call + 148
	20  python3.12                          0x00000001004eba10 _PyEval_EvalFrameDefault + 222788
	21  python3.12                          0x000000010037f900 method_vectorcall + 368
	22  python3.12                          0x00000001005f7944 thread_run + 156
	23  python3.12                          0x0000000100577cfc pythread_wrapper + 48
	24  libsystem_pthread.dylib             0x00000001878432e4 _pthread_start + 136
	25  libsystem_pthread.dylib             0x000000018783e0fc thread_start + 8
)
libc++abi: terminating due to uncaught exception of type NSException
[1]    87579 abort      python app.py

I feel the solution is to configure the call to select_directory so it passes CORS restrictions but I'm not completely sure on how to do that.

@QuentinWach
Copy link
Owner

I can't debug or test this right now but I was aware that there might be issues with the threading. I hope to get a Mac this week and will then see what I can do. Thank you for letting me know, @Chadius.

@Chadius
Copy link
Author

Chadius commented Nov 12, 2024

Thanks for taking a look. I double checked and it does work on WIndows Firefox. I'm usually on my Macbook. The interface is really nice.

@QuentinWach QuentinWach added the bug Something isn't working label Nov 14, 2024
@QuentinWach
Copy link
Owner

It should indeed work well on Windows as I programmed on Windows up until now. But I now have a Mac again as well and got the same error. WIP.

@QuentinWach
Copy link
Owner

@Chadius - I can't seem to find the time right now to thoroughly test the new version I wrote that seems to be a fix to this issue. But I encourage you and anyone having this issue with Image Ranker on MacOS to try out the branch MacOS Test Branch.

@Chadius
Copy link
Author

Chadius commented Nov 29, 2024

Thanks for the update. This is working for me in Firefox, Chrome and Safari. Thank you for looking into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@Chadius @QuentinWach and others