#FXML JavaFX Slowdowns
1 messages · Page 1 of 1 (latest)
<@&987246487241105418> please have a look, thanks.
show your code
using fxml isnt a bottleneck at all. its how you use it
theres a good chance your slowdowns could be caused by how your interface with FXML, or could be completely irrelevant to FXML
gotta see the code. more specifically, the code causing the problems
Also wdym by slowdowns? You used a profiler to check?
Here I added my code here https://github.com/Skultrix/Wardrobe
No just by running it on my computer.
The "Home" page takes 2-3 seconds to load, but other pages load quickly
Basically. I have a UI that is a border pane with navigation on the left and logo and whatever. Then I load a "page" and set it into the borderpane's center container when the navigation is interacted with
This is handled here https://github.com/Skultrix/Wardrobe/blob/master/src/main/java/com/aabdalla/wardrobe/controllers/BaseUI.java
considering the Home controller doesn't do anything, and the FXML for Home seems pretty lightweight, makes me believe its not the FXML itself
Do you have any ideas of what might cause this?
well id recommend cleaning up your code first
BaseUI has an FXMLLoader field which doesnt seem to be used
Yep I forgot that
first step is simplifying the code as much as possible
next step would be pinpointing exactly where the time is being taken
are you sure its the loading of the homepage? maybe there are some other things going on causing a slowdown
so timing things would give you more insight into exactly what is taking so much time
Could it be that running it from the IDE would be slower than usual?
should be negligible
throw in some simple timing systems
long start = System.nanoTime();
loadPage(...)
long end = System.nanoTime();
long timeTaken = end - start;```
itll give you a rough idea of how much time is being consumed relative to other things
You should cache pages so you don't have to load them from the hard drive each time
but even then
it's not normal that it takes so much time
there must be something else causing problems
you should, but it also shouldnt be taking that long to reload the same thing
so theres something else going on
separate the call to load and setcenter, and calculate the time it takes for each one, just to be sure
Yeah im working on that
So the issue is with setCenter
Not load
The only differences between other pages and home is that Home is an HBox while the others are border panes
I would think that an HBox would be faster to put in
thats very interesting
ima try to run this in about 10 mins
try to verify that the dimension are exact so it doesn't need to resise anything
that seems strange that setCenter would cause such a impact on load times
I just tried, I removed prefwidth and prefheight but no change
the thing is, your controller does nothing, and the FXML is very simple
Maybe I need to remove whats already there?
Because its fast on the first setCenter
Is there a function for that
i think it may be a different issue
When I paste the fxml contents of another page into the home page's fxml, it works fine
So its an issue with the contents of the home page's fxml but im not sure how to debug that
let me take another look at the fxml. not home yet, cant test
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.Text?>
<HBox fillHeight="false" prefHeight="100.0" prefWidth="200.0" spacing="30.0" stylesheets="@../../../css/pages/home/home.css" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1">
<children>
<AnchorPane prefHeight="200.0" prefWidth="200.0" styleClass="info_container">
<children>
<Text layoutX="84.0" layoutY="180.0" strokeType="OUTSIDE" strokeWidth="0.0" styleClass="info_title" text="# OUTFITS" />
<Text layoutX="26.0" layoutY="111.0" strokeType="OUTSIDE" strokeWidth="0.0" styleClass="info_count" text="00" />
</children>
</AnchorPane>
<AnchorPane prefHeight="200.0" prefWidth="200.0" styleClass="info_container">
<children>
<Text layoutX="99.0" layoutY="180.0" strokeType="OUTSIDE" strokeWidth="0.0" styleClass="info_title" text="# PIECES" />
<Text layoutX="26.0" layoutY="111.0" strokeType="OUTSIDE" strokeWidth="0.0" styleClass="info_count" text="00" />
</children>
</AnchorPane>
</children>
</HBox>
Detected code, here are some useful tools:
@keen lynx you could try to run a profiler to see what is actually taking time
what does the stylesheet look like?
nothing in the FXML is suggesting high load times. and its strange that it loads quick the first time, but not the second
i dont think its the stylesheet causing the issues (although cant rule it out), i still think theres something else
but thats the only thing in that FXML that is suggesting time pitfalls
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Reddit+Mono:[email protected]&display=swap');
.info_container {
-fx-effect: dropshadow(gaussian, rgba(157, 141, 195, 0.16), 30, 0, 10,10);
-fx-background-color: linear-gradient(to bottom, #ffffff, #f1f7f8);
-fx-background-radius: 7; /* Set the radius for the background */
-fx-border-radius: 7; /* Set the radius for the border */
-fx-border-color: #ffffff;
-fx-border-width: 5px;
}
.info_title {
-fx-font-family: "Poppins", monospace;
-fx-font-size: 20px;
-fx-font-weight: 900;
-fx-fill: #636973;
}
.info_count {
-fx-font-family: "Reddit Mono", monospace;
-fx-font-size: 90px;
-fx-font-weight: 500;
-fx-fill: #40454c;
-fx-effect: dropshadow(gaussian, rgba(114, 255, 180, 0.37), 0, 0.5, 5, 5);
}
Detected code, here are some useful tools:
@import
url('https : //fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Reddit+Mono:[email protected]&display=swap');
.info_container {
- fx - effect : dropshadow(gaussian, rgba(157, 141, 195, 0.16), 30, 0, 10, 10);
- fx - background - color : linear - gradient(to bottom, #ffffff, #f1f7f8);
- fx - background - radius : 7;
/* Set the radius for the background */
-fx-border-radius: 7; /* Set the radius for the border */
- fx - border - color : #ffffff;
- fx - border - width : 5px;
}
.info_title {
- fx - font - family : "Poppins", monospace;
- fx - font - size : 20px;
- fx - font - weight : 900;
- fx - fill : #636973;
}
.info_count {
- fx - font - family : "Reddit Mono", monospace;
- fx - font - size : 90px;
- fx - font - weight : 500;
- fx - fill : #40454c;
- fx - effect : dropshadow(gaussian, rgba(114, 255, 180, 0.37), 0, 0.5, 5, 5);
}
this is the stylesheet
alright, so you are using a url to access a font
im not sure why that would take more time the 2nd occurrence
yeah, so probably not the issue
Ok
if the problem is still here, it's not that
just seems strange that it would take longer the 2nd time
but like I said, you should use a profiler, a profiler should be able to pin point what is exactly taking this much time
profiler isnt easy to comprehend though, they'd have to be able to analyze the results properly
otherwise they'd be confused on why byte[] is taking so much memory
A profiler would step inside and see exactly what is taking time
when in reality, its because strings are backed by it
Wait
yes but we are here to assist him
youre RIGHT!
?
The font was slowing it
ayy
ah?
then?
I removed the font from another file by accident and tested
Yes that was a mistake
I removed it from base.css instead of home.css
but why only on second time?
lmfao
Maybe some sort of limit from the google api? IDK
ima still try to troubleshoot
can you try to make a Minimal reproducible example so we can find the problem?
still
its still an interesting problem
Wait, can you try to load it from code and then test if it takes time and when?
How can I do that?
this should contain an MRE
@violet sage
Whats an MRE
Minimal Reproducable Example
Im a cs student with no practical experience guys
the minimal code to reproduce the example
and even though this isnt minimal, its still not much
Will do
so id consider it good enough for an MRE
no worries, we're here to help bring you up to par