-
Notifications
You must be signed in to change notification settings - Fork 146
Prism's Glyphcache management throws ArrayIndexOutOfBoundsExceptions on ListView changes #287
Comments
Given the error this seems clearly to be a JavaFX bug. Can you run it with the following flags?
|
Unfortunately I believe the logs do not give much more info on the actual error, but at least they do print a few status infos. Highlights I gathered (or see full log ) :
here somehow the UI fixes itself for a brief moment, then any further interaction with it yields us broken state again with output :
|
Perhaps the most interesting line is:
I don't know that we have too much experience with this chipset, although it seems a little odd that differences in graphics HW would cause an AIOOBE in the font rendering code. |
If I remember correctly the same happened with the Nvidia renderer on my home box though, so it might not be it indeed. Will check and send through the according logs. |
So I just checked at home, using totally different CPU/GPU system combination (AMD x Nvidia instead of Intel²) and get the same results (interestingly, I get the errors consistently instantaneously, instead of after tinkering for a few seconds). Also same behavior with GTK2 (by forcing it with Earlier line becomes
See here for trimmed logs (full_logs attached as before)
|
At this point I don't have any ideas, except that you might want to check that all accesses to all live nodes are done from the JavaFX Application thread. We will need a standalone test program that reproduces it in order to do anything more. |
Will look into making one, just hoped the need would not be there as I'm getting those custom listview through somewhat unholy abuse of cell properties and a lot of it is not on the JFX thread on the data-side so it might not be trivial to reproduce... Anyway, will let you know once I have a minimal version of it. |
I just noted the same problem in two of my programs. Google led me here and thank you for pointing me to the ListView and custom list cell rendering. I was able to track it down to the usage of Unicode characters and by removing them in the following commit I got the functionality back, without the nice looking glyphs. |
Oh that is actually a pretty great find! I wonder if it's not an issue with these special characters being actually multiple code points for example? Edit : Also if I'm not wrong you're using KDE, so it's not only a Gnome-based issue. |
Yes, it's KDE, Manjaro for me too (well NetRunner Rolling actually). |
Didn't try on a non-arch base. Would be worth testing if you have a ubuntu base somewhere as it could be stuff that fontconfig does not automatically set-up that javafx assumes? |
Seems you are closing in on the root cause. It would help if someone has a concrete reproducible code snippet? |
Ok, here we go! `public class UnicodeListViewTest extends Application {
} |
Oh I didn't realize it was not necessary to even toy with cells' graphics properties to get it to fail. |
Just closing a loop because this was asked about on the Manjaro forum too. With this snippet: import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class UnicodeListViewTest extends Application {
@Override
public void start(Stage stage) {
StackPane root = new StackPane();
ListView<String> listView = new ListView<>();
listView.getItems().addAll("a", "b", "c");
listView.getItems().add("🖉"); //Remove this row to make it work.
listView.getItems().add("d");
root.getChildren().add(listView);
Scene scene = new Scene(root, 300, 250);
stage.setTitle("Prism's Glyphcache");
stage.setScene(scene);
stage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
} and compiling with
it works fine for me: |
The fact that it works here is fairly independent of the set-up for which I reported the issue (OpenJDK 11 + OpenJFX 11 vs OpenJDK 8 + OpenJFX 8) so although it is nice, I'm not sure what to really make of it. That said if using OpenJFX 8 works, it means that the issue is probably a regression between 8 and 11. Interesting that the thread over there mentions no issues on non-arch distros. Might indeed be some fontconfig madness going on... |
I'm sorry, I failed to mention that I'm using Java 8. I have this problem with OpenJDK 8 + OpenJFX 8 and with Oracle's JDK8. I do however have Java 11 installed, but (open)jdk-8 is selected with the command I created the following ant based Apache NetBeans project: |
While it doesn't crash for me, I see something strange when I add debug information in GlyphCache.getCachedGlyph: |
@prrace do you have any thoughts on this? |
I have the same issue. Rendering in listview with serveral unicode glyphs failed. This bug is filed here: https://bugs.openjdk.java.net/browse/JDK-8189092 - but still unresolved and Priority "minor". However, the root cause is explained there: "Somewhere glyph code values have overflowed such that we are storing a negative glyph code and this results in a negative index into an array." |
Hi,
I will fix it, I assigned the forementioned bug to me...
Laurent
Le mar. 11 déc. 2018 à 12:08, klausahrenberg <[email protected]> a
écrit :
… I have the same issue. Rendering in listview with serveral unicode glyphs
failed. This bug is filed here:
https://bugs.openjdk.java.net/browse/JDK-8189092 - but still unresolved
and Priority "minor". However, the root cause is explained there:
"Somewhere glyph code values have overflowed such that we are storing a
negative glyph code and this results in a negative index into an array."
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#287 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFWOoT1P9XrpaotVl_xIi3p1BZ6Qn8Poks5u35IXgaJpZM4Yglay>
.
|
@bourgesl Thanks for offering to fix this. Can you file the JBS bug? |
I assigned JDK-8189092 to me, as I thought it was related to the same problem, I will have a look soon. |
Hi, Could someone make a synthetic summary of problems and reproducer codes ? I will then work on fixing GlyphCache (newbie) during my holidays. Thanks |
I still think, the JDK-8189092 is related to the problem in this thread also. There is an issue with GlyphCache with 2 parts:
My observations today. Sorry, I don't have a deeper knowledge about Strings in UTF-16 and UTF-32. I only recognize that Strings which have special characters included (e.g. emojies or other), crashes text components in JavaFX - always with this Exception (only the negative index is not constant): java.lang.ArrayIndexOutOfBoundsException: -11
at javafx.graphics/com.sun.prism.impl.GlyphCache.getCachedGlyph(GlyphCache.java:332)
at javafx.graphics/com.sun.prism.impl.GlyphCache.render(GlyphCache.java:148) I tried this on Linux (Antergos) with JDK-9 and also with OpenJDK/OpenJFX-12-ea. The following JavaFX app crashes reproducable with the exception above and is (one) reason for the non-working ListView described in this thread: public void start(Stage primaryStage) {
//Create an Emoji
char[] ca = new char[]{0xF0, 0x9F, 0x92, 0xB8};
String s = "Emoji: " + String.valueOf(ca);
//Create a textField that should display the prepared String
TextField textField = new TextField();
textField.setText(s);
primaryStage.setScene(new Scene(new StackPane(textField)));
primaryStage.show();
} BUT: It crashes only in Linux in my case. I tried this with Windows10/JDK11 - the result is ugly, the unknown chars are displayed as a rectangle and also number of chars is wrong, but the app is not crashing at least. Thanks a lot for any kind of solution. However, don't destroy your holiday because of this. |
@klausahrenberg thanks for your answer. I will try reproducing the issue on my work-station and if it really fails, I will spend some time (when possible) on fixing the bug, I expect it will be not too complicated as I never looked at this JavaFX aspect (GlyphCache ...) |
The fix for #125, which was just merged, won't fix the exception on Linux, since that fix was in Windows-specific code. |
Interesting, maybe fontconfig tuning could explain why returned glyphcode are different between linux distros... |
The problem is most likely due to something similar as #125 where a wrong conversion (e.g. an int being cut into a short) creates a negative index. As long as the number is small, the conversions will go fine. |
Is there any update on this? I've just hit this problem too.
|
I was curious about that high slot number and looked into it some more. It appears that each logical font has a number of linked fonts which are used to resolve missing glyphs (and a slot is assigned for each linked font as well as the original font). In my case, the font is System, physical font LiberationSans-Regular, and it has a truckload of linked fonts (well, 147), about 90% of which are various versions of Noto Sans. Almost none of those linked fonts has that pencil glyph, and it goes all the way to slot 144 which seems to be the Symbola font. |
Any recent linux distro will trigger this bug for any unicode making javafx useless on linux... this is the kind of thing that should warrant a hotfix point release. |
An update: I've disabled a metric ***ton of Noto fonts using KDE's font manager (seriously, it said 1178 fonts, and that's excluding all the Noto fonts I think I might ever use), and now GlyphCache is not crashing anymore. This confirms my previous diagnosis. |
This bug has been opened for 8 months, seemingly no activity. Javafx is, as of now, unusable on any recent linux distribution. |
I'm having exactly the same issue. I'm running on Arch Linux where the In my application I'm using the character '👁' (\uD83D\uDC41). After debugging for a while I figured that this character results in the negative glyph code The negative value is caused by the bit shift in https://github.com/javafxports/openjdk-jfx/blob/develop/modules/javafx.graphics/src/main/java/com/sun/javafx/font/CompositeGlyphMapper.java#L90. See the screenshot below for the values before this method was called during my debugging. Unfortunately I don't really know how to solve this problem. Skipping the call to |
127 fonts should be enough for anyone :-) |
lion7 wrote:
I already suggested a solution (see my first comment). It is still not perfect - it will just push the limit to 255. |
@aditsu you are correct, I just noticed you did exactly the same digging 🤦♂️ |
@aditsu Solved my issue on Arch Linux, I was about to run HMCL under KDE and some guys seems to have the same issue (see https://github.com/huanghongxun/HMCL/issues/536) |
Have the same issue |
This GitHub issue tracker is not actively tracked or managed. Please file a bug at bugreport.java.com. However, without a reproducible test case, we are not likely to be able to make progress on this issue. If you are interested in contributing a fix for this issue, please see CONTRIBUTING.md in the official openjdk/jfx GutHub repo. |
@kevinrushforth There's already a reproducible test case earlier in the thread. (Worked for me on Debian 10 Linux, OpenJDK 11.) But, I hear you that this issue tracker is not monitored. Interestingly, it's not just freezes; I also get graphics corruption. Here's what happens when I paste the "💥" emoji into a text field—a copy of the whole scene is flipped vertically and then inserted into a scrollpane: |
Here's a repro case with complete build config and everything, as a repository, if anyone gets around to filing a bug before me: https://gitlab.com/timmc/sscce-javafx-emoji-crash |
Filed a bug, with internal review ID 9062849. |
More info on workaround and diagnosis, following the Noto fonts lead. I found I have the following font packages installed in Debian with
Uninstalling just Is there further debugging I can do? For example, is there a way to prevent certain system fonts from being loaded by JavaFX, so that I can do a binary search and find if there are specific fonts that are causing the issue? |
The issue is not really caused by specific fonts, it is caused by the number of fonts linked to the font you are using and missing the required glyph. The reproducibility of the test case is contingent on the number and configuration of the fonts installed in the system. |
Ouch, got it. Is there a shippable workaround, like shipping with a set of fonts and somehow restricting the UI to only consider those fonts? |
That should be possible, by using loadFont and explicitly referencing those fonts in the application. I'm not sure if there's a mechanism for defining fallback fonts, or for configuring the fonts used by an application without modifying its code. |
I tried setting the font for a TextField by name (which worked) and then pasted in an emoji, and the app crashed. I think it's still looking at fallback fonts from the system. |
Please stop looking or updating at bugs on github. OpenJFX doesn't use them. |
@prrace I'm aware of it, but the fact is that I can talk about debugging it and finding workaround with people here, and I don't see a way to get a login there. 🤷♂️ |
Same here this java bug tracker thing is awful. I can not comment there or whatsoever... |
Hello, I've been having prism issues pop up on Linux lately (as in, doesn't happen on Windows implementation at all)
System info
-Djdk.gtk.version=2
without any difference)Java/Maven/OpenJFX info
Failing component
It seems to be when using a
ListView
that overrides thegraphic
property of its cells to render a full node in each cell (basically having a list of nodes rather than of only primitive-wrapping cells/simple controls).When the computation of some of the elements is executed on resizing of window, or on adding more elements to the list (which incurs recomputation of stuff like scroll bar size), some assertion is failing.
What happens
The UI freezes while
ArrayIndexOutofBoundsException
s are being spilled in hundredsBefore corruption:
After:
The exceptions I get (all the same):
Overall I do not have an idea of why it happens and it doesn't seem to be easily reproducible so as for a locally reproducible way you can use branch
develop
of https://github.com/Tristan971/Lyrebird/ (lyrebird
submodule is the runnable app) and just scroll through a twitter timeline (in my experience you need to reach the end of the timeline so that the app actually has to fetch older tweets and plug them in the item list of theListView
.Will try to inquire it on my own as well, but if someone had an idea it would be pretty helpful.
Thank you
The text was updated successfully, but these errors were encountered: