startup error while parsing xrandr output.
Bubu opened this issue · 15 comments
I get the following exception when running any lwjgl application on this Lubuntu 14.04.02 Notebook.:
Exception in thread "LWJGL Application" java.lang.ExceptionInInitializerError
at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setVSync(LwjglGraphics.java:446)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:118)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.lwjgl.opengl.LinuxDisplay.getAvailableDisplayModes(LinuxDisplay.java:954)
at org.lwjgl.opengl.LinuxDisplay.init(LinuxDisplay.java:738)
at org.lwjgl.opengl.Display.<clinit>(Display.java:138)
I traced the error to the xrandr parsing function but could not yet exactly pinpoint it.
Below is the output of xrandr. The offending lines are definitely the bottom ones with LVDS-1-1 connected
. The laptop has 2 graphics card, I think this is probably the root cause:
$> lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 07)
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] RV710/M92 [Mobility Radeon HD 4330/4350/4550]
$> xrandr -q
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 32767 x 32767
LVDS1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 310mm x 174mm
1366x768 60.0*+
1360x768 59.8 60.0
1024x768 60.0
800x600 60.3 56.2
640x480 59.9
VGA1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
TV1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
VGA-1-1 disconnected
LVDS-1-1 connected
1366x768 60.0 +
1280x720 59.9
1152x768 59.8
1024x768 59.9
800x600 59.9
848x480 59.7
720x480 59.7
640x480 59.4
HDMI-1-0 disconnected
1366x768 (0x45) 75.1MHz
h: width 1366 start 1414 end 1446 total 1564 skew 0 clock 48.0KHz
v: height 768 start 771 end 776 total 800 clock 60.0Hz
Do you know which version of LWJGL is producing this?
Also, please gather some more info by launching your application with
-Dorg.lwjgl.util.Debug=true
as JVM argument and post all output that begins with [LWJGL]
The version is LWJGL 2.9.2.
I will add the other info later, I'm currently not on that PC.
Thanks.
Also the xrandr output looks a bit strange. You are absolutely right,
LVDS-1-1 connected
breaks the parsing. I tried this with the latest LWJGL version, which results in a different error, but still does not work edit: changed my mind, seems to be the same problem. How exactly did you run xrandr to get this output? Please check if
xrandr -q
produces the same. If it does, we probaly need to patch LWJGL to support this. Besides,
xrandr -v
would also be nice to know.
The above output is xrandr -q
(same as just xrandr
).
$> xrandr -v
xrandr program version 1.4.1
Server reports RandR version 1.4
ok. I will create a patch for this as soon as I find some time, may take a couple of days.
Just out of curiosity, can you please post the output of
xrandr --verbose
I still think having a display with unknown resolution is a bit odd.
I should probably also fix the parsing for the HDMI lines, they all look quite odd and will break the parsing sooner or later.
$> xrandr --verbose
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 32767 x 32767
LVDS1 connected 1366x768+0+0 (0x45) normal (normal left inverted right x axis y axis) 310mm x 174mm
Identifier: 0x6f
Timestamp: 36654
Subpixel: horizontal rgb
Gamma: 1.0:1.0:1.0
Brightness: 1.0
Clones:
CRTC: 0
CRTCs: 0 1
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
EDID:
00ffffffffffff0030e4024300000000
00130103801f11780a8845955a568d28
23505400000001010101010101010101
010101010101561d56c6500020303020
350036ae100000190000000000000000
00000000000000000000000000fe004c
4720446973706c61790a2020000000fc
004c503134305748322d544c423100f6
BACKLIGHT: 5
range: (0, 9)
Backlight: 5
range: (0, 9)
scaling mode: Full aspect
supported: None, Full, Center, Full aspect
1366x768 (0x45) 75.1MHz -HSync -VSync *current +preferred
h: width 1366 start 1414 end 1446 total 1564 skew 0 clock 48.0KHz
v: height 768 start 771 end 776 total 800 clock 60.0Hz
1360x768 (0xbe) 84.8MHz -HSync +VSync
h: width 1360 start 1432 end 1568 total 1776 skew 0 clock 47.7KHz
v: height 768 start 771 end 781 total 798 clock 59.8Hz
1360x768 (0xbf) 72.0MHz +HSync -VSync
h: width 1360 start 1408 end 1440 total 1520 skew 0 clock 47.4KHz
v: height 768 start 771 end 781 total 790 clock 60.0Hz
1024x768 (0xc0) 65.0MHz -HSync -VSync
h: width 1024 start 1048 end 1184 total 1344 skew 0 clock 48.4KHz
v: height 768 start 771 end 777 total 806 clock 60.0Hz
800x600 (0xc1) 40.0MHz +HSync +VSync
h: width 800 start 840 end 968 total 1056 skew 0 clock 37.9KHz
v: height 600 start 601 end 605 total 628 clock 60.3Hz
800x600 (0xc2) 36.0MHz +HSync +VSync
h: width 800 start 824 end 896 total 1024 skew 0 clock 35.2KHz
v: height 600 start 601 end 603 total 625 clock 56.2Hz
640x480 (0xc3) 25.2MHz -HSync -VSync
h: width 640 start 656 end 752 total 800 skew 0 clock 31.5KHz
v: height 480 start 490 end 492 total 525 clock 59.9Hz
VGA1 disconnected (normal left inverted right x axis y axis)
Identifier: 0x70
Timestamp: 36654
Subpixel: unknown
Clones:
CRTCs: 0 1
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
DP1 disconnected (normal left inverted right x axis y axis)
Identifier: 0x71
Timestamp: 36654
Subpixel: unknown
Clones:
CRTCs: 0 1
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
Broadcast RGB: Automatic
supported: Automatic, Full, Limited 16:235
audio: auto
supported: force-dvi, off, auto, on
TV1 disconnected (normal left inverted right x axis y axis)
Identifier: 0x72
Timestamp: 36654
Subpixel: unknown
Clones:
CRTCs: 0 1
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
bottom margin: 37
range: (0, 100)
right margin: 46
range: (0, 100)
top margin: 36
range: (0, 100)
left margin: 54
range: (0, 100)
mode: NTSC-M
supported: NTSC-M, NTSC-443, NTSC-J, PAL-M, PAL-N, PAL, 480p, 576p, 720p@60Hz, 720p@50Hz, 1080i@50Hz, 1080i@60Hz
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
Identifier: 0x73
Timestamp: 36654
Subpixel: no subpixels
Clones:
CRTCs: 2
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
VGA-1-1 disconnected (normal)
Identifier: 0x41
Timestamp: 36654
Subpixel: no subpixels
Clones:
CRTCs: 3 4
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
load detection: 1
range: (0, 1)
LVDS-1-1 connected (normal)
Identifier: 0x42
Timestamp: 36654
Subpixel: horizontal rgb
Clones:
CRTCs: 3 4
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
scaling mode: Full
supported: None, Full, Center, Full aspect
1366x768 (0x45) 75.1MHz -HSync -VSync +preferred
h: width 1366 start 1414 end 1446 total 1564 skew 0 clock 48.0KHz
v: height 768 start 771 end 776 total 800 clock 60.0Hz
1280x720 (0x46) 74.5MHz -HSync +VSync
h: width 1280 start 1344 end 1472 total 1664 skew 0 clock 44.8KHz
v: height 720 start 723 end 728 total 748 clock 59.9Hz
1152x768 (0x47) 71.8MHz -HSync +VSync
h: width 1152 start 1216 end 1328 total 1504 skew 0 clock 47.7KHz
v: height 768 start 771 end 781 total 798 clock 59.8Hz
1024x768 (0x48) 63.5MHz -HSync +VSync
h: width 1024 start 1072 end 1176 total 1328 skew 0 clock 47.8KHz
v: height 768 start 771 end 775 total 798 clock 59.9Hz
800x600 (0x49) 38.2MHz -HSync +VSync
h: width 800 start 832 end 912 total 1024 skew 0 clock 37.4KHz
v: height 600 start 603 end 607 total 624 clock 59.9Hz
848x480 (0x4a) 31.5MHz -HSync +VSync
h: width 848 start 872 end 952 total 1056 skew 0 clock 29.8KHz
v: height 480 start 483 end 493 total 500 clock 59.7Hz
720x480 (0x4b) 26.8MHz -HSync +VSync
h: width 720 start 744 end 808 total 896 skew 0 clock 29.9KHz
v: height 480 start 483 end 493 total 500 clock 59.7Hz
640x480 (0x4c) 23.8MHz -HSync +VSync
h: width 640 start 664 end 720 total 800 skew 0 clock 29.7KHz
v: height 480 start 483 end 487 total 500 clock 59.4Hz
HDMI-1-0 disconnected (normal)
Identifier: 0x43
Timestamp: 36654
Subpixel: horizontal rgb
Clones:
CRTCs: 3 4
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
dither: off
supported: off, on
audio: auto
supported: off, on, auto
underscan vborder: 0
range: (0, 128)
underscan hborder: 0
range: (0, 128)
underscan: off
supported: off, on, auto
coherent: 1
range: (0, 1)
1366x768 (0x45) 75.1MHz
h: width 1366 start 1414 end 1446 total 1564 skew 0 clock 48.0KHz
v: height 768 start 771 end 776 total 800 clock 60.0Hz
Adding the output of:
-Dorg.lwjgl.util.Debug=true
[LWJGL] Xrandr extension version 1.4
[LWJGL] Using Xrandr for display mode switching
[LWJGL] Exception in XRandR.populate(): 2
I just crafted a possible fix: tfg13/lwjgl@0b83683
Before we commit anything, please try this fix by manually replacing lwjgl.jar with the one from this test release: https://github.com/tfg13/lwjgl/releases/tag/test_lwjgl%23112
I will test it and let you know. But it will be a few days until I have the opportunity.
Works perfectly! Thank you for the fix. When will it be merged/released?
I've run into a similar problem that I'm adding here, because I think it's related closely enough. I too am using a notebook with two graphics cards, but I usually connect an external monitor to it and then disable the notebooks's monitor. When I do this, I get this error:
Exception in thread "LWJGL Application" java.lang.ExceptionInInitializerError
at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setVSync(LwjglGraphics.java:446)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:118)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.lwjgl.opengl.XRandR.findPrimary(XRandR.java:326)
at org.lwjgl.opengl.XRandR.ScreentoDisplayMode(XRandR.java:315)
at org.lwjgl.opengl.LinuxDisplay$3.run(LinuxDisplay.java:746)
at org.lwjgl.opengl.LinuxDisplay$3.run(LinuxDisplay.java:743)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.opengl.LinuxDisplay.init(LinuxDisplay.java:743)
at org.lwjgl.opengl.Display.<clinit>(Display.java:138)
... 2 more
AL lib: (EE) alc_cleanup: 1 device not closed
When I disable the external monitor and instead enable the notebook's monitor, it works out just fine.
This is the output for xrandr -q
when I'm using the external monitor:
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
LVDS1 connected (normal left inverted right x axis y axis)
1600x900 60.00 +
1440x900 59.89
1360x768 59.80 59.96
1152x864 60.00
1024x768 60.00
800x600 60.32 56.25
640x480 59.94
VGA1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
VIRTUAL1.735-1920x1080 60.00*
VIRTUAL1.736-1680x1050 59.95
1440x900 59.89
VIRTUAL1.738-1280x1024 75.02
VIRTUAL1.739-1280x1024 60.02
VIRTUAL1.740-1280x960 60.00
VIRTUAL1.741-1280x720 60.00
VIRTUAL1.742-1024x768 75.03
VIRTUAL1.743-1024x768 70.07
1024x768 60.00
VIRTUAL1.745-800x600 75.00
VIRTUAL1.746-800x600 72.19
800x600 60.32 56.25
VIRTUAL1.749-640x480 75.00
VIRTUAL1.750-640x480 72.81
640x480 59.94
VIRTUAL2 disconnected (normal left inverted right x axis y axis)
VIRTUAL3 disconnected (normal left inverted right x axis y axis)
VIRTUAL4 disconnected (normal left inverted right x axis y axis)
VIRTUAL5 disconnected (normal left inverted right x axis y axis)
VIRTUAL6 disconnected (normal left inverted right x axis y axis)
VIRTUAL7 disconnected (normal left inverted right x axis y axis)
VIRTUAL8 disconnected (normal left inverted right x axis y axis)
VIRTUAL9 disconnected (normal left inverted right x axis y axis)
And here's what I get when I'm using the notebook's monitor:
Screen 0: minimum 8 x 8, current 1600 x 900, maximum 32767 x 32767
LVDS1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
1600x900 60.00*+
1440x900 59.89
1360x768 59.80 59.96
1152x864 60.00
1024x768 60.00
800x600 60.32 56.25
640x480 59.94
VGA1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 connected (normal left inverted right x axis y axis)
VIRTUAL1.735-1920x1080 60.00
VIRTUAL1.736-1680x1050 59.95
1440x900 59.89
VIRTUAL1.738-1280x1024 75.02
VIRTUAL1.739-1280x1024 60.02
VIRTUAL1.740-1280x960 60.00
VIRTUAL1.741-1280x720 60.00
VIRTUAL1.742-1024x768 75.03
VIRTUAL1.743-1024x768 70.07
1024x768 60.00
VIRTUAL1.745-800x600 75.00
VIRTUAL1.746-800x600 72.19
800x600 60.32 56.25
VIRTUAL1.749-640x480 75.00
VIRTUAL1.750-640x480 72.81
640x480 59.94
VIRTUAL2 disconnected (normal left inverted right x axis y axis)
VIRTUAL3 disconnected (normal left inverted right x axis y axis)
VIRTUAL4 disconnected (normal left inverted right x axis y axis)
VIRTUAL5 disconnected (normal left inverted right x axis y axis)
VIRTUAL6 disconnected (normal left inverted right x axis y axis)
VIRTUAL7 disconnected (normal left inverted right x axis y axis)
VIRTUAL8 disconnected (normal left inverted right x axis y axis)
VIRTUAL9 disconnected (normal left inverted right x axis y axis)
So it's basically just the difference of the indicated mode in use.
I'd be glad if someone with more insight into this library could have a look at this -- I only came over here from another project because I noticed this behaviour. :)
Looking at the org.lwjgl.opengl.XRandR code I see that the following resolution string will not be parsed correctly.
1920x1080i 60.1* 50.0 60.0
That is because the pattern SCREEN_MODELINE_PATTERN= "^(\d+)x(\d+)$"
Such resolution string will cause
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.lwjgl.opengl.XRandR.findPrimary(XRandR.java:326)
Please provide fix for that cases.
Yeah, xrandr modelines can contain all kind of funny content these days.
Maybe one could try something like:
private static final Pattern SCREEN_MODELINE_PATTERN = Pattern.compile("^(\\S*\\D)?(\\d+)x(\\d+)(\\D\\S*)?$");
Also, change line 122:
- Integer.parseInt(m.group(1)), Integer.parseInt(m.group(2)),
+ Integer.parseInt(m.group(2)), Integer.parseInt(m.group(3)),
This should match almost anything before or after the screen resolution, and therefore also fix #121
Warning: I don't have the time to test this, I never even tried to compile it.
There still seems to be some edge cases that this misses. I am unable to launch minecraft (1.11.2
at the time of reporting) if the modeline I'm using is 2560x1440_60.00
. If I drop the _60.00
it launches.
Yup, LWJGL2 relies on these modelines to find out about screen resolutions.
This is a bad strategy, because the modeline can be any arbitrary text whatsoever.
I wrote a semi-technical explanation how this came to be in the forums a while ago: here.
Unfortunately, there isn't much you can do about this, patching the regex again and again will not fix the underlying problem, and there probably won't be any bigger rewrites on LWJGL since it is EOL. The best thing for you is to not use "exotic" modelines and nag at Mojang until they switch to LWJGL3.