Bug #1225

RCP: 0.7.7, SWT_AWT bridging is bugged with the couple SWT 4.4 + JRE 7/JRE 8 on MAC OS X

Added by Sebastien Jacquot almost 5 years ago. Updated over 4 years ago.

Status:Feedback Start date:01/08/2015
Priority:Immediate Due date:
Assignee:- % Done:

80%

Category:Charts Spent time: -
Target version:TXM X.X

Description

Charts don't work anymore on MAC OS X with last setup.
All SWT/AWT bridges in Composite are affected:
R chart engine, JFC chart engine and "old" SVG Batik Editor (it's the one used when opening an SVG file from the "File" view, the one which was used in TXM <= 0.7.5)

SWT_AWT bridging is bugged with the couple SWT 4.4 (or >= 4.0 ?) + JRE 7/JRE 8 on MAC OS X

With R chart engine and "old" SVG Batik Editor => TXM hangs up
With JFC charts engine => TXM slows down and the chart is not displayed/refreshed

Involved classes:
  • /org.txm.rcp/src/main/java/org/txm/rcp/chartsengine/jfreechart/swt/JFCComposite.java
  • /org.txm.rcp/src/main/java/org/txm/rcp/chartsengine/svgbatik/swt/SVGComposite.java
  • /org.txm.rcp/src/main/java/org/txm/rcpapplication/svg/SVGComposite.java

If someone thinks about some others AWT/SWT bridges in TXM RCP, please let me know.

See:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=418245
http://mail.openjdk.java.net/pipermail/macosx-port-dev/2013-November/006252.html
https://bugs.openjdk.java.net/browse/JDK-8020165

Solution 1

Asynchronously call frame.setVisible(true) in the Swing thread (invokeLater()) or in the SWT main thread (Display.getDefault().asyncexec())

h3 .Observation

The JFC charts are well displayed but the UI and the refresh of the chart are slowed. Plus, the asynchronous call may be problematic since the chart editor part needs the chart to be constructed so it's too strongly linked to the runtime execution context.

Solution 2

Keep Java 1.6 as embedded JRE version

Important note

This note is also strongly linked to the choice of the JVM version that will be embedded in TXM. It seems one of the next Oracle JVM direction is to switch from Swing to JavaFX as default GUI API. JavaFX is now natively included in Java 8 API.

Conclusion

The only viable solution seems to stay in Java 1.6 for the embedded JVM version.
(Actually get back to Eclipse 4.3 may also fix this issue)

Validation tests

History

#1 Updated by Sebastien Jacquot almost 5 years ago

  • Description updated (diff)

#2 Updated by Sebastien Jacquot almost 5 years ago

  • Description updated (diff)

#3 Updated by Sebastien Jacquot almost 5 years ago

  • Description updated (diff)

#4 Updated by Sebastien Jacquot almost 5 years ago

  • Description updated (diff)

#5 Updated by Matthieu Decorde almost 5 years ago

  • Description updated (diff)

#6 Updated by Sebastien Jacquot almost 5 years ago

  • Description updated (diff)

#7 Updated by Sebastien Jacquot over 4 years ago

I confirm this bug using Oracle JDK 1.8.0_25-b17.

#8 Updated by Sebastien Jacquot over 4 years ago

  • Status changed from New to Feedback
  • % Done changed from 0 to 80

"Fixed" for now by keep using Java 1.6 for Mac OS X target.

#9 Updated by Sebastien Jacquot over 4 years ago

  • Target version changed from TXM 0.7.7 to TXM X.X

I move this ticket to TXM X.X target to keep track of this in case we want to update Java in the future.

#10 Updated by Sebastien Jacquot over 4 years ago

As said by an Eclipse developer, this bug won't be fixed in Eclipse 4.5: https://bugs.eclipse.org/bugs/show_bug.cgi?id=418245
(Pity for us because we are stuck in Java 1.6)

#11 Updated by Sebastien Jacquot over 4 years ago

After further investigation, the bug may be linked to the graphics acceleration that doesn't seem to be activated with the JDKs I tested (Sun Java 1.8.0_25 and openjdk 1.7.0-u60-unofficial).

When launching this simple test case from Eclipse which does NOT containing any SWT code at all with Java > 1.6:

import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Panel;
import java.awt.Rectangle;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class TestAWTOnly2 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

         Frame frame = new Frame("test");
         frame.setSize(800,600);

         frame.addWindowListener(new WindowAdapter() {
             public void windowClosing(WindowEvent windowEvent){
                System.exit(0);
             }        
          });    

         java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout());

            Panel chartPanel = new Panel()    {
                 public void paint( Graphics g ) {
                        g.setColor( getBackground() );
                        g.fillRect( 20, 50, getSize().width, getSize().height );
                        g.setColor( getForeground() );
                        Rectangle border = new Rectangle( 100, 20, 14, 50 );
                        g.drawRect( border.x, border.y, border.width, border.height );
                    }
            };

            panel.add(chartPanel); 

        frame.add(panel);

        frame.setResizable(true);
        frame.setVisible(true);
    }

}

this message appears in Eclipse console:

WARNING: GL pipe is running in software mode (Renderer ID=0x1020400)

Then when resizing the AWT Frame created, the CPU usage increases a lot (reaching sometimes 70% of usage), maybe due of the software rendering.

This problem (maybe linked to an other problem related to the bridge) may be the cause of the bug leading to the non-drawing of the JFC and SVG AWT/Swing components. After some tests with TXM + Java 1.8, the CPU usage also increases a lot after trying to create a JFC chart and resizing the TXM windows. Using the old SVG Batik EditorPart, the behavior is a few different, CPU usage doesn't increase but the application hangs up.

NOTE: link to a basic SWT_AWT bridge snippet: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet135.java

Need to find if it's possible to enable hardware acceleration with Java 1.7/1.8 on Mac OS X. Also need to find the relation between the JRE and XQuartz. For example, Apple Java 1.6 can use hardware acceleration through XQuartz or through OpenGL. I guess the hardware acceleration enabling behavior in Java 1.7/1.8 is strongly linked to the MAC OS X version and the graphics hardware (e.g. embedded or not embedded GPU).

Also available in: Atom PDF