[Support request] Mac Os Retina crash with JME+Swing

Hello Monkeys,
I’ve finally finished the 1st version of my very first JME desktop application.
It works smoothly in every computer except in Mac Os.

The software is made with JME + Swing (for the GUI).
The guy who reported this problem is using a MacBookPro with a Retina display.
When he tries to open the application, he just sees a white screen and the software stops working if he tries to resize the window.

I haven’t added a crash reporter yet, so the only log he could send is this:
[/quote]
Date/Time: 2014-09-14 19:45:43 -1000
OS Version: 10.9.4 (Build 13E28)
Architecture: x86_64
Report Version: 18

Command: MyGame
Path: /Library/Internet Plug-ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
Version: ??? (???)
Parent: Jar Launcher [66136]
Responsible: Jar Launcher [66136]

PID: 66138
Event: hang
Duration: 1.34s
Steps: 14 (100ms sampling interval)

Hardware model: MacBookPro10,1
Active cpus: 8
Fan speed: 2563 rpm

Free pages: 92214 pages (-3273)
Pageins: 7 pages
Pageouts: 0 pages
Swapins: 64 pages
Swapouts: 0 pages

Process: MyGame [66138]
Path: /Library/Internet Plug-ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
Architecture: x86_64
Parent: Jar Launcher [66136]
Responsible: Jar Launcher [66136]
UID: 502
Task size: 42602 pages (+40)
CPU Time: 0.095s
[/quote]

Did anyone already have this problem?
Is there any newbie mistake I’m doing?
Could it be a threads lock (I don’t think so because on Windows it works…)?

Thanks monkeys for the useful support! :slight_smile:
Axel

The problem here is probably, that with retina the real resolution and the reported ones do not match at all.

Workaround would be to simple disallow resizing on macosx for now, and make it via an settings dialog only initial.

Wich exactl jvm version is running? older ones have no real support for retina and use the blurring fallback mode.

Did you try with a simplified testcase? Eg. only the swing frame with the context in it, but without your application logic, to rule out errors there?

I think @normen is using mac as well? Maybee he can confirm this.

@Empire Phoenix said: The problem here is probably, that with retina the real resolution and the reported ones do not match at all.

Workaround would be to simple disallow resizing on macosx for now, and make it via an settings dialog only initial.

Wich exactl jvm version is running? older ones have no real support for retina and use the blurring fallback mode.

Did you try with a simplified testcase? Eg. only the swing frame with the context in it, but without your application logic, to rule out errors there?

I think @normen is using mac as well? Maybee he can confirm this.

Thanks Empire Phoenix for the answer!
He said he’s running Java 7 update 67, so it shouldn’t be because of the Java version.
I’ll try with a testcase (just GUI+JME without any logic) but I don’t own a Mac and for this reason it will be difficult for me.
The weirdest thing is that the application is a completely white screen immediately (so no one is actually resizing it).
Waiting for @normen then, he could know what’s happening :slight_smile:

Still haven’t found a solution and I cannot test as I don’t have any Mac.
I’ve created a simple program (GUI+Scene only) to check if it works or not, could any Mac user try it?
It’s safe and the link is: http://www.mediafire.com/download/r33t130cz99hn8u/MyGame-MacOSX.zip

There’s nothing but Swing without listeners and a simple JME scene.

Thanks to all,
Axel

I don’t have a mac with retina display so in CIA style I can neither confirm nor deny this issue :wink:

@normen said: I don't have a mac with retina display so in CIA style I can neither confirm nor deny this issue ;)

ahah thanks anyway for the reply Normen
Is there any other Mac user that can try my test application? :slight_smile:

Hope I won’t need to buy a Mac to test applications :stuck_out_tongue:

Ok so, the problem with the Retina screen is caused by Swing. JME works perfectly.
This is how the program looks like in Retina displays:

This is how the program should be:

Do you have any documentation/reference for fixing this Retina mess?

Thank you,
Axel

Use AWT panels, this is probably related to the new way of LWJGL to paint into AWT windows natively. AWT panels will also allow you to open more than one jME window in a swing app. You could also try and use a newer LWJGL version, maybe they fixed the issue by now. But you’d have to create your own jME3-lwjgl-natives.jar for that from the binaries.

@normen said: Use AWT panels, this is probably related to the new way of LWJGL to paint into AWT windows natively. AWT panels will also allow you to open more than one jME window in a swing app. You could also try and use a newer LWJGL version, maybe they fixed the issue by now. But you'd have to create your own jME3-lwjgl-natives.jar for that from the binaries.

Forgive my ignorance,
I’m using several Swing components and JPanels to make the main structure. What should I exactly replace with the AWT panels?
Also how can I check the LWJGL version that JMonkeyEngine is using right now? :slight_smile:

Thanks in advance,
Axel

Check the AWT panels example, jME uses lwjgl 2.9.0 by default.

@normen said: Check the AWT panels example, jME uses lwjgl 2.9.0 by default.

Thanks Normen for the really useful answers,
I have checked both things.
Seems that lwjgl 2.9.1 has the possibility to enable HighDPI from VM parameter and from code before creating the Display ( http://www.lwjgl.org/wiki/index.php?title=Using_High_DPI_Mode ).
The problem is that I’m not directly creating the Display (JME does it) and I don’t know where I could add the code to make it run correctly (I would also need to check if the display is a Retina, but this shouldn’t be a problem).
This is probably the best way to fix it, although I’m not really sure how to create the .jar from the binaries.
The awt panel is basically a better Canvas, which could allow us to open many JME windows but I’m sure it won’t really solve the problem.

So the 2 final questions now are:
how can I add in my application “System.setProperty(“org.lwjgl.opengl.Display.enableHighDPI”, “true”);” before the Display creation?
how do I create my own jME3-lwjgl-natives.jar from the binaries?
I would just need any reference or documentation :slight_smile:

Thank you again,
Axel

I suggest just before the call to start,
so maybee in the main method?

For the other, just take a look at it inside, via 7zip winrar ect.
Then you can by hand recreate it with other binarys.

@Empire Phoenix said: I suggest just before the call to start, so maybee in the main method?

For the other, just take a look at it inside, via 7zip winrar ect.
Then you can by hand recreate it with other binarys.

So what you mean is just creating a new zip called “jme3-libraries - lwjgl.jar” with the new lwjgl version inside+an updated manifest file?
Anyway thanks, I’ll try this way and tell you the results :slight_smile:

Look inside the existing natives jar for the file structure. A jar is just a zip file basically, so make the same folder structure, zip it and then rename it.

@normen said: Look inside the existing natives jar for the file structure. A jar is just a zip file basically, so make the same folder structure, zip it and then rename it.
Yeah sorry, this is what I meant, going to try it, thanks guys :D

Hi guys,
sorry for the late reply, I have been pretty busy these days!
I have done several tests and I’ve discovered that my problem (of Canvas position) is common in all Macs (Retina and non-Retina).
So far I’ve:

  • tried to fix the Canvas in the GUI adding a JPanel as container of the Canvas, but it didn’t do much
  • tried to force Revalidation of the Canvas and the parent component (the JPanel)
  • tried the AWT Panel provided in JME (but seems that you cannot attach and detach the AWTPanel dinamically, which is really needed for me)

I don’t know if it’s a jME3-lwjgl library bug, but it works perfectly on Windows and Linux.
Do you guys have any tip? I’ve seriously run out of ideas :frowning:

Thank you in advance!

Little update:
After many sad other tests, this is what happens now:

  • When you open the program, the canvas is in the wrong place (top-left corner of the window, intead of the center (I’m using BorderLayout.CENTER for it)).

  • If you just resize the window, the canvas will stay in the top-left corner.

  • If you switch tab, the GUI won’t refresh correctly (except for the canvas which refreshes dimensions but it is still in the wrong position), like if the canvas existence is blocking the SWING repainting process.

  • If you switch tab AND resize the window, the GUI is correctly refreshed and the canvas is in the right place (so in this case it works, but I don’t get why).

You can check these things in this video: My Edited Video - YouTube

From these 3 points (which happen on Macs only) I suppose that when switching tab+resizing the window something happen in Swing process. We would need to call this “something” every time, but we don’t know which methods are called.

Again, any little try or help would be really useful,
Axel

I’d stilly try using AWT panels instead of the canvas, they generally behave much better in an AWT environment because you don’t mix heavyweight AWT with lightweight AWT and OpenGL in one app.

Yes, you’re right, it must be for sure the right way. But I have 2 problems:

  1. AWT panel is unloaded when I detach it (I need to reattach in another tab everytime the user changes tab)
  2. AWT panel seem to thread lock at the beginning: I create the AWT Panel (so the LWJGL thread) and start the JME app. Then I create my Swing GUI which requires some data from the JME thread (which is supposely the LWJGL thread) and the software just freezes.

Are there solutions for those 2 problems?
Otherwise, is there a way for coding my own JPanel which actually behaves like the AWT panel?

Thanks @Normen :slight_smile:

  1. If the problem with that is that the render thread stops while doing that you can change that behavior.
  2. Depends on how you grab the data from the lwjgl thread, you should do so asynchronously, not using locks.
1 Like