Canvas3D resize problem

classic Classic list List threaded Threaded
42 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

gouessej
Administrator
I think that this change just exposes us to this bug in Oracle Java:
http://bugs.java.com/view_bug.do?bug_id=8017776

@runiter please try the workaround I suggested in one of my posts just to confirm I'm right. Call those few lines very early.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

runiter
gouessej, do you mean this solution?

if(AppContext.getAppContext() == null){
    SunToolkit.createNewAppContext();
}

I assumed AppContext refers to sun.awt.AppContext.

I just tried it and it didn't work. I also pop a dialog box to show the content of AppContext.getAppContext(). It is never null.
Here you can try:

http://www.runiter.com/webstart/test_gc3/grapher.jnlp
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

gouessej
Administrator
This post was updated on .
Actually, your latest example works with OpenJDK 1.7 update 45 and Icedtea Webstart :D

I fear that the AppContext is seen as null in a particular class loader.

Edit.: AppContext is stored in something like a ThreadLocal, I'm right. You have to call the workaround in the right context, depending on the current thread when calling AWTEDTExecutor.invoke().
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

runiter
Judging from the exception it seem to be called from javax.media.j3d.J3dThread.run()

In that case, what's the code to set the context inside J3dThread? I'm not very familiar with thread contexts
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

gouessej
Administrator
Actually, I'm not sure that the workaround can work without modifying JOGL source code. Maybe you should rather try to reproduce this bug with a simple AWT GLCanvas so that you can report it against JOGL and not against Java3D.

I advise you to look at that to understand the workaround:
http://kingsfleet.blogspot.fr/2009/10/how-to-have-more-than-one-instance-of.html
http://www.docjar.com/docs/api/sun/awt/AppContext.html
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

runiter
I never really programmed directly in JOGL before so it will be difficult for me to come up with a test case that breaks it the way Java3D breaks it. Looks to me that JOGL seem to function fine by itself so perhaps Java3D needs to update the way it calls JOGL to be consistent with the new way JOGL initiates.

Meanwhile this is the Java3D test case I have. I removed all calls to my own application so it's pure Java3D. It still crashes upon call to new SimpleUniverse().

Testcase jnlp:
http://www.runiter.com/webstart/test_gc3/grapher.jnlp

Testcase Source Code:

package runiter.grapher;

import javax.media.j3d.BranchGroup;
import javax.swing.JOptionPane;

import sun.awt.AppContext;
import sun.awt.SunToolkit;

import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.SimpleUniverse;

public class MainApplication {


        public static void main(final String[] args) {
                try {
                        System.out.println("Initiating...");
                        JOptionPane.showMessageDialog(null, "AppContext.getAppContext() = " + AppContext.getAppContext());
                        if(AppContext.getAppContext() == null){
                                SunToolkit.createNewAppContext();
                                JOptionPane.showConfirmDialog(null, "AppContext.getAppContext() was null. It was recreated!");
                                JOptionPane.showMessageDialog(null, "AppContext.getAppContext() = " + AppContext.getAppContext());
                        }

                        JOptionPane.showMessageDialog(null, "final SimpleUniverse universe = new SimpleUniverse();");
                        final SimpleUniverse universe = new SimpleUniverse();

                        JOptionPane.showMessageDialog(null, "final BranchGroup group = new BranchGroup();");
                        final BranchGroup group = new BranchGroup();

                        JOptionPane.showMessageDialog(null, "group.addChild(new ColorCube(0.3));");
                        group.addChild(new ColorCube(0.3));

                        JOptionPane.showMessageDialog(null, "universe.getViewingPlatform().setNominalViewingTransform();");
                        universe.getViewingPlatform().setNominalViewingTransform();

                        JOptionPane.showMessageDialog(null, "universe.addBranchGraph(group);");
                        universe.addBranchGraph(group);
                } catch (final Throwable e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(null, "Exception Occured: " + e.getMessage());
                }
        }
}
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

Sven Gothel
Administrator
On 02/22/2014 06:09 PM, runiter [via jogamp] wrote:
> I never really programmed directly in JOGL before so it will be difficult for
> me to come up with a test case that breaks it the way Java3D breaks it. Looks
> to me that JOGL seem to function fine by itself so perhaps Java3D needs to
> update the way it calls JOGL to be consistent with the new way JOGL initiates.
>
> Meanwhile this is the Java3D test case I have. I removed all calls to my own
> application so it's pure Java3D. It still crashes upon call to new
> SimpleUniverse().

Thank you both!

Maybe you can create a bugreport w/ _all_ the info of this thread,
including Julien's hint that this might be an Oracle Java issue ?

(Source code, stack traces, platform .. beef of this discussion)

Does it run well w/ IcedTea-Web and OpenJDK ?

~Sven



signature.asc (894 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

runiter
I don't have Linux so I can't try OpenJDK, but gousses says it worked with his OpenJDK after I added his workaround.

I filed a bug report here:

https://jogamp.org/bugzilla/show_bug.cgi?id=983
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

gouessej
Administrator
It works even without my workaround with OpenJDK as only the proprietary version of Java is concerned by this bug.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

runiter
I stand corrected. Only Oracle webstart causes this problem.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

runiter
Gouessej, do you have any updates on this?
In the bug report, Harrison promised to fix it but looks like he didn't have time to do anything about it yet.

Thanks in advance
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

Sven Gothel
Administrator
On 03/18/2014 06:23 AM, runiter [via jogamp] wrote:
> Gouessej, do you have any updates on this?
> In the bug report, Harrison promised to fix it but looks like he didn't have
> time to do anything about it yet.

Maybe it is possible that more people who are using Java3D
participate fixing it - since it's all available as free software ?

This is not for this particular issue, but in general ..

I am sure that Harvey will love to see your git patches/pull-req.

Go go go .. :)

Just a thought ..

~Sven



signature.asc (894 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

runiter
I'd love to, but in this particular I'm not sure how to fix it. Harrison mentioned a simple problem with thread group context. Well I never worked directly with thread context before, but okay I'll see what I can do.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

hharrison
I completely forgot about it, but Emmanual had already given me a patch for JCanvas3d which you can find here, that would be at least something for you to compare to when doing a similar patch for Canvas3D.

https://github.com/hharrison/java3d-utils/commit/14206478b7a5bf628b59094c92d5727291c7c2bf

Harvey
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

runiter
Great, thanks Harrison, that certainly helps!
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

runiter
I fixed the bug. You can find the patch under comments:

https://jogamp.org/bugzilla/show_bug.cgi?id=983

Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

hharrison
Can you email me a diff, and let me know what name/email you'd like to appear in the Author field when I commit this.

harvey.harrison@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

runiter
Thanks Harvey. I sent you an email.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

hharrison
Applied, and released in Java3d 1.6.0-pre10

http://jogamp.org/deployment/java3d/1.6.0-pre10/

Thanks a lot!!!
Reply | Threaded
Open this post in threaded view
|

Re: Canvas3D resize problem

gouessej
Administrator
In reply to this post by runiter
Great job runiter, thank you so much.
Julien Gouesse | Personal blog | Website
123