Bug 94589 - [Wayland] xrandr has different output format when running in XWayland
Summary: [Wayland] xrandr has different output format when running in XWayland
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/General (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-17 12:57 UTC by Christian Stadelmann
Modified: 2016-04-06 11:39 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Christian Stadelmann 2016-03-17 12:57:28 UTC
When comparing outputs of xrandr on a regular X server and on XWayland, there are some differences:

1. Within a weston instance:
$ xrandr
Screen 0: minimum 320 x 200, current 1024 x 640, maximum 8192 x 8192
   1024x640@60.0Hz  59.89*+

2. Within a gnome+wayland session:

Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192
XWAYLAND0 connected 1360x768+0+0 340mm x 190mm
   1360x768@0.1Hz   0.00*+

3. From a regular X server:

Screen 0: minimum 8 x 8, current 1366 x 768, maximum 32767 x 32767
LVDS1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
1366x768      60.00*+
1280x720      60.00
1024x768      60.00
1024x576      60.00
960x540       60.00
800x600       60.32    56.25
864x486       60.00
640x480       59.94
720x405       60.00
680x384       60.00
640x360       60.00
DP1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
VGA1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

This contains a break in how the output is formatted, from
[width]x[height]  [Frequency][[*]][[+]]
to
[width]x[height]@[Frequency]  [a different Frequency][[*]][[+]]
which in turn breaks lwjgl [1]. Is this change intended?


[1] https://github.com/LWJGL/lwjgl/issues/118

Affected versions (present since at least 9 months):
xrandr from xorg-x11-server-utils-7.7-17.fc23.x86_64
xorg-x11-server-Xwayland-1.18.2-1.fc23.x86_64

$ xrandr --version
xrandr program version       1.4.3
Server reports RandR version 1.5

also affects xrandr 1.5.0
Comment 1 Olivier Fourdan 2016-03-17 13:27:52 UTC
Xwayland exposes only one output and one mode which breaks lwjgl-2.x xrandr parsing:

  https://bugzilla.redhat.com/show_bug.cgi?id=1287864
  https://bugzilla.redhat.com/show_bug.cgi?id=1236389

But the key point IMHO is that lwjgl should not be using xrandr as an external command and then try (wrongly) to parse its output to get the list of supported modes, it should rather use the appropriate libXrandr that does all this programatically with a stable API for years.

FWIW, xrandr is a command not part of the Xserver, so Xwayland is not responsible for the formatting returned by xrandr.
Comment 2 Olivier Fourdan 2016-03-17 13:35:06 UTC
(In reply to Olivier Fourdan from comment #1)
> [...]
> FWIW, xrandr is a command not part of the Xserver, so Xwayland is not
> responsible for the formatting returned by xrandr.

I take taht back, Xwayland does set the mode name that contains the "@" that could cnfuse the lwjgl parser, and a fix is easy.
Comment 3 Olivier Fourdan 2016-03-17 13:40:42 UTC
Can you try with this patch:

https://patchwork.freedesktop.org/series/4573/
Comment 4 Olivier Fourdan 2016-03-17 13:42:34 UTC
=> Moving to Xserver as the mode name is returned by the Xwayland in this case.
Comment 5 Olivier Fourdan 2016-03-17 13:51:32 UTC
I just tested the patch with lwjgl-2.9.3 and it works on Xwayland wit hthe fix applied, yay!:

1. Download lwjgl 2.x from http://sourceforge.net/projects/java-game-lib/
2. Unzip the archive lwjgl-2.9.3.zip
3. From the directory created by unzipping the archive, run the test:

$ java -cp .:res:jar/lwjgl.jar:jar/lwjgl_test.jar:jar/lwjgl_util.jar:jar/jinput.jar: -Djava.library.path=native/linux org.lwjgl.test.WindowCreationTest

(this is from http://wiki.lwjgl.org/wiki/Downloading_and_Setting_Up_LWJGL)
Comment 6 Pekka Paalanen 2016-03-17 14:19:11 UTC
(In reply to Olivier Fourdan from comment #1)
> But the key point IMHO is that lwjgl should not be using xrandr as an
> external command and then try (wrongly) to parse its output to get the list
> of supported modes, it should rather use the appropriate libXrandr that does
> all this programatically with a stable API for years.

However, this comment is absolutely totally correct.

User can easily create modes with arbitrary names AFAIK, both with xorg.conf and with xrandr the tool. There is no rule that says the mode name must be "<width>x<height>".

For example:

$ xrandr --newmode "you're scwered"  75.50  1288 1352 1480 1672  725 728 738 753 -hsync +vsync
$ xrandr --addmode DP-1 "you're scwered"
$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 2280, maximum 8192 x 8192
VGA-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 connected 1600x1200+0+0 (normal left inverted right x axis y axis) 408mm x 306mm
   1600x1200R    59.92*+
   1600x1200     60.00 +  60.00  
   1280x1024     75.02    60.02  
   1280x960      60.00  
   1152x864      75.00  
   1024x768      75.08    70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   640x480       75.00    72.81    66.67    60.00  
   720x400       70.08  
DP-1 connected 1920x1080+0+1200 (normal left inverted right x axis y axis) 477mm x 268mm
   1920x1080     60.00*+
   1680x1050     59.95  
   1600x900      59.98  
   1280x1024     60.02  
   1440x900      59.89  
   1280x720      59.97  
   1024x768      60.00  
   800x600       60.32  
   640x480       60.00  
   720x400       70.08  
   you're scwered  59.97  
HDMI-2 disconnected (normal left inverted right x axis y axis)
HDMI-3 disconnected (normal left inverted right x axis y axis)


Note how the mode name contains an apostrophe, a space, a typo, and no numbers.
Comment 7 Olivier Fourdan 2016-03-17 14:42:14 UTC
(In reply to Pekka Paalanen from comment #6)
> (In reply to Olivier Fourdan from comment #1)
> > But the key point IMHO is that lwjgl should not be using xrandr as an
> > external command and then try (wrongly) to parse its output to get the list
> > of supported modes, it should rather use the appropriate libXrandr that does
> > all this programatically with a stable API for years.
> 
> However, this comment is absolutely totally correct.

Yeah, I closed the downstream bugs because of this, but...

> [...]
> $ xrandr --addmode DP-1 "you're scwered"

Can't parse that, there is a typo ^^^^^^^  :-)

> [...] 
> Note how the mode name contains an apostrophe, a space, a typo, and no
> numbers.

Sure, yet fixing the lib might not be so simple because it's usually embedded in Java packages (e.g. minecraft) and we can as well make it work by default for most people not willing to change the name of the modes, with a pretty low risk trivial patch...
Comment 8 Christian Stadelmann 2016-04-06 11:39:27 UTC
Fixed in https://cgit.freedesktop.org/xorg/xserver/commit/?h=server-1.18-branch&id=fcb89adb4a6cde585923e63d3c34df465aa78d1b for 1.18.3. Thank you!

New output looks like this:

$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
XWAYLAND0 connected 1920x1080+0+0 530mm x 300mm
   1920x1080      0.00*+


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.