JavaFX on iOS and Android - are we there yet?

Richard Bair richard.bair at oracle.com
Tue Oct 22 08:22:10 PDT 2013


> 1. Can you provide me with a detailed summary of where the iOS/Android
> ports are currently?

I got this from Tomas today (with some minor modifications):

*************************
-Text rendering
Hopefully the last thing remaining to have Android fully opensourced is native text rendering support. Of course there are also media but replacing t2k with the native text has been main obstacle for opensourcing. The whole text stuff has to be commented out to be able to run it on dalvik. I hope I can get this feature into repository in 1-2 days unless it's too late for integrating features. Even it will be for simple layout only. Complex texts won't be displayed.

- WebView
WebView is very basic. It is native webkit and works as an overlay (always on top no properly z-ordered) correctly sized and positioned. Some callbacks work too.

-Media
No current open implementation for Android. We currently have a working prototype based on Open SLES (for audio) and OpenMAX AL (for video). It's far from being a full blown implementation of the media API, it can be used for demonstration purposes though. We would need at least one more sprint to polish the code and prepare it into a presentable form (as a prototype). The implementation imposes significant limitations on the set of media formats supported. As for audio, we support MP3 and WAV. The only one video format supported is H.264/AAC in MP2TS container. Video implementation uses an overlay (similarly to webview)

- Dalvik compatibility
If you want to run on dalvik you need jdk6 compatible javafx. I found it easier to create my local version of jdk6 compatible javafx instead relying on any 3rd party solution. Likely the repository which RoboVM uses will work either instantly or with minimal changes. There is not only problem of lambdas but also missing APIs (java.function, sun.misc packages for example) in dalvik. I don't know how robovm guys do it and what's the current status of their repository.

-Performance
Startup time is good on dalvik. Simple HelloWorld is up in about 2 seconds.

- Problems?
Many. Lack of testing on dalvik vm.
Problems in threading when delivering events from dalvik to jfx runtime. I will fix that in next sprint.
Screen rotation and sending application into background doesn't work well.
Multitouch and native softkeyboard worked well on our vm but no testing has been done on dalvik.
*************************

Hopefully we'll get the media prototype out soon, although it has significant issues as you can see (back to the heavyweight / lightweight issues). Personally I'm interested in RoboVM on Android, so that there is a single VM across both iOS and Android. Also if RoboVM supported the OpenJDK class libraries, it would make this so much simpler for us and provide a consistent story. For example, the OpenJFX project is an OpenJDK project and we really can't be officially promoting a VM that doesn't implement the Java standard. It puts us in a very awkward position. If RoboVM used the OpenJDK class libraries instead of the Android class libraries, not only could I push it at conferences like JavaOne, but I could also put support directly into the OpenJFX build system for building FX and running FX apps (like Hello*, Modena, Ensemble, etc) directly on RoboVM without developers having to setup anything special. This would be huge for making it easy for people to contribute iOS fixes to OpenJFX. But I can't do that if RoboVM doesn't actually implement "Java".

I took a quick look, and it doesn't look like it would be trivial to do. There are 600+ native methods in the Android class libraries and 3000+ native methods in the OpenJDK class libraries, and unfortunately they don't match up. So basically somebody would need to visit the various classes and make sure they work, one by one. At least, I don't know of an easier way to go about it.

For example, the Apache java.lang.Object implementation is:

private native Object internalClone(Cloneable o);
public final native Class<?> getClass();
public native int hashCode();
public final native void notify();
public final native void notifyAll();
public final native void wait(long millis, int nanos) throws InterruptedException;

Whereas the OpenJDK java.lang.Object implementation is:

private static native void registerNatives();
public final native Class<?> getClass();
public native int hashCode();
protected native Object clone() throws CloneNotSupportedException;
public final native void notify();
public final native void notifyAll();
public final native void wait(long timeout) throws InterruptedException;

So it wouldn't be a simple case of swapping out the Java sources without also having to modify native files. For Android it might be that we can reuse all (or virtually all?) of the Linux OpenJDK native implementation, and the iOS one might be very close to the Mac implementation. However somebody will need to be familiar with the OpenJDK implementation and the RoboVM implementation to make it happen, which will have a bit of a learning curve. Any takers? It looks like a couple month project, but one that would be both interesting and very useful (for more than just JavaFX).

Richard



More information about the openjfx-dev mailing list