PNG's In Mac on Java cause massive CPU usage - java

Hey, I've been having this problem for a while now and I was hoping someone could help.
I make small games using Java on Mac OSX 1.6.3 and if I use PNG's as the image format my CPU usage by Java skyrockets to say 50% (on a very small 2D game). However if I use GIF as the format my CPU usage by Java stays constant at 10% which is reasonable.
What is causing this problem?? It occurs on every game I develop using PNG's so I always just switch to GIF's.
The problem is now that i need to use a PNG for its variable alpha properties rather than just plain transparency. This is not available using GIF's.
The problem is present on Java SE 6 and previous versions. I am using an early 2009 Mac Book Pro 15".
The problem does not occur on a Windows PC running the same game. The CPU usage due to Java using PNG's on a Windows PC (I have tried XP, Vista and 7) is always constantly low at ~10%.
Any help would be greatly appreciated.
Thanks :)

Transparency is probably at the root of the issue, since it's a rather expensive feature. My guess is that Java2D on Mac doesn't use hardware acceleration, while on Windows it does.
Are you running the JRE that comes with MacOS?

Related

Java would only run on Compatibility Mode set to Windows 98 or older

My Java SE (8u111) just won't work. I can't open java programs. Not even the Java Control Panel. I have reinstalled 5 times over, and java just won't work. Everytime i try to open Java (The CP or Program) it appears in Taskmgr, does some work (CPU and Disk rate is picking up), then the rates goes back to 0 (except memory), and Java closes itself without any error notices.
The first time i installed Java, it worked without compatibility mode.
Now, it doesn't.
The only things i did before it breaks are:
I updated Intel HAXM
I turned on Intel VT
I ran Remix OS Player
Java breaks.
After it breaks, i did these to solve:
Uninstall Intel HAXM
Disabled Intel VT
Reinstalled Java 5 times over, one in a different drive
Still doesn't work.
If i apply compatibility mode set to Windows 98 / Windows Me or older, it works. But if i set it to Windows XP or newer, it will not work. Do anybody know why?
I run Java SE 8u111 (on first install, never updated), on Windows 10 version 1607
Intel Core i5-7200U, Nvidia Geforce 920MX, all running on a new 2 week old laptop.
One more thing, i doubt this'll help but, I use custom DPI Scaling (145%)
Test by launching from the console. it's as simple as typing java -jar path-to-your-jarfile into the terminal (can be opened with "win+r" and typing "cmd"). That might at least give you an idea what is the actual problem. --Paul
Thank you Paul for suggesting! After i run my java programs from the console, i found that all of the programs' crashes was caused by java.lang.IllegalArgumentException: 33 incompatible with Text-specific LCD contrast key.
I did a quick google search and read https://www.rarst.net/software/cleartype-install4j-java-bug/.
Then i remembered that, i have modified the registries of cleartype before java breaks. So i re-calibrated the cleartype settings through Windows Control Panel, and now... Everything works! All of the java programs, Java Control Panel, and java on the web is now working!
I might have figured out why the compatibility mode only works on Windows 98 or older. My cleartype parameters was invalid and java could not process the cleartype. Cleartype was implemented on Windows XP (i think). With compat. mode telling Java that this machine is Windows 98, Java would not start collecting configs and information on cleartype and/or load cleartype, making it not crash.
My problem is solved! Thank you!

Guidance on Java issue on Mac

I have come across a major wall and hopefully someone can help me out.
Preface:
We have a desktop application (JavaFX based). It speaks to Canon camera using Canon's SDK. Hence one can download the latest Image taken, get notifications about camera events and so on. And it works all well on Windows.
Now the SDK is 32-bit based and hence the JVM we use has to be 32-bit based (64-bit JVM is incompatible, fullstop).
Coming to Mac
There is no Java-7 for 32-bit Mac. Hence we have got to us Java-6 which is no Issue (WIth -d32 VM argument). But it turns out that there is no Java-FX for Java6 on Mac. How can I bundle my application with Java6 and Java-FX? Any nightly build wil help? Or any other manual tweaks? Else it will demand a lot of restructuring of the code.

Is it possible to run Java3D applications on Nvidia 3D Vision hardware in windowed mode?

Thanks to JohnnyO it was already answered if it is possible to run Java3D application in conjunction with nVidia 3D vision:
Is it possible to run Java3D applications on Nvidia 3D Vision hardware?
His approach also worked fine for me. But it is restricted to full screen mode.
His thread is already a few months old, and now during the last few weeks nVidia improved its drivers for 3D Vision: Now it is possible to run many applications also in windowed mode. If you are using professional hardware like the nVidia Quadro cards or ATI Fire GL, you know and appreciate the windowed mode already for a very long time.
Now, with the latest updates of the nVidia drivers (I have currently installed 295.73) it is also possible to run many applications like the nVidia Picture Viewer, the Stereoscopic Player etc. in windowed mode.
http://nvidia.custhelp.com/app/answers/detail/a_id/2311
Normally DirectX 9 applications should run in windowed mode, as you can read on the previously mentioned nVidia page. And I think Java 3D is a DirectX 9 application. If I use:
-Dj3d.debug=true
Then the console says:
[j3d] Using DirectX D3D 9.0 or higher.
(And of course no one seems to be working on the improvement of the DirectX implementation of Java 3D these says.)
Did somebody meanwhile find out the trick how to run Java3D in Stereo windowed mode? I tried it, but I failed so long. I think this will be a very important argument pro Java 3D, if we solve this issue!
One thing I noticed when I played around with this was that the 3D vision drivers weren't kicking in, even when I thought I had everything set up correctly.
One hack we found was that the nVidia drivers were actually only configured to support specific video games on their whitelist, but the whitelist matching was just based on exe names.
After lots of problems and frustration, we renamed our Java wrapper from myprogram.exe to something from the whitelist, things worked much better. I think for a while, or exe was named BatmanAC.exe in testing or something like that. This seemed to make the nVidia drivers much more permissive to what we wanted to do.

Is it possible to run Java3D applications on Nvidia 3D Vision hardware?

Is is possible to run a Java3D application on Nvidia 3D Vision hardware?
I've got an existing Java3D application that can run in stereoscopic 3D. In the past, I've always run the application on Quadro cards using the OpenGL renderer and quad buffered stereo.
I now have access to a laptop with the nVidia 3D Vision system (with a GeForce GTX 460M). From the documentation, it seems like it should be possible to run my application in stereo if I use the DirectX bindings and let the nVidia drivers take care of the stereo, however, this does not seem to be the case.
If I run a Java3D application with j3d.rend=d3d, the nVidia 3D Vision API doesn't seem to recognize it as a DirectX application.
How can I get the nVidia 3D Vision drivers to detect a Java3D application and render in stereoscopic 3D?
I'm disappointed that so far everyone has dismissed this as impossible right out of the gate. I've been working on this for the past several days, and made some headway. So far, I've found that it is possible, but with a few caveats:
You need the latest drivers from nVidia (280.29 as of this writing)
You need to use the Direct3D renderer, not the OpenGL renderer (-Dj3d.rend=d3d)
You need to force Direct3D to run in fullscreen mode. (-Dj3d.fullscreen=REQUIRED)
You need to run using a ConfiguredUniverse in fullscreen mode (I'm using the provided j3d-1x1.cfg that is available in the Java3D documentation)
In order to get it working on a 64-bit machine, I had to use the 64-bit dlls for Java3D, which someone has helpfully provided on the Java3D forums (http://home.java.net/node/705510) This may or may not be required on a 32-bit system.
Future releases of the nVidia drivers promise improved support for windowed-mode stereo, so its possible that this will become easier in the future (possibly eliminating the need for option 3 and/or 4 above)
I'll also investigate if rebuilding the Java3D source with some additional nVidia bindings can eliminate the fullscreen requirement, and repost with the results.
Java3D uses something called "Quadbuffer Stereo", i.e. two distinct doublebuffered framebuffers, one for the left and one for the right eye. NVidia considers this thing "professional grade", although it is impossible to to proper stereoscopy without accurate control of the content of both eyes.
3D Vision however inserts some shaders to create an in-situ stereo separation. This however only works with programs giving it some hints through the 3D Vision API. Java3D doesn't.
Let's just hope that Microsoft will indeed push Quadbuffered Stereo as a core requirement of DirectX 12 Graphics, so that NVidia has no longer lame excuses to keep this from "consumer grade" OpenGL.
java3D does not support the 3d vision api but it may work with any direct x program
This is may outdated, but I have the binary DirectX libs for Java3D 64. It is the j3dcore-d3d.dll .
If someone needs it, send a message to me.
From readme.txt file :
======
README
Java3D DirectX 9.0 Renderer for 64bits
January, 2010
Hi
The companion j3dcore-d3d.dll is a Java3D renderer
for Microsoft DirectX D3D in 64bit. This uses exactly
same source code from 32bits, but compiled with Visual
studio 2005 for Windows 64bits.
It was tested with Windows XP Pro. 64bit Edition,
Vista 64 and Windows-7 64. In both nVidia and ATI drivers.
Usage
Drop the j3dcore-d3d.dll in the same folder you have j3dcore-ogl.dll.
Dependency
Use it with a 64bit JRE.
It requires Java3D for Windows AMD 64, available at
https://java3d.dev.java.net/binary-builds.html
It also needs a DirectX driver update
You can get it http:\www.microsoft.com\directx
Current full link for DirectX Web Setup :
http://www.microsoft.com/downloads/details.aspx?familyid=2DA43D38-DB71-4...
This last link points to a very small web updater for DirectX runtime.
Disclaimer
This is for testing purposes only. Use it at your own risk.
This IS NOT endorsed or supported by Sun, Oracle or any other company.

Java 6 Hardware Acceleration on Mac OS X

I have a java application I wrote that loads up a TTF font and uses the drawString method from Graphics2D. This gets called every 50ms with the x and y positions changing each time to make the text move. When I run the program on Windows, I get 0-1% CPU usage, but on Mac I get about 75% usage. This Windows machine does have a better CPU but there's no way there should be that big of a difference. I think it has to do with Hardware Acceleration and I want to know how enable it. I found some Mac specific Java properties, but none of them lowered my CPU usage. Any ideas how to increase Java 2D performance on OS X? Thanks.
EDIT1: I thought that these properties would help but they didn't.
System.setProperty("sun.java2d.opengl", "true");
System.setProperty("apple.awt.graphics.UseQuartz","true"); System.setProperty("apple.awt.graphics.EnableQ2DX","true");
EDIT2: You can download the project source and byte code here: http://drop.io/ExampleScreenSaver
EDIT3: Since drop.io no longer exists, I uploaded the project to Google Code. Now you can browse the code without downloading it. I still have no idea how to approach this problem so any help would be appreciated.
Run the profiler in "jvisualvm" to identify where the time goes.
Apple JVM font handling is specific to MacOS X. For instance, if a glyph is not found for a character in the current font, the JVM looks for another font to display the character. Also, antialiasing is enabled by default (you should check that you have it enabled on Windows if you want to compare).
I am not surprised Apple's implementation is using more CPU.
OpenGL can be enabled when calling java e.g.
java -Dsun.java2d.opengl=true MyJavaGame
Too enable opengl from inside your java application
System.setProperty("sun.java2d.opengl", "true");
Not sure how this pans out on the iOS / Linux / Android and may require more looking into.

Categories

Resources