Xinerama prevents Java fullscreen exclusive mode in Gutsy

Bug #154613 reported by Dan Munckton
20
This bug affects 2 people
Affects Status Importance Assigned to Milestone
icedtea-java7 (Ubuntu)
Won't Fix
Undecided
Unassigned
openjdk-6 (Ubuntu)
Fix Released
Undecided
Unassigned
sun-java6 (Ubuntu)
Fix Released
Undecided
Dan Munckton

Bug Description

Update: This bug has evolved a little, the summary for this bug now reflects the root cause of the problem, discovered later in the comments. It seems Java fullscreen exclusive mode is not supported when Xinerama is present in Xorg. In Gutsy it seems it is there on all installations (that I've tested) which means no Java fullscreen exclusive mode apps/games will run.

Original Description: While testing a Java fullscreen mode application in Gutsy I have discovered that Java does not find the full list of supported display modes it only lists the current screen resolution even though the xrandr command lists all supported screen modes. Consequently it cannot use full screen exclusive mode in any other resolution than the current one in use. This is a regression as the problem does not occur in Feisty.

I've tested this on 2 completely different machines first with Feisty and then with Gutsy.

I've attached a sample Java program DisplayModeLister which outputs a list of supported screen modes. Here's it's output on Gutsy:

  1: 1440 x 900 @ 0Hz -1bit

Here's the xrandr command's output on Gutsy:

  Screen 0: minimum 320 x 200, current 1440 x 900, maximum 1440 x 1200
  VGA-0 disconnected (normal left inverted right)
  LVDS connected 1440x900+0+0 (normal left inverted right) 0mm x 0mm
     1440x900 59.9*+
     1280x800 60.0
     1280x768 60.0
     1024x768 60.0
     800x600 60.3
     640x480 59.9
  S-video disconnected (normal left inverted right)
  DVI-0 disconnected (normal left inverted right)

Here's DisplayModeLister's output on the same machine running Feisty:

  1: 1440 x 900 @ 60Hz -1bit
  2: 1024 x 768 @ 60Hz -1bit
  3: 800 x 600 @ 60Hz -1bit
  4: 640 x 480 @ 60Hz -1bit
  5: 640 x 350 @ 60Hz -1bit
  6: 640 x 400 @ 60Hz -1bit
  7: 720 x 400 @ 60Hz -1bit
  8: 1152 x 864 @ 60Hz -1bit
  9: 832 x 624 @ 60Hz -1bit
 10: 1280 x 768 @ 60Hz -1bit
 11: 1280 x 800 @ 60Hz -1bit
 12: 1152 x 768 @ 60Hz -1bit

This result is the same in Java 5 and 6. Here are the package versions:

Feisty:
  * sun-java6 6-00-2ubuntu2
  * xorg 1:7.2-0ubuntu11
  * libxrandr 1.2.0-3ubuntu1
  * xrandr 1.0.2-0ubuntu1

Gutsy:
  * sun-java6 6-03-0ubuntu2
  * xorg 1:7.2-5ubuntu13
  * libxrandr 2:1.2.1-1
  * xrandr 1:1.2.2-0ubuntu1

Related branches

Revision history for this message
Dan Munckton (munckfish) wrote :
Revision history for this message
Dan Munckton (munckfish) wrote :

Right. I've been digging into this a little.

As expected the deb source for sun-java6 just includes the *.bin files from Sun, no source code. I tried to find the Java 6 source but the link just goes to the java.net binary downloads page.

Instead I tested again with Icedtea and found it also exhibits the same problem, so I feel fairly happy it's probably using roughly the same code as Java 6. After a little hunting I located the JNI call Java_sun_awt_X11GraphicsDevice_enumDisplayModes(...) in http://icedtea.classpath.org/hg/openjdk/file/ce9dde984c21/j2se/src/solaris/native/sun/awt/awt_GraphicsEnv.c. It's using XRandr calls to get the list of modes. I've coded up a quick C test binary using the same algorithm (attached xrandr-lsmodes.c) and it worked fine on Feisty and Gutsy. Could it be this is a regression in Java 6 u3?

There doesn't seem to be an upstream bug, so I'll raise one.

Output of xrandr-lsmodes.c on Feisty:

  1: 1440 x 900 @ 60Hz -1bit
  2: 1024 x 768 @ 60Hz -1bit
  3: 800 x 600 @ 60Hz -1bit
  4: 640 x 480 @ 60Hz -1bit
  5: 640 x 350 @ 60Hz -1bit
  6: 640 x 400 @ 60Hz -1bit
  7: 720 x 400 @ 60Hz -1bit
  8: 1152 x 864 @ 60Hz -1bit
  9: 832 x 624 @ 60Hz -1bit
 10: 1280 x 768 @ 60Hz -1bit
 11: 1280 x 800 @ 60Hz -1bit
 12: 1152 x 768 @ 60Hz -1bit

Output on Gutsy:

  1: 1440 x 900 @ 60Hz -1bit
  2: 1280 x 800 @ 60Hz -1bit
  3: 1280 x 768 @ 60Hz -1bit
  4: 1024 x 768 @ 60Hz -1bit
  5: 800 x 600 @ 60Hz -1bit
  6: 640 x 480 @ 60Hz -1bit

Revision history for this message
Dan Munckton (munckfish) wrote :

More testing

  * Java 6u3 on Win XP (same machine) - OK
  * Java 6u3 from java.sun.com bin on Feisty - OK
  * Java 6u3 unpacked from gutsy source (6-03-0ubuntu2) on Feisty - OK

So it looks like it's just a problem on Gutsy.

Dan Munckton (munckfish)
description: updated
Revision history for this message
Dan Munckton (munckfish) wrote : Re: Java cannot change display modes / screen resolution in Gutsy

Yet more testing

  * Java 6u3 from java.sun.com bin on Gutsy - FAIL

Revision history for this message
Dan Munckton (munckfish) wrote :

Right I believe I have found the cause of all this: Xinerama.

Xinerama is enabled on Gutsy but not on Feisty. The JNI native function Java_sun_awt_X11GraphicsDevice_initXrandrExtension() is careful not to use Xrandr if Xinerama is enabled. In sun/awt/X11GraphicsDevice.java the overridden method getDisplayModes() calls its parent implementation (which returns just the current display mode) if isFullScreenSupported() returns false. isFullScreenSupported() returns false because Java_sun_awt_X11GraphicsDevice_initXrandrExtension() skips using Xrandr because of Xinerama.

So to get full screen mode working again we need to

  * See if Xrandr and Xinerama will work together safely and get the AWT code updated to support this in OpenJDK. I would presume any work of this size is unlikely to be back-ported to Java 6, so I guess it will be at least Java 7 final before we could see this all working well again. I wonder if this work is already underway? I will send a mail to the awt-dev mailing list at OpenJDK to see if anything is happening.
  * In the meantime Xinerama could be disabled on machines which need to use full screen mode applications. I need to find out how this is done.

Changed in icedtea-java7:
status: New → Confirmed
Changed in sun-java6:
status: New → Confirmed
Dan Munckton (munckfish)
description: updated
Revision history for this message
Conrad Knauer (atheoi) wrote :

Dunno if it would help at all, but instead of the sun-java6 packages, maybe try the icedtea-java7 packages?
(IcedTea is a GPL derivative of Sun's Java, launched by Red Hat; see http://en.wikipedia.org/wiki/IcedTea)

Revision history for this message
Dan Munckton (munckfish) wrote :

Thanks Conrad. Yes IdedTea also has the problem, I already added it as an affected package.

Dan Munckton (munckfish)
Changed in icedtea-java7:
assignee: nobody → munckfish
Changed in sun-java6:
assignee: nobody → munckfish
Revision history for this message
Dan Munckton (munckfish) wrote :

UPDATE

This week I've been pestering people on the ubuntu-x, awt-dev (OpenJDK) and xorg mailing lists about this.

As of Xorg server 1.3 the Xinerama backend implementation has been replaced with a 'fake' Xrandr one [0] which now handles the Xinerama protocol. Unfortunately this has changed the interface slightly; the real Xinerama would not initialise if there is only 1 monitor [1], but the Xrandr one now does [2].

Current thinking (thanks to 'ajax' on #xorg) is that Java needs to call XRRQueryVersion() and if returns >= 1.2 then go ahead and use RANDR even if Xinerama is present.

Have also submitted a bug report to the Java Bug Database and now await Sun reviewing it.

Next week I'm going (to try) to prepare a patch to resolve this.

[0] http://gitweb.freedesktop.org/?p=xorg/xserver.git;a=blob;f=randr/rrxinerama.c
[1] See PanoramiXExtensionInit(...) in http://gitweb.freedesktop.org/?p=xorg/xserver.git;a=blob;f=Xext/panoramiX.c
[2] See RRXineramaExtensionInit(void) in [0]

Revision history for this message
Kevin Bulgrien (kbulgrien) wrote :

Apologies for this AWFUL HACK that is NOT RECOMMENDED, but, it makes an excellent point... To fix full-screen mode:

  $ hexedit /usr/bin/X11/Xorg
  Replace XINERAMA with ZINERAMA, or anything else for that matter.

I'd give credit where credit is due, but the perps might not appreciate it...

Revision history for this message
mo (morten-s) wrote :

Awful but it works :) Remember to backup the Xorg executable first, and be careful about encodings and such in emacs, if you use it to edit binary files.

Dan Munckton (munckfish)
Changed in icedtea-java7:
status: Confirmed → In Progress
Changed in sun-java6:
status: Confirmed → In Progress
Revision history for this message
Dan Munckton (munckfish) wrote :

UPDATE

Patch attached in upstream list which re-enables FSEM mode for the xorg server 1.3+:

http://mail.openjdk.java.net/pipermail/2d-dev/2008-January/000129.html

Awaiting approval from java2d team for inclusion in OpenJDK6 and 7.

Noted some rather random issues with mouse/cursor disappearing when changing screen mode not yet sure if it's a Java 7 thing or Xorg server prob - need to test in a Java 6 build.

Revision history for this message
japheth (dmp1488) wrote :

I downloaded the patch, but what do I do to apply it? I tried simply running it, but that just gave me several errors. I'm using ubuntu 7.10.

Revision history for this message
japheth (dmp1488) wrote :

I figured out that I was supposed to use the patch program. However, I tried "patch <attachment.bin" and it asked me where the original file was. Could anyone tell me where it is? I tried searching for awt_GraphicsEnv.c, but didn't find anything.

Revision history for this message
Dan Munckton (munckfish) wrote :

Hi japheth

The patch modifies Java's C programmed base, and therefore requires a complete rebuild of Java from source code.

To apply it on Ubuntu you'd need to learn a little about Ubuntu software packaging [0] and package maintenance [1], or compile your own independent version of either OpenJDK or IcedTea [2].

I'm hoping to find time to do this work myself for the IcedTea packages, then I will upload a debdiff file here which can be used to create an updated Ubuntu package and would hopefully (if approved) make it into a proper Ubuntu update.

[0] https://wiki.ubuntu.com/PackagingGuide
[1] https://wiki.ubuntu.com/PackagingGuide/Recipes/PackageUpdate
[2] http://openjdk.java.net/guide/

Cheers

Revision history for this message
Dan Munckton (munckfish) wrote :

Ok raw patch attached.

Revision history for this message
Matthias Klose (doko) wrote :

this is fixed in hardy in the openjdk-6 package (icedtea-java7 was removed from hardy). I do not intend to backport the fix to gutsy.

Changed in icedtea-java7:
status: In Progress → Won't Fix
Revision history for this message
Dan Munckton (munckfish) wrote :

Actually this isn't fixed in Hardy yet. doko: I think I confused you on IRC.

Suggested changelog entry (doko requested)

  * Make Java Full Screen Exclusive Mode work again with Xorg Server 1.3 and above. LP: #154613 (Java bug 6636469).

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package openjdk-6 - 6b08-0ubuntu2

---------------
openjdk-6 (6b08-0ubuntu2) hardy; urgency=low

  * Update IcedTea build infrastructure.
  * Configure with --enable-zero on all archs except amd64, i386, lpia.
  * Make Java Full Screen Exclusive Mode work again with Xorg Server 1.3
    and above (Dan Munckton). LP: #154613 (Java bug 6636469).

 -- Matthias Klose <email address hidden> Thu, 03 Apr 2008 11:58:15 +0000

Changed in openjdk-6:
status: New → Fix Released
Revision history for this message
Dan Munckton (munckfish) wrote :

Thanks doko!

Revision history for this message
Scott Van Wart (silvaran-gmail) wrote :

I get something of an error regardless which JVM I use (I used java6, java5, and downloaded 1.4.2 directly from Sun). I'm not sure exactly how related this is, but I get other problems (I have a Java app whose Oracle JDBC driver can't even do a simple connect to a database). The JVM doesn't CRASH, but it does have a few xinerama references in the stack trace. I don't know if this is related to bug #174759 or not, but see attachment in case it rings any bells.

Dan Munckton (munckfish)
Changed in icedtea-java7:
assignee: munckfish → nobody
Revision history for this message
Dan Munckton (munckfish) wrote :

As of update 10 this is now fixed in Sun Java 6.

http://bugs.sun.com/view_bug.do?bug_id=6636469

Changed in sun-java6:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.