minerl
minerl copied to clipboard
GLFW requires main thread
When I use the 0.4 version minerl All is good but if I want to use 1.0.0 version I have the following error:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py:125: RuntimeWarning: 'minerl.utils.process_watcher' found in sys.modules after import of package 'minerl.utils', but prior to execution of 'minerl.utils.process_watcher'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 293, in _on_run
r = self.sock.recv(1024)
OSError: [Errno 9] Bad file descriptor
Traceback (most recent call last):
File "/Users/merenion/Documents/Projects/Other/testMineral2/venv/lib/python3.7/site-packages/minerl/env/_multiagent.py", line 436, in reset
self._setup_instances()
File "/Users/merenion/Documents/Projects/Other/testMineral2/venv/lib/python3.7/site-packages/minerl/env/_multiagent.py", line 539, in _setup_instances
self.instances.extend([f.result() for f in instance_futures])
File "/Users/merenion/Documents/Projects/Other/testMineral2/venv/lib/python3.7/site-packages/minerl/env/_multiagent.py", line 539, in <listcomp>
self.instances.extend([f.result() for f in instance_futures])
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 428, in result
return self.__get_result()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/Users/merenion/Documents/Projects/Other/testMineral2/venv/lib/python3.7/site-packages/minerl/env/_multiagent.py", line 805, in _get_new_instance
instance.launch(replaceable=self._is_fault_tolerant)
File "/Users/merenion/Documents/Projects/Other/testMineral2/venv/lib/python3.7/site-packages/minerl/env/malmo.py", line 428, in launch
error_str + "\n\nMinecraft process finished unexpectedly. There was an error with Malmo.")
EOFError: /Users/merenion/Documents/Projects/Other/testMineral2/venv/lib/python3.7/site-packages/minerl/env/../MCP-Reborn
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[13:37:16] [Render thread/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[13:37:17] [Render thread/ERROR]: Failed to verify authentication!
[13:37:17] [Render thread/INFO]: Setting user: Player508
[13:37:17] [Render thread/INFO]: Backend library: LWJGL version 3.2.1 SNAPSHOT
---- Minecraft Crash Report ----
// Hi. I'm Minecraft, and I'm a crashaholic.
Time: 08.07.22 13:37
Description: Initializing game
java.lang.ExceptionInInitializerError
at org.lwjgl.glfw.GLFW.glfwCreateWindow(GLFW.java:1842)
at net.minecraft.client.MainWindow.<init>(MainWindow.java:91)
at net.minecraft.client.renderer.VirtualScreen.create(VirtualScreen.java:21)
at net.minecraft.client.Minecraft.<init>(Minecraft.java:408)
at net.minecraft.client.main.Main.main(Main.java:154)
Caused by: java.lang.IllegalStateException: GLFW windows may only be created on the main thread and that thread must be the first thread in the process. Please run the JVM with -XstartOnFirstThread. For offscreen rendering, make sure another window toolkit (e.g. AWT or JavaFX) is initialized before GLFW.
at org.lwjgl.glfw.EventLoop$OffScreen.<clinit>(EventLoop.java:39)
... 5 more
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Thread: Render thread
Stacktrace:
at org.lwjgl.glfw.GLFW.glfwCreateWindow(GLFW.java:1842)
at net.minecraft.client.MainWindow.<init>(MainWindow.java:91)
at net.minecraft.client.renderer.VirtualScreen.create(VirtualScreen.java:21)
at net.minecraft.client.Minecraft.<init>(Minecraft.java:408)
-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.main.Main.main(Main.java:154)
-- System Details --
Details:
Minecraft Version: 1.16.5
Minecraft Version ID: 1.16.5
Operating System: Mac OS X (x86_64) version 10.16
Java Version: 1.8.0_292, AdoptOpenJDK
Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), AdoptOpenJDK
Memory: 709970056 bytes (677 MB) / 1641545728 bytes (1565 MB) up to 3817865216 bytes (3641 MB)
CPUs: 16
JVM Flags: 1 total; -Xmx4G
Launched Version: ~~NULL~~
Backend library: LWJGL version 3.2.1 SNAPSHOT
Backend API: NO CONTEXT
GL Caps:
Using VBOs: Yes
Is Modded: Very likely; Jar signature invalidated
Type: Client (map_client.txt)
CPU: <unknown>
#@!@# Game crashed! Crash report saved to: #@!@# /Users/merenion/Documents/Projects/Other/testMineral2/venv/lib/python3.7/site-packages/minerl/MCP-Reborn/./crash-reports/crash-2022-07-08_13.37.17-client.txt
Minecraft process finished unexpectedly. There was an error with Malmo.
python-BaseException
I was trying to find a solution to this problem in this issue https://github.com/minerllabs/minerl/issues/637 but all my attempts failed. I think that I have a poor understanding of what is xvfb and why I have to use this with version 1.0.0. Maybe someone can give me any information that will help me solve my problem.
What about -XstartOnFirstThread. How can I run Java App from python code with this attribute
Is this the log from running xvfb-run -a python [path to your code] as mentioned in the linked issue?
Is this the log from running
xvfb-run -a python [path to your code]as mentioned in the linked issue?
No. I didn't find a way to use a xvfb-run command on OS X but I installed xvfb and I can use xvfb but it isn't the same thing. How I understood xvfb-run is a wrapper of xvfb but now I haven't figured out how to use it yet.
@Merenion If you installed xvfb, you should be able to use the xvfb-run command. What do you see in your terminal if you just type xvfb-run and hit enter?
Using xvfb-run fixed that issue for me on Ubuntu.
@trigaten I thought the same, but xvfb is available in the console, xvfb-run is not available. Perhaps this also applies. I think it also may depends on the version of OSX. Do you have somebody who have OSX?
@Merenion You could try this with xvfb to manually setup the screen and use it, but I do not know if it would work on OSX.
export DISPLAY=:1
xvfb $DISPLAY -screen 0 1024x768 &
@trigaten is main member in the team who runs things in OSX. @brandonhoughton also runs some things in OSX but I can not remember if it is the full MineRL or not.
@Miffyli @Merenion I would also be interested to see how @trigaten and @brandonhoughton have installed xvfb and configured MineRL to run on their copies of macOS (e.g., macOS Monterrey). For reference, I am getting the same GLFW main thread error while running MineRL 1.0.0 on macOS Monterrey on a 16-inch 2019 MacBook Pro with a dedicated AMD Radeon Pro 5500M onboard GPU.