0

I have finalized a video game for Android Smartphones that works fine when the Real Time is not too strong (ie. the player provides an event each second). But, when I use it "with determination as a geek", an error outside my JavaFX code is raised (approximately every 15-20 minutes).

My SW architecture is simple: a loop activated each 110 ms, the accelerometer sensor and the AndroidNativeAudio class for sounds

I have added some debug traces:

  • at the beginning and the end of the loop,

  • some traces in AndroidNativeAudio and the sensor (optional).

In these conditions, I have noticed that the error trace is OUTSIDE my code (loop + accelerometer) and the AndroidNativeAudio code: the trace mentions that my code is completely performed before the error is raised. So, I am stuck.

Have you already encountered this kind of problem with Javafx on a Real Time game running on Android smartphone?

Where could I get the JavaFxPorts (including MediaPlayer) source code with debug trace of the javafxports for trying to understand the problem source?

If I don't find the problem source, migrating my JavaFX code (20 000 Javafx lines) to Java in Android studio could be an eventuality (but that would be a heavy work that I'ld want to avoid).

Thanks for your feedback

Note: The compiler option for detecting some leak memory in my code is set and there is no code problem, at this time.


Additional info: the FATAL exception systematically occurs with that message (outside my code i.e. after the end of the processing inside the 110ms loop):

E/AndroidRuntime(14369): FATAL EXCEPTION: JavaFX Application Thread

E/AndroidRuntime(14369): Process: com.gluonapplication, PID: 14369

E/AndroidRuntime(14369): java.lang.ArrayIndexOutOfBoundsException: length=20; index=-1

E/AndroidRuntime(14369): at java.util.ArrayList.get(ArrayList.java:310)

E/AndroidRuntime(14369): at javafx.scene.Parent.updateCachedBounds(Parent.java:1583)

E/AndroidRuntime(14369): at javafx.scene.Parent.recomputeBounds(Parent.java:1527)

E/AndroidRuntime(14369): at javafx.scene.Parent.impl_computeGeomBounds(Parent.jav

Pascal DUTOIT
  • 121
  • 1
  • 13
  • You can find the specific JavaFXPorts source code [here](https://bitbucket.org/javafxports/8u-dev-rt/src/60645062fc15332ad8279b77b18418f755db5b05/modules/graphics/src/dalvik/java/javafxports/android/?at=default), but there is no JavaFX Media on Android, that's why you are using the `AndroidNativeAudio` class. You can add debugging info there. – José Pereda Aug 07 '17 at 10:02
  • José: I am looking for JavaFXPorts source code already including system output for debugging. My aim is to substitute the API by a "debug API".Thus, I could test my game with ALL layers in debug and detect the location of the problem. I have not enough skill for understanding all concepts used in the JavaFXports source code, useful for adding judicious "println" – Pascal DUTOIT Aug 12 '17 at 14:45
  • 1
    There is no such debug API (all debug info is already added an available, see tag `FXEntity` for instance). You could fork the repo and add it before building it, but this is far from a trivial task. You can debug the app instead (see [this](https://stackoverflow.com/questions/44970567/run-debugger-on-javafx-project-in-android/44988910#44988910)), adding as much logging as possible to your code. – José Pereda Aug 12 '17 at 16:29
  • After many investigations, it seems to be that when I artificially slow down the processing by adding many debug traces, the problem (FATAL exception) disappears. So, I suspect a Real Time problem in JavaFX API where two concurrent threads access on a same data, involving a table index problem (see the added trace above). An idea for searching in this direction? – Pascal DUTOIT Aug 18 '17 at 08:38
  • José: do you know how many threads there are in a "JavaFX layer" and what are they (name, priority, ...)? – Pascal DUTOIT Aug 18 '17 at 08:59
  • I can't say. You keep finding that AIOOB exception all the time. Maybe worth checking again the reasons why it might happen. – José Pereda Aug 18 '17 at 10:51
  • I use jfxdvk-8.60.8 and jre1.8.0_66 – Pascal DUTOIT Aug 20 '17 at 16:12
  • José: a patch on JavaFX8 seems to solve a similar problem. See https://bugs.openjdk.java.net/browse/JDK-8096304 The trace: E/AndroidRuntime(16193): java.lang.ArrayIndexOutOfBoundsException: length=45; index=-1 ..... E/AndroidRuntime(16193): at java.util.ArrayList.get(ArrayList.java:310)..... E/AndroidRuntime(16193): at javafx.scene.Parent.updateCachedBounds(Parent.java:1583). If you agree, which official JFX jar version could solve this problem OR (but more difficult) how to build its own JavaFX jar, as mentioned in http://hg.openjdk.java.net/openjfx/8u-dev/rt/rev/eb251121a360? Thanks – Pascal DUTOIT Aug 20 '17 at 16:22
  • The patch you mentioned is already added to the [jfxdvk](https://bitbucket.org/javafxports/8u-dev-rt/src/5dfa492a736d8f1678fcd05605ddd518f44fd7b8/modules/graphics/src/main/java/javafx/scene/Parent.java?at=default&fileviewer=file-view-default) dependency. So this issue is not related, but the exception may happen for other reasons. – José Pereda Aug 20 '17 at 21:53
  • I agree with you: I have replaced the jdk 66 by the jdk 141, .. without success – Pascal DUTOIT Aug 21 '17 at 12:27
  • I am using the javafxports 8.60.8 version . Could the 8.60.9 version solve the problem? – Pascal DUTOIT Aug 21 '17 at 12:38
  • You should use 8.60.9 anyhow, as that contains the latest changes, but as I linked above, that still relies on 8u60. Also, your local JDK doesn't make a difference, JavaFX is added from the jfxdvk jar. – José Pereda Aug 21 '17 at 13:11
  • The problem has been solved :) A TimerTask and the periodical processing used the same instance but sometimes this one was removed by the processing whereas the TimerTask still wanted to use it. A little bit tricky to investigate that error among 20 000 Java code lines because the verbose trace did not point out the source of the problem but only a generic Array index error. Perhaps, that is due to the fact that this instance was used by two different kinds of classes. Anyway, thank you for your help. Now, my game can work more than 8 hours without error :) – Pascal DUTOIT Sep 03 '17 at 16:12
  • Glad you finally solved it! – José Pereda Sep 03 '17 at 16:16
  • José: I can end about a JavaFX use for Android games. The JavaFX Transitions (Parallel, Path, Scale, Fade, Sequential, Rotate, Translate) disturb a little bit the Real Time. I can assert that because I had built the game on PC with all these transitions. So, when I moved it to Android, I noticed some response time problems. Progressively, by changing all these transitions (except Rotate and Translate) by a sequential processing (110 ms), the execution has been improved from 360 ms to 60 ms. Perhaps, in JavaFxPorts, it would be interesting to create transitions classes that sequentially work. – – Pascal DUTOIT Sep 12 '17 at 06:16

0 Answers0