rchartra / NcCut

A GUI for visualizing and transecting 3D data.
https://nccut.readthedocs.io/en/latest/
4 stars 2 forks source link

App crashes on FileChooser with pyobjus/type_enc.pxi IndexError: list index out of range #43

Open platipodium opened 3 weeks ago

platipodium commented 3 weeks ago

Related to #21 and https://github.com/openjournals/joss-reviews/issues/7185

On Mac M1 in conda/py-312/nccut46 environment hitting the FileChooser Dialog "Browse" results in an app crash.

Here's the log

   File "/opt/conda/envs/nccut/lib/python3.12/site-packages/kivy/lang/builder.py", line 60, in custom_callback
     exec(__kvlang__.co_value, idmap)
   File "/opt/conda/envs/nccut/lib/python3.12/site-packages/nccut/nccut.kv", line 418, in <module>
     on_press: root.browse()
 ^
   File "/opt/conda/envs/nccut/lib/python3.12/site-packages/nccut/homescreen.py", line 184, in browse
     files = filechooser.open_file(filters=[["Valid Files", "*.png", "*.jpg", "*.jpeg", "*.nc"]])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/opt/conda/envs/nccut/lib/python3.12/site-packages/plyer/facades/filechooser.py", line 54, in open_file
     return self._file_selection_dialog(mode="open", *args, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/opt/conda/envs/nccut/lib/python3.12/site-packages/plyer/platforms/macosx/filechooser.py", line 122, in _file_selection_dialog
     return MacFileChooser(**kwargs).run()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/opt/conda/envs/nccut/lib/python3.12/site-packages/plyer/platforms/macosx/filechooser.py", line 59, in run
     panel = NSOpenPanel.openPanel()
             ^^^^^^^^^^^^^^^^^^^^^^^
   File "pyobjus/pyobjus.pyx", line 504, in pyobjus.ObjcMethod.__call__
   File "pyobjus/pyobjus_conversions.pxi", line 240, in pyobjus.convert_cy_ret_to_py
   File "pyobjus/pyobjus_conversions.pxi", line 181, in pyobjus.convert_to_cy_cls_instance
   File "pyobjus/pyobjus.pyx", line 741, in pyobjus.autoclass
   File "pyobjus/pyobjus.pyx", line 627, in pyobjus.resolve_super_class_methods
   File "pyobjus/pyobjus.pyx", line 543, in pyobjus.class_get_methods
   File "pyobjus/pyobjus.pyx", line 535, in pyobjus.objc_method_to_py
   File "pyobjus/pyobjus.pyx", line 244, in pyobjus.ObjcMethod.__init__
   File "pyobjus/type_enc.pxi", line 13, in pyobjus.parse_signature
   File "pyobjus/type_enc.pxi", line 2, in pyobjus.seperate_encoding
 IndexError: list index out of range
rchartra commented 5 days ago

I've looked into this issue and it seems to be a bug with the file selection widget from Kivy on MacOS (see here). It seems it's been fixed but not released and I don't think they are planning on doing a release any time soon unfortunately. The FileChooser works fine on the Macs I have access to so I'm hoping I can figure out what the difference is. Otherwise there's other python UI frameworks that provide file selection functionality but I was running into issues with those before as mixing frameworks is generally not well supported.

For now I will add an error popup so at least the app won't crash and the user can still type in the file path manually.

platipodium commented 5 days ago

I am happy with a temporary fix; that way, I can continue testing your software. For now, this is a showstopper also for my review, I'm afraid.

rchartra commented 5 days ago

Sounds good, I'll let you know when it's in place.