Bug 411

Summary: Restore applet support / make jogl usable in managed environments again
Product: [JogAmp] Jogl Reporter: Michael Bien <bienator>
Component: coreAssignee: Sven Gothel <sgothel>
Status: VERIFIED FIXED    
Severity: blocker CC: gouessej, sgothel
Priority: P2    
Version: 2   
Hardware: All   
OS: linux   
Type: DEFECT SCM Refs:
774138544e1eec3330309ad682fa05154a07ab8d
Workaround: ---

Description Michael Bien 2010-09-09 11:01:07 CEST
locking optimizations for X11 require the host application to call GLProfile.initSingleton() prior doing any UI work.

This is not acceptable as default behavior since it breaks JOGL in managed environments (Applets, NetBeans RCP, lifecycle containers in general). This kind of optimizations should be an opt-in flag or resolved otherwise before JOGL 2 release.

regression since JOGL 1.
Comment 1 Julien Gouesse 2010-09-22 05:15:19 CEST
Calling GLProfile.initSingleton() in AbstractUIPlugin makes it work with Eclipse RCP. This workaround does not prevent random GUI freezes on focus lost.
Comment 2 Sven Gothel 2010-09-24 05:22:00 CEST
1st manual applet test:

I just tested running the same applet in 2 tabs:
   http://localhost/webstart-next/applet-gears.jnlp
   - Ubuntu 10.04, x86_64
   - Firefox 3.6.11pre-x86_64
   - Oracle Java 6u21-x86_64
   - NVIDIA 260.19.06

both applets running in the same process, and XInitThreads() has been called
_after_ AWT was in use by the applet's JVM (see below).
Result: It works.

But I have a deadlock or GL Profile not found situation using the plain javaws tool on X11,
will checking that and create a test case simulating this situation.

~Sven

+++

MozillaPlugin.setWindow sun.plugin2.main.server.MozillaPlugin@48e5855a hWndControlWindow = 83887001
MozillaPlugin.setWindow setting applet [AppletID 1] size to 600, 400
JRE 1.6.0.21: Info: XInitThreads() called for concurrent Thread support

JVMInstance.registerApplet for applet ID 2, plugin sun.plugin2.main.server.MozillaPlugin@63b9240e
JVMManager: applet launch (ID [AppletID 2]) succeeded
  Received applet ID [AppletID 2]
MozillaPlugin.setWindow sun.plugin2.main.server.MozillaPlugin@63b9240e hWndControlWindow = 83887533
MozillaPlugin.setWindow setting applet [AppletID 2] size to 600, 400
Spool AppletMessage: sun.plugin2.message.SetAppletSizeMessage@5
JRE 1.6.0.21: Info: XInitThreads() called for concurrent Thread support
Comment 3 Michael Bien 2010-09-24 07:26:00 CEST
a simple testcase would be:
 - start a non trivial swing application (JFrame, a few buttons etc) without doing any calls to GLProfile.
 - start a JOGL testcase (gears whatever).
 - dispose JOGL
 - dispose Swing

(another testcase: swap step one and two)

only than we could assume that JOGL has no side effects.
Comment 4 Sven Gothel 2010-09-25 06:12:02 CEST
commit bcad73dccb1cd0c32e3a77b3406ddc74e8f2e4ac

Unit test for Bug 411 (Pre AWT/Swing Usage, Mixed usage with JOGL):
    Added exhausting Pre AWT/Swing usage test utilizing a later JOGL init
    with GLCanvas and NEWTCanvasAWT.
    This works for NV+X11+Ubuntu+64bit, have to do more testing.
Comment 5 Michael Bien 2010-09-26 04:27:01 CEST
(for the record)
hudson build went through cleanly:
http://jogamp.org/chuck/job/jogl/174/testReport/

I also tested on u64 + ATI
Comment 6 Julien Gouesse 2010-09-27 04:43:07 CEST
Hi!

It works fine with Cent OS 5.3, Java 1.6 update 17, NVIDIA Quadro FX 3450 supporting OpenGL 2.1.2.

However, it works 50% of the time with Mandriva Linux 2010, Java 1.6 update 21, ATI Radeon 1950 Pro supporting OpenGL 1.3. When it does not work, nothing appears in the log, the window does not appear.
Comment 7 Julien Gouesse 2010-09-27 05:12:00 CEST
Gears.jnlp crashes after several focus changes. I have just updated Java, I use now the update 21 and the problem is exactly the same.
Comment 8 Julien Gouesse 2010-09-27 10:36:47 CEST
I have 2 AWT event queues on my machine when I launch Gears.jnlp :s

I have just used JStack to know where the application is blocked:
"javawsApplicationMain" prio=10 tid=0x0967bc00 nid=0x3f36 in Object.wait() [0x9f5ae000]
   java.lang.Thread.State: WAITING (on object monitor)                                 
        at java.lang.Object.wait(Native Method)                                        
        - waiting on <0xa632ca48> (a com.jogamp.opengl.impl.x11.glx.X11GLXDrawableFactory$ShareableResourceThread)
        at java.lang.Object.wait(Object.java:485)                                                                 
        at com.jogamp.opengl.impl.x11.glx.X11GLXDrawableFactory.<init>(X11GLXDrawableFactory.java:75)             
        - locked <0xa632ca48> (a com.jogamp.opengl.impl.x11.glx.X11GLXDrawableFactory$ShareableResourceThread)    
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)                                  
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)           
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)   
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)                                        
        at com.jogamp.common.util.ReflectionUtil.createInstance(ReflectionUtil.java:118)                          
        at com.jogamp.common.util.ReflectionUtil.createInstance(ReflectionUtil.java:148)                          
        at com.jogamp.common.util.ReflectionUtil.createInstance(ReflectionUtil.java:167)                          
        at javax.media.opengl.GLDrawableFactory.<clinit>(GLDrawableFactory.java:136)                              
        at javax.media.opengl.GLProfile$1.run(GLProfile.java:898)                                                 
        at java.security.AccessController.doPrivileged(Native Method)                                             
        at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:808)                                              
        at javax.media.opengl.awt.GLCanvas.<clinit>(GLCanvas.java:78)                                             
        at demos.gears.Gears.main(Gears.java:32)                                                                  
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                            
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)                          
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)                  
        at java.lang.reflect.Method.invoke(Method.java:597)                                                       
        at com.sun.javaws.Launcher.executeApplication(Launcher.java:1799)                                         
        at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1745)                                           
        at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1507)                                                
        at com.sun.javaws.Launcher.run(Launcher.java:129)                                                         
        at java.lang.Thread.run(Thread.java:619)
Comment 9 Sven Gothel 2010-10-14 23:55:04 CEST
    JOGL: Reenable Applet/Webstart/RCP support for JOGL + AWT + X11
    
    Changed GLProfile/NativeWindowFactory/.. initialization methodology:
    
        GLProfile:
            public static synchronized void initSingleton(final boolean firstUIActionOnProcess);
    
        NativeWindowFactory:
            public static synchronized void initSingleton(final boolean firstUIActionOnProcess);
    
.. read the rest in the git commit message.