JAVAFX on ANDROID

Matthias Hänel haenel at ultramixer.com
Wed Oct 16 01:59:34 PDT 2013


Hi Tomas,


thanks for your patch.
Your way doesn't seem to be so different to the jfx78 approach except the retro-stuff ;)
In the meanwhile I am pretty sure, this will not be entirely needed since DAVLIK can run java7 
class code. 

Nevertheless, I tried your patch... 
Patching works. After adapting some files and putting the correct pathes in the configuration
I got the gradle script working. Unfortunatly, I used the tip of openjfx8. That means there 
is a lot of new stuff e.g. usage of Function.java that's required from jdk8. Which tag did you use?
B111 or are you on the cutting edge at tip? I'll try B111 from master hopefully this new stuff 
isn't in there ;)
It looks like porting Function.java back to java7 is not so easy.


regards
Matthias


Am 15.10.2013 um 15:52 schrieb tomas.brandalik <tomas.brandalik at oracle.com>:

> Hi Matthias,
> you are right when I build for dalvik I build with a flag DALVIK_VM.
> Pls be careful when building changes in native code you have to do clean build. There is still an issue in jfx gradle script.
> I create my build differently. I start with openjfx patch it to be jdk7 compatible then use retrolambda to replace class file versions to jdk6.
> If you want give it a try use attached patch and do following:
> clone openjfx
> cd rt
> patch -p1 < fix_jdk7_compat.patch
> edit android-build.sh with your paths
> android-build.sh retrojfxrt
> 
> iI will build dalvik compatible jfxrt6.jar
> 
> -Tomas
> 
> On 10/15/2013 03:07 PM, Matthias Hänel wrote:
>> Hi Tomas,
>> 
>> 
>> I couldn't stand to merge it by hand ;) I merged the changes from RT-32802 into my backport.
>> 
>> Unfortunately, it still crashes:
>> 
>> 10-15 08:59:47.182: INFO/GLASS(3644): JNI call notifyTouchEvent
>> 10-15 08:59:47.202: INFO/GLASS(3644): Window 1[0x2a41a138] isVisible=true, state=NORMAL
>> 10-15 08:59:47.202: INFO/GLASS(3644): Absolute coordinates 542,414 are on window 1[0x2a41a138] as relative coordinates 670,292
>> 10-15 08:59:47.202: INFO/GLASS(3644): Returning focused window 1[0x2a41a138]
>> 10-15 08:59:47.202: ERROR/dalvikvm(3644): ERROR: detaching thread with interp frames (count=42)
>> 10-15 08:59:47.213: INFO/dalvikvm(3644): "main" prio=5 tid=1 RUNNABLE
>> 10-15 08:59:47.213: INFO/dalvikvm(3644): | group="main" sCount=0 dsCount=0 obj=0x414c5578 self=0x2a00d090
>> 10-15 08:59:47.222: INFO/dalvikvm(3644): | sysTid=3644 nice=0 sched=0/0 cgrp=apps handle=1073811452
>> 10-15 08:59:47.222: INFO/dalvikvm(3644): | state=R schedstat=( 6545290672 1534059118 8044 ) utm=610 stm=44 core=0
>> 10-15 08:59:47.252: INFO/dalvikvm(3644): at com.oracle.dalvik.FXActivity$InternalSurfaceView.onMultiTouchEventNative(Native Method)
>> 10-15 08:59:47.252: INFO/dalvikvm(3644): at com.oracle.dalvik.FXActivity$InternalSurfaceView.dispatchTouchEvent(FXActivity.java:234)
>> 
>> Do you have any idea?
>> The error "ERROR: detaching thread with interp frames (count=42)" seems to be a thread attach/detach mistake
>> in the code. In androidLens.c there is some ATTACH_JNI_THREAD and DTACH_JNI_THREAD code.
>> There are two implementations. One that's filled with (*vm)-> and the other one is left blank.
>> Currently, the macro DALVI_VM is not defined, so the code is filled. This seems to be odd to me.
>> Actually, I tried defining DAVLIK_VM but it doesn't help. It still crashes with the sme error.
>> 
>> 
>> regards
>> Matthais
>> 
>>  
>> Am 14.10.2013 um 14:31 schrieb tomas.brandalik <tomas.brandalik at oracle.com>:
>> 
>>> Hi Matthias,
>>> cool, I'm surprised you we're able to run it on emulator. I run on device not on emulator for a long time. There wasn't  opengl extension GL_EXT_texture_format_BGRA8888 in emulator. But that could have changed overtime.
>>> Regarding events: yes there seems to be a problem which I haven't discovered. I've pushed multitouch support and broke touch events on dalvik. I will fix that soon.
>>> In order to replace t2k there is freetype library for fonts and glyphs access and harfbuzz for layouting available among system libraries.  Although google discourages to use them since they aren't part of public api. It can bring all sorts of compatibility problems (harfbuzz implementation has changed in recent android releases for example). Yes try pango if you have time to spare and share results please.
>>> 
>>> good luck
>>> -Tomas
>>> 
>>> On 10/14/2013 01:45 PM, Matthias Hänel wrote:
>>>> Hi Tomas,
>>>> 
>>>> 
>>>> never mind, I found the problem over here in the simulator ;) I had to activate the GPU support.
>>>> 
>>>> So, now I had to BGRA image format for Android and now I get JFX up and running without fonts.
>>>> 
>>>> There are two things missing:
>>>> 1. fonts        - here we probably need to get pango working for Android right?
>>>> 2. touch events - I saw that you have got a special Android proxy for the input stuff Java_com_oracle_dalvik_FXActivity_00024InternalSurfaceView_onTouchEventNative
>>>> This seems to crash for some reason. any idea? It's not that complicated but it is producing a stack trace.
>>>> 
>>>> After fixing the touch events Brickbreaker with Niklas' no-font-patch should work. I'd pleased to test this.
>>>> 
>>>> 
>>>> kind regards
>>>> Matthias
>>>> 
>>>> 
>>>> 
>>>> Am 14.10.2013 um 12:17 schrieb Matthias Hänel <haenel at ultramixer.com>:
>>>> 
>>>>> Hi Tomas,
>>>>> 
>>>>> 
>>>>> since Tobi told me he had a similiar problem in the first place with the iOS port and he managed to run JFX8 without font.
>>>>> We deactivated fonts. There is some code to deactivate and after that it looks like it is starting the JFX-Application.
>>>>> 
>>>>> 10-14 06:06:49.529: INFO/GLASS(1546): glass_view_drawBegin
>>>>> 10-14 06:06:49.529: INFO/javafx(1546): Using getAndroidNativeWindow() from glass.
>>>>> 10-14 06:06:49.579: ERROR/libEGL(1546): called unimplemented OpenGL ES API
>>>>> 10-14 06:06:49.579: ERROR/libEGL(1546): called unimplemented OpenGL ES API
>>>>> 10-14 06:06:49.579: ERROR/libEGL(1546): called unimplemented OpenGL ES API
>>>>> 10-14 06:06:49.579: ERROR/libEGL(1546): called unimplemented OpenGL ES API
>>>>> 10-14 06:06:49.579: ERROR/javafx(1546): Some video driver error or programming error occurred. Framebuffer object status is invalid. (FBO - 823)
>>>>> 10-14 06:06:49.579: ERROR/libEGL(1546): called unimplemented OpenGL ES API
>>>>> 10-14 06:06:49.579: ERROR/javafx(1546): Error creating framebuffer object with TexID 1)
>>>>> 10-14 06:06:49.599: ERROR/libEGL(1546): called unimplemented OpenGL ES API
>>>>> 10-14 06:06:49.649: ERROR/libEGL(1546): called unimplemented OpenGL ES API
>>>>> 10-14 06:06:49.649: ERROR/libEGL(1546): called unimplemented OpenGL ES API
>>>>> 10-14 06:06:49.649: ERROR/libEGL(1546): called unimplemented OpenGL ES API
>>>>> 10-14 06:06:49.649: ERROR/libEGL(1546): called unimplemented OpenGL ES API
>>>>> 10-14 06:06:49.649: ERROR/libEGL(1546): called unimplemented OpenGL ES API
>>>>> 10-14 06:06:49.649: ERROR/libEGL(1546): called unimplemented OpenGL ES API
>>>>> 10-14 06:06:49.659: WARN/System.err(1546): java.lang.reflect.InvocationTargetException
>>>>> 10-14 06:06:49.669: WARN/System.err(1546): at java.lang.reflect.Method.invokeNative(Native Method)
>>>>> 10-14 06:06:49.669: WARN/System.err(1546): at java.lang.reflect.Method.invoke(Method.java:525)
>>>>> 10-14 06:06:49.709: DEBUG/dalvikvm(1546): GC_FOR_ALLOC freed 330K, 10% free 4129K/4564K, paused 32ms, total 32ms
>>>>> 10-14 06:06:49.709: WARN/System.err(1546): at com.sun.prism.es2.ES2ResourceFactory.createStockShader(ES2ResourceFactory.java:253)
>>>>> 10-14 06:06:49.709: WARN/System.err(1546): at com.sun.prism.impl.ps.BaseShaderContext.getPaintShader(BaseShaderContext.java:227)
>>>>> 10-14 06:06:49.709: WARN/System.err(1546): at com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:485)
>>>>> 10-14 06:06:49.709: WARN/System.err(1546): at com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:418)
>>>>> 10-14 06:06:49.709: WARN/System.err(1546): at com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:351)
>>>>> 10-14 06:06:49.709: WARN/System.err(1546): at com.sun.prism.impl.BaseContext.validateClearOp(BaseContext.java:116)
>>>>> 10-14 06:06:49.709: WARN/System.err(1546): at com.sun.prism.es2.ES2Graphics.clear(ES2Graphics.java:78)
>>>>> 10-14 06:06:49.719: WARN/System.err(1546): at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:460)
>>>>> 10-14 06:06:49.719: WARN/System.err(1546): at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:331)
>>>>> 10-14 06:06:49.719: WARN/System.err(1546): at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:88)
>>>>> 10-14 06:06:49.719: WARN/System.err(1546): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
>>>>> 10-14 06:06:49.729: WARN/System.err(1546): at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:276)
>>>>> 10-14 06:06:49.729: WARN/System.err(1546): at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
>>>>> 10-14 06:06:49.729: WARN/System.err(1546): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
>>>>> 10-14 06:06:49.729: WARN/System.err(1546): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
>>>>> 10-14 06:06:49.729: WARN/System.err(1546): at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:129)
>>>>> 10-14 06:06:49.729: WARN/System.err(1546): at java.lang.Thread.run(Thread.java:841)
>>>>> 10-14 06:06:49.729: WARN/System.err(1546): Caused by: java.lang.RuntimeException: Error creating vertex shader
>>>>> 10-14 06:06:49.740: WARN/System.err(1546): at com.sun.prism.es2.ES2Shader.createFromSource(ES2Shader.java:132)
>>>>> 10-14 06:06:49.740: WARN/System.err(1546): at com.sun.prism.es2.ES2Shader.createFromSource(ES2Shader.java:173)
>>>>> 10-14 06:06:49.740: WARN/System.err(1546): at com.sun.prism.es2.ES2ResourceFactory.createShader(ES2ResourceFactory.java:168)
>>>>> 10-14 06:06:49.749: WARN/System.err(1546): at com.sun.prism.shader.Texture_Color_Loader.loadShader(Texture_Color_Loader.java:47)
>>>>> 10-14 06:06:49.749: WARN/System.err(1546): ... 19 more
>>>>> 10-14 06:06:49.749: WARN/System.err(1546): java.lang.InternalError: Error loading stock shader Texture_Color
>>>>> 10-14 06:06:49.749: WARN/System.err(1546): at com.sun.prism.es2.ES2ResourceFactory.createStockShader(ES2ResourceFactory.java:256)
>>>>> 10-14 06:06:49.759: WARN/System.err(1546): at com.sun.prism.impl.ps.BaseShaderContext.getPaintShader(BaseShaderContext.java:227)
>>>>> 10-14 06:06:49.759: WARN/System.err(1546): at com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:485)
>>>>> 10-14 06:06:49.769: WARN/System.err(1546): at com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:418)
>>>>> 10-14 06:06:49.769: WARN/System.err(1546): at com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:351)
>>>>> 10-14 06:06:49.769: WARN/System.err(1546): at com.sun.prism.impl.BaseContext.validateClearOp(BaseContext.java:116)
>>>>> 10-14 06:06:49.769: WARN/System.err(1546): at com.sun.prism.es2.ES2Graphics.clear(ES2Graphics.java:78)
>>>>> 10-14 06:06:49.769: WARN/System.err(1546): at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:460)
>>>>> 10-14 06:06:49.769: WARN/System.err(1546): at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:331)
>>>>> 10-14 06:06:49.779: WARN/System.err(1546): at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:88)
>>>>> 10-14 06:06:49.779: WARN/System.err(1546): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
>>>>> 10-14 06:06:49.779: WARN/System.err(1546): at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:276)
>>>>> 10-14 06:06:49.779: WARN/System.err(1546): at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
>>>>> 10-14 06:06:49.779: WARN/System.err(1546): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
>>>>> 10-14 06:06:49.779: WARN/System.err(1546): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
>>>>> 10-14 06:06:49.779: WARN/System.err(1546): at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:129)
>>>>> 10-14 06:06:49.779: WARN/System.err(1546): at java.lang.Thread.run(Thread.java:841)
>>>>> 10-14 06:06:49.779: INFO/GLASS(1546): glass_view_drawEnd
>>>>> 
>>>>> 
>>>>> I track the error down to, compileShader in ES2Shader.java on line 130. This is returning 0 from native code.
>>>>> The native codes looks okay for me and the Android Simulator is supposed to emulate OpenGL ES 2.0 correclty, so I am not sure
>>>>> why the compileShader returns 0...
>>>>> 
>>>>> 	int vertexShaderID = glCtx.compileShader(vert, true);
>>>>>        if (vertexShaderID == 0) {
>>>>>            throw new RuntimeException("Error creating vertex shader"); //<<--- this Exception occours.
>>>>>        }
>>>>> 
>>>>> I know this is the common error from the shader compiler, but this should have worked for you,
>>>>> when you started your own application. Do you have a hint, what I could have been done wrong?
>>>>> 
>>>>> I assume right now that the native build is correctly, since it is called from java and it does
>>>>> return the correct EGLContext. This assumption might be wrong.
>>>>> 
>>>>> 
>>>>> regards
>>>>> Matthias
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> Am 12.10.2013 um 14:04 schrieb Tomas Brandalik <tomas.brandalik at oracle.com>:
>>>>> 
>>>>>> I think that PlatformLogger initialization in CssHelper was causing problems. I had to write one. Not 100% sure though I will look at it when I'm back in the office. (Or you can comment out css processing in the node.) I was able to run without font then.
>>>>>> 
>>>>>> -Tomas
>>>>>> 
>>>>>> 
>>>>>> On 10/11/2013 06:22 PM, Tom Schindl wrote:
>>>>>>> On 11.10.13 18:10, Matthias Hänel wrote:
>>>>>>>> Hi Tomas,
>>>>>>>> 
>>>>>>>> 
>>>>>>>> today, I took the time to investigate a little more time on this.
>>>>>>>> 
>>>>>>>> 1. I build an entirely new openjfx78 build for android
>>>>>>>> 2. starting this gave me several errors that lead me to the
>>>>>>>> conclusion that I need a java6 openjfx
>>>>>>>> 3. based on openjfx78 I ported it back to java6 (adapted gradled scripts, and tons of java source code)
>>>>>>>> 4. Now it's almost running on an 18th android. All libraries are firing up until the CssStyleHelper
>>>>>>>> is called with a static call to createStyleHelper.
>>>>>>>> 
>>>>>>>> That looks like the font stuff is not in jfx78. That's why "new Font" returns with null and therefore
>>>>>>> On OS-X font stuff is definately there in jfx78, but the low-level font
>>>>>>> stuff is loaded using reflection (at least this was the cause on robovm)!
>>>>>>> 
>>>>>>> Tom
> 
> <fix_jdk7_compat.patch>



More information about the openjfx-dev mailing list