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

Crashing On Linux When Clicking "Edit" #84

Closed
EvilSupahFly opened this issue Aug 10, 2020 · 51 comments
Closed

Crashing On Linux When Clicking "Edit" #84

EvilSupahFly opened this issue Aug 10, 2020 · 51 comments
Labels
help wanted Extra attention is needed opengl an error from OpenGL code OS: Linux type: bug Something isn't working

Comments

@EvilSupahFly
Copy link

I'm running Amulet on Linux Mint 20 (based on Ubuntu, which is itself a Debian derivative).

I cloned the latest release of Amulet with GIT, installed the dependencies without a problem, and I'm running Python 3.8.2.

My system is pretty solid:
Screenshot from 2020-08-10 13-35-20

Using Amulet, I was able to open an old world and convert it to 1.16.1, but if I attempt to click the "Edit" button, it always crashes with the following complaint:

[~/src/Amulet-Map-Editor] $ GDK_SYNCHRONIZE="1" python3 ./main.py
2020-08-10 13:06:55,129 - amulet_map_editor - INFO - Could not find loader for /home/seann/.minecraft/saves/Zoyas Underwater NPC Village Could not find a matching format for /home/seann/.minecraft/saves/Zoyas Underwater NPC Village
2020-08-10 13:06:55,130 - amulet_map_editor - INFO - Could not find loader for /home/seann/.minecraft/saves/Zoyas Other Underwater NPC Village Could not find a matching format for /home/seann/.minecraft/saves/Zoyas Other Underwater NPC Village
2020-08-10 13:16:00,388 - amulet_core - INFO - Loading world /home/seann/.minecraft/saves/Optifine Test World Copy

(main.py:57206): Gdk-ERROR **: 13:16:10.290: The program 'main.py' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
  (Details: serial 50874 error_code 2 request_code 151 (GLX) minor_code 3)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
Trace/breakpoint trap (core dumped)

I saw a logs directory, so I had a look, but it wasn't very helpful. Here's what I got from those log files, including a little extra info I had some of the subroutines dump to the log as I went through the debugging:

[~/src/Amulet-Map-Editor/logs] $ cat *.log
2020-08-10 17:24:51,569 - amulet_core - INFO - Loading world /home/seann/.minecraft/saves/1_16_1 Test Seed REDRED
2020-08-10 17:24:50,442 - amulet_map_editor - INFO - Could not find loader for /home/seann/.minecraft/saves/Zoyas Underwater NPC Village Could not find a matching format for /home/seann/.minecraft/saves/Zoyas Underwater NPC Village
2020-08-10 17:24:50,444 - amulet_map_editor - INFO - Could not find loader for /home/seann/.minecraft/saves/Zoyas Other Underwater NPC Village Could not find a matching format for /home/seann/.minecraft/saves/Zoyas Other Underwater NPC Village
2020-08-10 17:25:00,008 - amulet_map_editor - INFO - Loading world.
2020-08-10 17:25:05,739 - amulet_map_editor - INFO - class EditExtension called
2020-08-10 17:25:05,739 - amulet_map_editor - INFO - wx.Panel.__init__(self, parent)
2020-08-10 17:25:05,740 - amulet_map_editor - INFO - self.SetSizer(self._sizer)
2020-08-10 17:25:10,978 - amulet_map_editor - INFO - def enable self - self.Update() starting
2020-08-10 17:26:17,471 - amulet_map_editor - INFO - def enable self - self.Update() completed
2020-08-10 17:24:50,428 - pymctranslate - INFO - PyMCTranslate Version 81

I know Amulet doesn't support forge, so I expect it to have complaints about those worlds (which it does - the Underwater NPC Village worlds are older Forge worlds my daughter made on 1.6).

But when I attempt to edit any non-forge worlds I have, such as REDRED_3, listed above, it crashes.

After MUCH tinkering, and some excessive exploitation of Amulet's own logging function, I think I've managed to locate the moment the program crashes on my Linux install:

--Call--
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/programs/edit/canvas/base_edit_canvas.py(52)__init__()
-> def __init__(self, parent: wx.Window, world: "World", auto_setup=True):
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/programs/edit/canvas/base_edit_canvas.py(53)__init__()
-> super().__init__(parent)
--Call--
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(13)__init__()
-> def __init__(self, parent: wx.Window):
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(14)__init__()
-> display_attributes = wx.glcanvas.GLAttributes()
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(15)__init__()
-> display_attributes.PlatformDefaults().MinRGBA(8, 8, 8, 8).DoubleBuffer().Depth(
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(16)__init__()
-> 24
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(15)__init__()
-> display_attributes.PlatformDefaults().MinRGBA(8, 8, 8, 8).DoubleBuffer().Depth(
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(18)__init__()
-> super().__init__(parent, display_attributes, size=parent.GetClientSize())
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(19)__init__()
-> self._projection = [70.0, 4 / 3, 0.1, 10000.0]
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(20)__init__()
-> context_attributes = wx.glcanvas.GLContextAttrs()
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(21)__init__()
-> context_attributes.CoreProfile().OGLVersion(
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(22)__init__()
-> 3, 3
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(21)__init__()
-> context_attributes.CoreProfile().OGLVersion(
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(24)__init__()
-> self._context = glcanvas.GLContext(
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(25)__init__()
-> self, ctxAttrs=context_attributes
> /home/seann/src/Amulet-Map-Editor/amulet_map_editor/opengl/canvas/base.py(24)__init__()
-> self._context = glcanvas.GLContext(

(main.py:73108): Gdk-ERROR **: 17:27:57.383: The program 'main.py' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
  (Details: serial 27135 error_code 2 request_code 151 (GLX) minor_code 3)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
Trace/breakpoint trap (core dumped)

I had to do a lot of stepping through each line and function as I went, but I have generated a complete log, which I've posted to https://paste.ubuntu.com/p/vjdQGtF8VD/ if you want to look at the entire thing because it's 855 lines, and that's just too much to put here.

I hope this helps! :)

@gentlegiantJGC
Copy link
Member

I had a feeling it was probably opengl related. I probably should have pointed you to that section of the code. I will have a look later to see if there are settings that need changing for Linux

@EvilSupahFly
Copy link
Author

I left the complete GDB dump at https://paste.ubuntu.com/p/PwmkhSyP7Q/ if you're interested in the full backtrace.

@gentlegiantJGC gentlegiantJGC added type: bug Something isn't working help wanted Extra attention is needed opengl an error from OpenGL code OS: Linux labels Aug 11, 2020
@gentlegiantJGC
Copy link
Member

I am not really sure what is causing the issue. Google doesn't have anything of much use.

You could try updating the UI library to the newest one since you said you are using a version of Ubuntu 20 with python 3.8 and the one that automatically installs is for Ubuntu 20 for python 3.7.

https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-20.04/

We could really do with having someone on the dev team that knows more about linux (and mac)

@gentlegiantJGC
Copy link
Member

If that doesn't work you could try messing around with line 18 and line 24 of amulet_map_editor/api/opengl/canvas/base.py to see if you can get something working.

@EvilSupahFly
Copy link
Author

EvilSupahFly commented Aug 11, 2020

Funny you should mention that. In order to get Amulet to install initially, I had to use wxPython-4.1.0-cp38-cp38-linux_x86_64.whl for 20.04 because wxPython-4.1.0-cp37-cp37m-linux_x86_64.whl from 18.04 fails with a "Wrong OS" complaint, so I've actually been using the new version the whole time.

Being on the dev team would be great. In my case, however, while I'm well versed in Linux, I don't know enough about Python to do much more than a basic "Hello World."

@gentlegiantJGC
Copy link
Member

@EvilSupahFly
Copy link
Author

As soon as I get home from work today, I'll check it out and let you know.

=)

@EvilSupahFly
Copy link
Author

EvilSupahFly commented Aug 11, 2020

On v0.6.11.0, I made the change from 24 to 32, and it doesn't kill the program, but it still fails to create the map:

seann on black-beast Tue Aug 11 05:16 PM
[~/src/Amulet/0.6.11.0] $ python3-dbg main.py amulet-debug
/home/seann/.local/lib/python3.8/site-packages/wx/py/buffer.py:6: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
/home/seann/.local/lib/python3.8/site-packages/wx/lib/agw/flatnotebook.py:2655: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
2020-08-11 17:16:42,713 - amulet_map_editor - INFO - Could not find loader for /home/seann/.minecraft/saves/Zoyas Underwater NPC Village Could not find a matching format for /home/seann/.minecraft/saves/Zoyas Underwater NPC Village
2020-08-11 17:16:42,716 - amulet_map_editor - INFO - Could not find loader for /home/seann/.minecraft/saves/Zoyas Other Underwater NPC Village Could not find a matching format for /home/seann/.minecraft/saves/Zoyas Other Underwater NPC Village
/home/seann/src/Amulet/0.6.11.0/amulet_map_editor/amulet_wx/ui/select_world.py:59: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  img.Scale(width, 128, wx.IMAGE_QUALITY_NEAREST).ConvertToBitmap(),
/home/seann/src/Amulet/0.6.11.0/amulet_map_editor/amulet_wx/ui/select_world.py:74: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  self.img = wx.StaticBitmap(self, wx.ID_ANY, img, (0, 0), (width, 128))
2020-08-11 17:16:45,681 - amulet_core - INFO - Loading world /home/seann/.minecraft/saves/1_16_1 Test Seed REDRED
/home/seann/src/Amulet/0.6.11.0/amulet_map_editor/amulet_wx/ui/select_world.py:74: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  self.img = wx.StaticBitmap(self, wx.ID_ANY, img, (0, 0), (width, 128))
/home/seann/.local/lib/python3.8/site-packages/wx/lib/agw/flatnotebook.py:2655: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
/home/seann/.local/lib/python3.8/site-packages/wx/lib/agw/flatnotebook.py:2666: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  x_rect = wx.Rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16)
Traceback (most recent call last):
  File "/home/seann/src/Amulet/0.6.11.0/amulet_map_editor/programs/__init__.py", line 132, in _page_change
    self._extensions[self.GetSelection()].enable()
  File "/home/seann/src/Amulet/0.6.11.0/amulet_map_editor/programs/edit/edit.py", line 45, in enable
    self._canvas = EditCanvas(
  File "/home/seann/src/Amulet/0.6.11.0/amulet_map_editor/programs/edit/canvas/edit_canvas.py", line 98, in __init__
    super().__init__(parent, world, **kwargs)
  File "/home/seann/src/Amulet/0.6.11.0/amulet_map_editor/programs/edit/canvas/controllable_edit_canvas.py", line 26, in __init__
    super().__init__(world_panel, world, **kwargs)
  File "/home/seann/src/Amulet/0.6.11.0/amulet_map_editor/programs/edit/canvas/base_edit_canvas.py", line 53, in __init__
    super().__init__(parent)
  File "/home/seann/src/Amulet/0.6.11.0/amulet_map_editor/opengl/canvas/base.py", line 18, in __init__
    super().__init__(parent, display_attributes, size=parent.GetClientSize())
wx._core.wxAssertionError: C++ assertion ""Assert failure"" failed at /home/wxpy/wxPython-4.1.0/ext/wxWidgets/src/unix/glx11.cpp(626) in InitVisual(): Failed to get a XVisualInfo for the requested attributes.
/home/seann/.local/lib/python3.8/site-packages/wx/lib/agw/flatnotebook.py:2655: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
/home/seann/.local/lib/python3.8/site-packages/wx/lib/agw/flatnotebook.py:2666: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  x_rect = wx.Rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16)
seann on black-beast Tue Aug 11 05:17 PM
[~/src/Amulet/0.6.11.0] $ 

The program continues to run, and I can close the tab, or exit, or even open a new world, but I can't edit:

Screenshot from 2020-08-11 17-20-17

On v0.7.0.0, I can't get beyond the World Selection, so I have no idea what impact the change I made (again from 24 to 32) has:

seann on black-beast Tue Aug 11 05:23 PM
[~/src/Amulet/0.7.0.0] $ python3-dbg main.py amulet-debug
/home/seann/.local/lib/python3.8/site-packages/wx/py/buffer.py:6: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
/home/seann/.local/lib/python3.8/site-packages/wx/lib/agw/flatnotebook.py:2655: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
2020-08-11 17:23:13,639 - amulet_map_editor - INFO - Could not find loader for /home/seann/.minecraft/saves/Zoyas Underwater NPC Village Could not find a matching format for /home/seann/.minecraft/saves/Zoyas Underwater NPC Village
2020-08-11 17:23:13,641 - amulet_map_editor - INFO - Could not find loader for /home/seann/.minecraft/saves/Zoyas Other Underwater NPC Village Could not find a matching format for /home/seann/.minecraft/saves/Zoyas Other Underwater NPC Village
/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/api/wx/ui/select_world.py:60: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  img.Scale(width, 128, wx.IMAGE_QUALITY_NEAREST).ConvertToBitmap(),
/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/api/wx/ui/select_world.py:75: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  self.img = wx.StaticBitmap(self, wx.ID_ANY, img, (0, 0), (width, 128))
2020-08-11 17:23:16,779 - amulet_core - INFO - Loading world /home/seann/.minecraft/saves/1_16_1 Test Seed REDRED
Traceback (most recent call last):
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/api/wx/ui/select_world.py", line 115, in _call_callback
    self.open_world_callback(self.path)
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/api/wx/ui/select_world.py", line 286, in _update_recent
    self._open_world_callback(path)
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/api/wx/ui/select_world.py", line 307, in _run_callback
    self._open_world_callback(path)
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/api/framework/amulet_ui.py", line 167, in _open_world
    world = WorldPageUI(
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/api/framework/pages/world_page.py", line 55, in __init__
    self._load_extensions()
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/api/framework/pages/world_page.py", line 70, in _load_extensions
    load_extensions()
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/api/framework/pages/world_page.py", line 28, in load_extensions
    module = importlib.import_module(f"amulet_map_editor.programs.{name}")
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/programs/edit/__init__.py", line 1, in <module>
    from .edit import EditExtension
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/programs/edit/edit.py", line 12, in <module>
    from .canvas.edit_canvas import EditCanvas
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/programs/edit/canvas/__init__.py", line 1, in <module>
    from .base_edit_canvas import BaseEditCanvas
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/programs/edit/canvas/base_edit_canvas.py", line 27, in <module>
    from amulet_map_editor.api.opengl.mesh.world_renderer.world import (
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/api/opengl/mesh/world_renderer/__init__.py", line 1, in <module>
    from .world import RenderWorld
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/api/opengl/mesh/world_renderer/world.py", line 10, in <module>
    from amulet.api.registry import BlockManager
ModuleNotFoundError: No module named 'amulet.api.registry'
seann on black-beast Tue Aug 11 05:23 PM
[~/src/Amulet/0.7.0.0] $ 

As with 0.6.11.0, I can still navigate the menus (quit normally, close the world, try to open a new one), but I can't do anything else. I just get trapped on the opening screen until I exit Amulet.

Screenshot from 2020-08-11 17-23-24

I'll keep playing around with things and see what happens.

Edit
Stacktraces are a real bitch sometimes, but I'll run 0.6.11.0 through GDB with the changed Depth value and see what turns up. Just as a comparison.

Edit 2
Damn. GDB is useless because the errors in both cases (on both my modified 0.6.11.0 and 0.7.0.0) aren't fatal, so the thread exits normally.

@EvilSupahFly
Copy link
Author

I've spent 4 hours demolishishing and recreating Python virtual environments over and over, removing everything, reinstalling it all, and I'm getting nowhere.

No matter what I do, each time I open a world on 0.7.0.0, it ends the same way: ModuleNotFoundError: No module named 'amulet.api.registry' and I'm out of ideas. I don't know why this seems to work elsewhere. I've gone over the Python3 documentation for module imports, I've tried absolute path imports, I've tried relative path imports, I've tried modifying and expanding the search path (sys.path.append( os.path.join( os.path.dirname(__file__), os.path.pardir ) )) and I've even tried moving the files around.

Nothing works. When I run python with -m, it tells me the same thing, but faster: No module named amulet.api.registry

I'm lost.

@gentlegiantJGC
Copy link
Member

Sounds like I missed a step in our build process

@gentlegiantJGC
Copy link
Member

Ah no you are running from source. The other libraries have changed so you will need to uninstall them and reinstall them

@gentlegiantJGC
Copy link
Member

You might need to run the pip command that clears the cache so that it doesn't use the cached old version

@EvilSupahFly
Copy link
Author

Caching is such a pain sometimes. lol

So I cleared the cache, and decided "What the hell!" and deleted the entire virtualENV I was working in, and started over.

First, I cloned the GIT master branch. Then I patched linux_requirements.txt to use https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-20.04/wxPython-4.1.0-cp38-cp38-linux_x86_64.whl.asc instead.

Then, I opted to keep things cleaner this time around by doing pip3 install -U -r requirements_linux.txt --no-cache-dir and made sure it at least ran this time, which it did.

Then I changed https://github.com/Amulet-Team/Amulet-Map-Editor/blob/master/amulet_map_editor/api/opengl/canvas/base.py#L19 from 24 to 32, and proceeded to load a world, which was going great until I clicked "edit" and again, it stopped working, but didn't die. I could still close the world, and navigate the menus.

I still can't edit, but at least I'm not getting fatal errors now. In fact, on first glance, this seems to be almost the same thing I got from my patched version of 0.6.11.0.

2020-08-12 13:54:34,689 - amulet_map_editor - INFO - Could not find loader for /home/seann/.minecraft/saves/Zoyas Underwater NPC Village Could not find a matching format for /home/seann/.minecraft/saves/Zoyas Underwater NPC Village
2020-08-12 13:54:34,691 - amulet_map_editor - INFO - Could not find loader for /home/seann/.minecraft/saves/Zoyas Other Underwater NPC Village Could not find a matching format for /home/seann/.minecraft/saves/Zoyas Other Underwater NPC Village
2020-08-12 13:54:35,829 - amulet_core - INFO - Loading world /home/seann/.minecraft/saves/1_16_1 Test Seed REDRED
Traceback (most recent call last):
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/api/framework/pages/world_page.py", line 99, in _page_change
    self._extensions[self.GetSelection()].enable()
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/programs/edit/edit.py", line 47, in enable
    self._canvas = EditCanvas(
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/programs/edit/canvas/edit_canvas.py", line 99, in __init__
    super().__init__(parent, world, **kwargs)
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/programs/edit/canvas/controllable_edit_canvas.py", line 26, in __init__
    super().__init__(world_panel, world, **kwargs)
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/programs/edit/canvas/base_edit_canvas.py", line 56, in __init__
    super().__init__(parent)
  File "/home/seann/src/Amulet/0.7.0.0/amulet_map_editor/api/opengl/canvas/base.py", line 21, in __init__
    super().__init__(parent, display_attributes, size=parent.GetClientSize())
wx._core.wxAssertionError: C++ assertion ""Assert failure"" failed at /home/wxpy/wxPython-4.1.0/ext/wxWidgets/src/unix/glx11.cpp(626) in InitVisual(): Failed to get a XVisualInfo for the requested attributes.
seann on black-beast Wed Aug 12 01:54 PM
[~/src/Amulet/0.7.0.0] $ 

I'm not sure if there's still something messed up with my local install, so I'm going to try it on a virtual machine so I can just do a clean install of Mint, install only what's needed for Amulet, and not worry about contamination from older projects.

@EvilSupahFly
Copy link
Author

EvilSupahFly commented Aug 17, 2020

Since I'm off today, I gave it a shot, and I get the same error on the virtual machine as I do on the real one. The VM is running a clean install of Mint 20 with only what was needed for Amulet, plus the tweak to https://github.com/Amulet-Team/Amulet-Map-Editor/blob/master/amulet_map_editor/api/opengl/canvas/base.py#L19, which I changed to 32.

Screenshot from 2020-08-17 13-42-37

Perhaps I should be filing the bug report against wxPython for this? It seems that's where the problem is coming from now, and not Amulet directly. I'll drop by their GIT and see what they say.

** Edit: Mint 20 (Mint release notes) is forked from Ubuntu 20.04 (Ubuntu release notes).

@EvilSupahFly
Copy link
Author

I'm curious...

The release notes for wxWidget say:

  • wxGLCanvas now uses physical pixels on high DPI displays under platforms
    where they're different from logical ones (wxGTK3, wxOSX). Multiply logical
    coordinates, e.g. returned by wxWindow::GetSize() by GetContentScaleFactor()
    before using them with OpenGL functions.

Where is this done in Amulet?

@EvilSupahFly
Copy link
Author

I give up. Python makes my head hurt.

@gentlegiantJGC
Copy link
Member

This is still an issue we want to fix. I will leave it open in case someone else has the same issue

@EvilSupahFly
Copy link
Author

EvilSupahFly commented Aug 24, 2020

I'm back!

So, it took them a while, but they finally got back to me on the wxWidgets GIT, so I'm passing along their response in hopes this helps, and run it with his suggested tweaks and see what happens:

That assertion comes from X11 failing, not wxWidgets, not Amulet.

It's pretty strange that the attributes you use:

display_attributes.PlatformDefaults().MinRGBA(8, 8, 8, 8).DoubleBuffer().Depth(24).EndList()

may result in a fail.

You can also try with

display_attributes.PlatformDefaults().RGBA().DoubleBuffer().Depth(24).EndList()

Where I changed the ancient MinRGBA(,,) with RGBA()

The cases where I see this kind of problem are:
a) Running inside a VM (which often also limits the OGL version up to 2.1, no Core Profile)
b) Not having installed the graphics card proper driver.
c) Lacking of installing "mesa-utils" (some OGL basis ship with it) fixes many issues.

Finally, is Wayland the default (instead of X11)? Currently, wxWidgets doesn't support Wayland.
See https://trac.wxwidgets.org/ticket/17702#comment:5 about setting GDK_BACKEND=x11 Amulet (if that's the name of your executable) before running your app.

@EvilSupahFly
Copy link
Author

So I tested on my production rig this time, rather than the VM and set GDK_BACKEND like they suggested, but I get the same error still with both

MinRGBA(8, 8, 8, 8)

and

RGBA()

And it fails under both those with both Depth(24) and Depth(32) so now I'm at a complete loss again. Maybe this helps you guys at least? I still can get it to run though.

@gentlegiantJGC
Copy link
Member

Do you have a link to that bug report you opened? GitHub will link the two reports.
I assume you have the graphics drivers installed

@EvilSupahFly
Copy link
Author

It's at https://trac.wxwidgets.org/ticket/18891 but I can't get to it right now with my home ISP. Only works on my mobile data for some reason.

@EvilSupahFly
Copy link
Author

EvilSupahFly commented Aug 24, 2020

I posted this on the other thread as well, but it bears repeating.

According to ​https://linuxconfig.org/how-to-enable-disable-wayland-on-ubuntu-20-04-desktop, Wayland is disabled by default on Ubuntu 20.04, which serves as the base for Mint 20, so the comment at ​https://blog.linuxmint.com/?p=3890#comment-154895 stating that Wayland is not even really supported on Mint 20 tracks, meaning I shouldn't need to force X11 through GDK_BACKEND.

Edit: Mint team explains position on Wayland: https://blog.linuxmint.com/?p=3890#comment-154935

@EvilSupahFly
Copy link
Author

Indeed, I searched my /etc for anything relating to Wayland and came up empty. Not a single file references it.

@EvilSupahFly
Copy link
Author

Because X11 is asynchronous, does that impact the way Amulet creates the window on Linux? Or is this already factored by the OpenGL components in the back-end?

On wxWidgets, they suggested setting the glcanvas with a wx.Frame as parent, and also checking the desired attributes without the need of a window as outlined at https://docs.wxpython.org/wx.glcanvas.GLCanvas.html#wx.glcanvas.GLCanvas.IsDisplaySupported.

I'm going to play around with it some and see what happens.

@EvilSupahFly
Copy link
Author

EvilSupahFly commented Oct 28, 2020 via email

@andrewathalye
Copy link

I've also observed this same issue. Backtracing with gdb got me to a GLX instance creation, at which point it seemed to throw the X11 error. I am using the Proprietary NVIDIA driver on Kernel 5.9 - maybe that also has something to do with it?

Vulkan, OpenGL, and EGL all work fine for me, but I don't really have a good way of testing GLX directly.

@EvilSupahFly
Copy link
Author

EvilSupahFly commented Nov 6, 2020 via email

@andrewathalye
Copy link

andrewathalye commented Nov 6, 2020 via email

@andrewathalye
Copy link

andrewathalye commented Nov 6, 2020

Actually nevermind, I think I have traced the error :)
It seems to have to do with the Context Attributes setup after the GLX initialization. I am not yet sure which specific attribute causes the issue though, so I'll try to get back as soon as I figure it out.

Removing this part leads to everything fully initializing, although I have to reset my virtualenv in order to get a better idea about whether the actual rendering works as expected. It certainly doesn't crash though :)

Edit 3: Success! I am not sure if this is a tenable workaround, but:

  1. In amulet-map-editor/api/opengl/canvas/base.py
context_attributes = wx.glcanvas.GLContextAttrs()
        context_attributes.CoreProfile().OGLVersion(
            3, 3
        ).Robust().ResetIsolation().EndList()
        self._context = glcanvas.GLContext(
            self, ctxAttrs=context_attributes
        )  # setup the OpenGL context

Replace instead with
self._context = glcanvas.GLContext(self)

It looks like passing ctxAttrs to the context causes some sort of error on Linux.

  1. A second important step, at least for now, is removing the dtype assertion from amulet-api/partial_3d_array/base_partial_3d_array.py.

I am not sure why this causes problems, but with these two changes made Amulet functions just as before on Linux (with flickering menus, but otherwise completely functional)

This may well be a wxPython bug, but it could also have to do with the use of the NVIDIA driver, as that is where the actual X error is generated.

@gentlegiantJGC
Copy link
Member

Do you have the traceback for the dtype assertion? It is probably an internal issue. Also the world version you opened

@gentlegiantJGC
Copy link
Member

If you don't specify the attributes what does it use? I presume the defaults assuming that is compatible with what we are doing

@andrewathalye
Copy link

andrewathalye commented Nov 7, 2020

Do you have the traceback for the dtype assertion? It is probably an internal issue. Also the world version you opened

I tested it initially with both a 1.16.4 world (from a Spigot server) and a 1.16.3 world (from a Fabric server, but with only Lithium, Phoshor, and FabricProxy installed, so without custom blocks / chunkdata).

Here is the traceback:

  File "/home/build/bin/Amulet-Map-Editor/amulet_map_editor/api/framework/pages/world_page.py", line 99, in _page_change
    self._extensions[self.GetSelection()].enable()
  File "/home/build/bin/Amulet-Map-Editor/amulet_map_editor/programs/edit/edit.py", line 77, in enable
    self._canvas.draw()
  File "/home/build/bin/Amulet-Map-Editor/amulet_map_editor/programs/edit/canvas/base_edit_canvas.py", line 627, in draw
    self._change_box_location()
  File "/home/build/bin/Amulet-Map-Editor/amulet_map_editor/programs/edit/canvas/base_edit_canvas.py", line 460, in _change_box_location
    position, box_index = self._box_location_closest()
  File "/home/build/bin/Amulet-Map-Editor/amulet_map_editor/programs/edit/canvas/base_edit_canvas.py", line 502, in _box_location_closest
    chunk = self._render_world.world.get_chunk(cx, cz, self.dimension)
  File "/home/build/.local/lib/python3.8/site-packages/amulet/api/world/world.py", line 248, in get_chunk
    return self._chunks.get_chunk(dimension, cx, cz)
  File "/home/build/.local/lib/python3.8/site-packages/amulet/api/world/chunk_manager.py", line 103, in get_chunk
    return self._get_entry((dimension, cx, cz))
  File "/home/build/.local/lib/python3.8/site-packages/amulet/api/history/history_manager/database.py", line 76, in _get_entry
    entry = self._temporary_database[key] = self._get_register_original_entry(
  File "/home/build/.local/lib/python3.8/site-packages/amulet/api/history/history_manager/database.py", line 88, in _get_register_original_entry
    entry = self._get_entry_from_world(key)
  File "/home/build/.local/lib/python3.8/site-packages/amulet/api/world/chunk_manager.py", line 119, in _get_entry_from_world
    chunk.biome_palette = self.world.biome_palette
  File "/home/build/.local/lib/python3.8/site-packages/amulet/api/chunk/chunk.py", line 245, in biome_palette
    self.biomes = {
  File "/home/build/.local/lib/python3.8/site-packages/amulet/api/chunk/chunk.py", line 203, in biomes
    self._biomes = Biomes(value)
  File "/home/build/.local/lib/python3.8/site-packages/amulet/api/chunk/biomes.py", line 40, in __init__
    self._3d = Biomes3D(array)
  File "/home/build/.local/lib/python3.8/site-packages/amulet/api/chunk/biomes.py", line 19, in __init__
    super().__init__(numpy.uint32, 0, (4, 4, 4), (0, 16), sections=input_array)
  File "/home/build/.local/lib/python3.8/site-packages/amulet/api/partial_3d_array/unbounded_partial_3d_array.py", line 33, in __init__
    super().__init__(
  File "/home/build/.local/lib/python3.8/site-packages/amulet/api/partial_3d_array/base_partial_3d_array.py", line 54, in __init__
    assert (

I'm not sure what the default behaviour for attribute inheritance is, but I also assume that it would choose defaults somehow.

It may also be related that this is quite a large world - more than a gigabyte at the moment, with approximately 3000x3000 blocks around 0,0 already generated by players using elytras.

@gentlegiantJGC
Copy link
Member

If a few more people on Linux can test that fix and confirm it works we can add it as a workaround for Linux.

I will look into the assertion in a bit

@EvilSupahFly
Copy link
Author

EvilSupahFly commented Nov 8, 2020

Which line (or lines?) did you alter in ~/.local/lib/python3.8/site-packages/amulet/api/partial_3d_array/base_partial_3d_array.py when you removed the dtype assertion? I've been testing Amulet using a world I created in 1.16.4 which is less than 100 MB - basically, I spawned in, looked around long enough to generate a few chunks, and left. Nothing fancy, just Vanilla Minecraft from the native launcher.

I tried removing dtype: DtypeType, and self._dtype = dtype on lines 18 and 27 and assert (section.dtype == self._dtype), on lines 54 - 56, and every combination of removing only some of those lines and leaving others, but it still fails every time.

Interestingly enough, I'm running version 455 of the nVidia proprietary driver, as I recently upgraded my video card to the GeForce GTX 1660. I think I should boot from my live environment thumb drive and see what happens when using the Nouveau driver instead of the proprietary one, tomorrow.

** Edit: My system has actually gone through a number of changes since I first tried Amulet. Complete specs are at https://termbin.com/xj9l if it helps anyone.

@gentlegiantJGC
Copy link
Member

If it causes you issues the last line of the traceback above. The line starts with assert

@gentlegiantJGC
Copy link
Member

This is the actual fix you need to try
#84 (comment)

@EvilSupahFly
Copy link
Author

Side note: I've read that under Linux you can't set the OpenGL context until the window has a non-zero size, but I don't have the Python skills to verify this and change it if necessary. I tried stepping through line by line in PyCharm, and watching everything as it unfolded, but it got way too technical with code improvement suggestions for everything it encountered then telling me that the files in .../site-packages/amulet/ weren't part of the project and shouldn't be touched, that I rage quit, having learned nothing, and arrived no closer to a solution.

Also worth noting that Amulet crashes right out of the gate with Python 3.9 (which PyCharm defaulted to, and I had to change). With 3.8, it only crashes when I click the 3D tab.

@gentlegiantJGC
Copy link
Member

The context isn't set up until you click the edit button. That is the reason why it is crashing.

Did you try making the suggested change to the context?

@EvilSupahFly
Copy link
Author

This is the actual fix you need to try
#84 (comment)

The context isn't set up until you click the edit button. That is the reason why it is crashing.

Did you try making the suggested change to the context?

I did change

        context_attributes.CoreProfile().OGLVersion(
            3, 3
        ).Robust().ResetIsolation().EndList()
        self._context = glcanvas.GLContext(
            self, ctxAttrs=context_attributes
        )  # setup the OpenGL context

to

        context_attributes.CoreProfile().OGLVersion(
            3, 3
        ).Robust().ResetIsolation().EndList()
        self._context = glcanvas.GLContext(
            self
        )  # setup the OpenGL context

It's the removal of the dtype assertion I was unclear on as it still crashes for me.

@gentlegiantJGC
Copy link
Member

That is close to the change they suggested but not exactly the same. They totally removed the context attributes lines.
This

context_attributes = wx.glcanvas.GLContextAttrs()
context_attributes.CoreProfile().OGLVersion(
	3, 3
).Robust().ResetIsolation().EndList()
self._context = glcanvas.GLContext(
	self, ctxAttrs=context_attributes
)  # setup the OpenGL context

should become this

self._context = glcanvas.GLContext(
	self
)  # setup the OpenGL context

What is the dtype crash? Have you removed the assert line?

@EvilSupahFly
Copy link
Author

Ah. I misunderstood the change.

So self._context is fixed, and I commented out as follows in base_partial_3d_array.py:

            # populate from sections
            self._sections: Dict[int, numpy.ndarray] = sections or {}
            for key, section in self._sections.items():
                assert isinstance(key, int), "All keys must be ints"
                assert (
                    section.shape == self._section_shape
                ), "The size of all sections must be equal to the section_shape."
                #assert (
                #    section.dtype == self._dtype
                #), "The given dtype does not match the arrays given."

But I'm wondering if I botched that too because I still get that whole BadValue (integer parameter out of range for operation)' dump, though, Python isn't reporting line numbers in the traceback now, after I nuked the ENV that was screwing things up before, so I don't know what I've done, but I clearly messed SOMETHING up.

@andrewathalye
Copy link

andrewathalye commented Nov 8, 2020 via email

@EvilSupahFly
Copy link
Author

EvilSupahFly commented Nov 8, 2020

Well. I uninstalled everything first, using pip3 uninstall -r requirements_linux.txt, deleted the Amulet folder I was working in, and started over using --use-feature=2020-resolver which is apparently now recommended by PIP3, as well as --force-reinstall and it complained at first that testresources wasn't installed, and the message I've always seen (but didn't seem to be a problem):

  WARNING: Missing build requirements in pyproject.toml for git+git://github.com/Amulet-Team/Amulet-NBT.git (from -r requirements_base.txt (line 4)).
  WARNING: The project does not specify a build backend, and pip cannot fall back to setuptools without 'wheel'.

I set GDK_SYNCHRONIZE=1 and installed the latest version of testresources then I made the changes to self._context from #84 (comment). Now I actually get the renderer to appear, along the way throwing ResourceWarning: Enable tracemalloc to get the object allocation traceback for each .PNG in the resource pack, then everything finally falls apart with the assertion error, repeated for each chunk:

Traceback (most recent call last):
  File "/home/seann/src/Minecraft/Amulet-Map-Editor/amulet_map_editor/api/opengl/mesh/world_renderer/world.py", line 126, in _generate_chunks
    chunk.create_geometry()
  File "/home/seann/src/Minecraft/Amulet-Map-Editor/amulet_map_editor/api/opengl/mesh/world_renderer/chunk.py", line 149, in create_geometry
    chunk = self.chunk
  File "/home/seann/src/Minecraft/Amulet-Map-Editor/amulet_map_editor/api/opengl/mesh/world_renderer/chunk.py", line 81, in chunk
    return self._world.get_chunk(self.cx, self.cz, self._dimension)
  File "/home/seann/.local/lib/python3.8/site-packages/amulet/api/world/world.py", line 248, in get_chunk
    return self._chunks.get_chunk(dimension, cx, cz)
  File "/home/seann/.local/lib/python3.8/site-packages/amulet/api/world/chunk_manager.py", line 103, in get_chunk
    return self._get_entry((dimension, cx, cz))
  File "/home/seann/.local/lib/python3.8/site-packages/amulet/api/history/history_manager/database.py", line 76, in _get_entry
    entry = self._temporary_database[key] = self._get_register_original_entry(
  File "/home/seann/.local/lib/python3.8/site-packages/amulet/api/history/history_manager/database.py", line 88, in _get_register_original_entry
    entry = self._get_entry_from_world(key)
  File "/home/seann/.local/lib/python3.8/site-packages/amulet/api/world/chunk_manager.py", line 119, in _get_entry_from_world
    chunk.biome_palette = self.world.biome_palette
  File "/home/seann/.local/lib/python3.8/site-packages/amulet/api/chunk/chunk.py", line 245, in biome_palette
    self.biomes = {
  File "/home/seann/.local/lib/python3.8/site-packages/amulet/api/chunk/chunk.py", line 203, in biomes
    self._biomes = Biomes(value)
  File "/home/seann/.local/lib/python3.8/site-packages/amulet/api/chunk/biomes.py", line 40, in __init__
    self._3d = Biomes3D(array)
  File "/home/seann/.local/lib/python3.8/site-packages/amulet/api/chunk/biomes.py", line 19, in __init__
    super().__init__(numpy.uint32, 0, (4, 4, 4), (0, 16), sections=input_array)
  File "/home/seann/.local/lib/python3.8/site-packages/amulet/api/partial_3d_array/unbounded_partial_3d_array.py", line 33, in __init__
    super().__init__(
  File "/home/seann/.local/lib/python3.8/site-packages/amulet/api/partial_3d_array/base_partial_3d_array.py", line 54, in __init__
    assert (
AssertionError: The given dtype does not match the arrays given.

Now that I've come this far, and confirmed the findings from #84 (comment), I went into ~/.local/lib/python3.8/site-packages/amulet/api/partial_3d_array/base_partial_3d_array.py and commented out lines 54, 55, and 56:

                #assert (
                #    section.dtype == self._dtype
                #), "The given dtype does not match the arrays given."

Now, it renders the world, but the buttons only appear for a short time when the mouse is over them, or when I'm rotating the map view. I tested Copy and Paste, which seemed to work, and was able to switch from Overworld to Nether, all of which you can see in https://youtu.be/3ZBt5f6A3wc.

So, now it works, mostly. The menu flickering is a bit of an annoyance, but not fatal.

@gentlegiantJGC
Copy link
Member

Awesome news. I haven't gotten around to looking into why that assert is a problem. You can probably get by with just uncommenting it.

The flickering is a problem

@EvilSupahFly
Copy link
Author

EvilSupahFly commented Nov 8, 2020 via email

@gentlegiantJGC
Copy link
Member

Sorry I meant commenting it out

gentlegiantJGC added a commit that referenced this issue Nov 10, 2020
I am not entirely sure why this fixes it or what issues this may cause
@gentlegiantJGC
Copy link
Member

a07ee4c should fix the canvas issue
Amulet-Team/Amulet-Core@d6f0e8a should hopefully resolve the assert error. numpy.uint is different on windows and linux

@EvilSupahFly
Copy link
Author

a07ee4c has indeed fixed the assertion issue with the base canvas, and as you can see in this new video, aside from the flickering, the world editing seems very stable on Linux, and the edited world plays fine in Minecraft.

@gentlegiantJGC
Copy link
Member

Awesome. I have opened #127 for the flickering issue.

I think that resolves all the issue for this report

@EvilSupahFly
Copy link
Author

Awesome. I have opened #127 for the flickering issue.

I think that resolves all the issue for this report

Quite nicely, I think. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed opengl an error from OpenGL code OS: Linux type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants