EvilSupahFly / Amulet-Flatpak

Amulet Flatpak Project
https://github.com/Amulet-Team/Amulet-Map-Editor
GNU General Public License v3.0
1 stars 0 forks source link

3D map editor unusable #2

Closed UltraBlackLinux closed 2 weeks ago

UltraBlackLinux commented 1 month ago

whenever I try to open a map with the 3D map editor, I get this:

CRITICAL - NotImplementedError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/lib/python3.11/site-packages/amulet_map_editor/api/framework/pages/world_page.py", line 178, in _enable_page
    self.GetPage(page).enable()
  File "/app/lib/python3.11/site-packages/amulet_map_editor/programs/edit/edit.py", line 69, in enable
    self._canvas = EditCanvas(self, self._world)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/amulet_map_editor/programs/edit/api/canvas/edit_canvas.py", line 150, in __init__
    super().__init__(parent, world)
  File "/app/lib/python3.11/site-packages/amulet_map_editor/programs/edit/api/canvas/base_edit_canvas.py", line 63, in __init__
    super().__init__(parent)
  File "/app/lib/python3.11/site-packages/amulet_map_editor/api/opengl/canvas/event_canvas.py", line 15, in __init__
    super().__init__(parent)
  File "/app/lib/python3.11/site-packages/amulet_map_editor/api/opengl/canvas/canvas.py", line 41, in __init__
    display_attributes = GLAttributes()
                         ^^^^^^^^^^^^^^
SystemError: <class 'wx._glcanvas.GLAttributes'> returned a result with an exception set

Really no idea why I get this, but I hope you can fix that ;) Thanks!

EvilSupahFly commented 1 month ago

Looks like I need to do more testing when I get home. I was using a virtual machine for testing different distributions, but I think I'll have to switch to physical machines. What version of Linux are you running, and what's your video card?

EvilSupahFly commented 1 month ago

I believe #1 is related as it looks like the FreeGLUT libraries and headers didn't get bundled when testing on the VMs. Once this is resolved, I'll do some independent testing outside of VMs on a couple of spare rigs I'm installing different distros on and we'll go from there.

UltraBlackLinux commented 1 month ago

What version of Linux are you running, and what's your video card?

Arch Linux, RX 6700XT, linux-lts in case it matters

EvilSupahFly commented 1 month ago

Well, I thought it might make a difference, and I made a bunch of changes, but it's still crashing.

See my pastebin log here if you're curious.

gentlegiantJGC commented 1 month ago

This post seems to imply it is an issue with error handling in wxPython. https://stackoverflow.com/questions/53796264/systemerror-class-int-returned-a-result-with-an-error-set-in-python

Here are the relevant source files that I can find. I don't see anything that would error. I can't even find the constructor.

https://github.com/wxWidgets/wxWidgets/blob/9e1b62779757a83acd75304e7c3defb40bd6a99a/interface/wx/glcanvas.h#L246 https://github.com/wxWidgets/wxWidgets/blob/9e1b62779757a83acd75304e7c3defb40bd6a99a/include/wx/glcanvas.h#L155

https://github.com/wxWidgets/wxWidgets/blob/9e1b62779757a83acd75304e7c3defb40bd6a99a/src/unix/glegl.cpp#L147 https://github.com/wxWidgets/wxWidgets/blob/9e1b62779757a83acd75304e7c3defb40bd6a99a/src/msw/glcanvas.cpp#L440 https://github.com/wxWidgets/wxWidgets/blob/9e1b62779757a83acd75304e7c3defb40bd6a99a/src/unix/glx11.cpp#L360 https://github.com/wxWidgets/wxWidgets/blob/9e1b62779757a83acd75304e7c3defb40bd6a99a/src/osx/glcanvas_osx.cpp#L262 https://github.com/wxWidgets/wxWidgets/blob/9e1b62779757a83acd75304e7c3defb40bd6a99a/src/qt/glcanvas.cpp#L262

Here is the base class https://github.com/wxWidgets/wxWidgets/blob/9e1b62779757a83acd75304e7c3defb40bd6a99a/include/wx/glcanvas.h#L71

gentlegiantJGC commented 1 month ago

Looks like an implicit constructor. I still don't know what in the C++ code would be causing an error. It is just initialising a vector and bool.

EvilSupahFly commented 1 month ago

I think it's related to the OpenGL implementation inside Flatpak sandboxes. I'm trying something different when I get home today, and we'll see what happens. Evidently, they've discontinued and replaced the OpenGL.Default call which is supposed to give you access to the default rendering device.

EvilSupahFly commented 1 month ago

Or perhaps not? The Flatpak builder uses PIP to grab Amulet and all it's assorted dependencies, so I created a new VENV and installed Amulet with PIP myself, and it fails to run (see https://github.com/Amulet-Team/Amulet-Map-Editor/issues/1093), so now I don't know. I'll make a clean VENV and try running Amulet's setup.py for comparison to see what's different.

gentlegiantJGC commented 1 month ago

I did tweak the opengl initialisation recently so I may have broken something. The missing symbol error is definitely not an issue with Amulet

EvilSupahFly commented 4 weeks ago

I have a post open on the wxPython forums to try and get to the bottom of this, and I'll update this as information is made available.

EvilSupahFly commented 4 weeks ago

So, I got Amulet to run from a PIP install by changing the version of Python running it, then checked the modules PIP installed with Amulet (I haven't installed anything else in this VENV):

(amulet-py-319) evilsupahfly on Black-Beast at Thu 15 Aug 2024 18:04:37 EDT
[~/Downloads/Python/Python-3.9.19] python --version
Python 3.9.19
(amulet-py-319) evilsupahfly on Black-Beast at Thu 15 Aug 2024 18:08:58 EDT
[~/Downloads/Python/Python-3.9.19] pip list
Package                 Version
----------------------- -------
amulet-core             1.9.25
amulet-leveldb          1.0.2
amulet-map-editor       0.10.35
amulet-nbt              2.1.3
lz4                     4.3.3
minecraft-resource-pack 1.4.3
mutf8                   1.0.6
numpy                   1.26.4
packaging               24.1
pillow                  10.4.0
pip                     24.2
platformdirs            3.11.0
portalocker             2.10.1
PyMCTranslate           1.2.27
PyOpenGL                3.1.7
setuptools              58.1.0
six                     1.16.0
wxPython                4.2.1

So, I'm going to try rebuilding the Flatpak using these specific packages and versions and see what happens.

EvilSupahFly commented 4 weeks ago

Installing Amulet with PIP in Python 3.11.9 (which is what Flatpak uses) and running after install: No problems

Screenshot from 2024-08-15 23-04-29

I did have to tweak requirements.txt in order to fix several "Module [blah] not found" errors, but having resolved those, it's now building the flatpack on my test machine as I type this, so I will hopefully have a useable flatpak in the morning.

EvilSupahFly commented 4 weeks ago

The Flatpak still crashes, so I'm going try using the 22.08 version of the SDK, instead of the 23.08 because it uses an older version of Python. I also feel like my OpenGL implementation is somehow incomplete even though according to the official documentation, I should only need to include --device=dri since Amulet already has OpenGL implementations included. Something is being lost in translation and I feel like it's related to the sandboxing inside the Flatpak environment.

EvilSupahFly commented 4 weeks ago

So, I've added some things to the recipe that I hope will future-proof updates while remaining (mostly) backwards compatible:

finish-args:
  - --env=GDK_BACKEND=x11
  - --env=GDK_BACKEND=wayland
(...)
modules:
  - name: python
    buildsystem: simple
    sources:
      - type: git
        url: https://github.com/python/cpython.git
        tag: v3.11.0
  - name: opengl
    buildsystem: cmake
    sources:
      - type: git
        url: https://github.com/KhronosGroup/OpenGL-Registry.git
        tag: master
  - name: opengl-extensions
    buildsystem: cmake
    sources:
      - type: git
        url: https://github.com/KhronosGroup/OpenGL-Extension-Registry.git
        tag: master
  - name: xapp-gtk3-module
    buildsystem: meson
    sources:
      - type: git
        url: https://github.com/linuxmint/xapp.git
        tag: master
  - name: wayland
    buildsystem: cmake
    sources:
      - type: git
        url: https://gitlab.freedesktop.org/wayland/wayland.git
        tag: master
  - name: x11
    buildsystem: meson
    sources:
      - type: git
        url: https://gitlab.freedesktop.org/xorg/lib/libx11.git
        tag: 1.7.0

I'm fairly sure it should pull the build instructions for the extra modules right from GitHub, but if it doesn't, I'll manually add them.

EvilSupahFly commented 3 weeks ago

I dunno, guys. Nothing works for me. Some changes prevent the project from even building, and when I fix those, something else breaks. Then when I get everything to stop breaking and actually give me a useable .flatpak file, I'm right back to this same irritatingly fatal error.

EvilSupahFly commented 3 weeks ago

I believe this should now be resolved per my comment at https://github.com/Amulet-Team/Amulet-Map-Editor/issues/1070 which basically boils down to me making a rookie mistake on my first major Flatpak build.

EvilSupahFly commented 2 weeks ago

OK, after a metric f_ck tonne of trial-and-error, and some solid guidance from bbhtt on Flathub Discourse, I'm reasonably certain all the issues have resolved.

Amulet Flatpak launches on Wayland, includes a "fallback" directive for X11, and properly loads Minecraft saves in the 3D editor.