I don’t know if anyone has the same issue or has noticed it, but when I install Material-UI v5 on my Meteor app and copy the example/sample of the Dialog or Menu, on the initial click I get a delay before it actually opens, it sort of hangs.
Clone the repo and run it.
Click on one of the two buttons and look at the delay before it opens.
Without doing a refresh, click again and you should see its almost instant afterwards.
Now hit refresh and click on it again and you should see it reoccur.
I created this repo because in my actual project, it take around 5 secs for the Dialog or Menu to open up.
I have no idea why that is, I have tried to look at it but couldn’t figure it out. At first I thought it might be my project code, but with my blank repo it actually has the same issue.
I am using latest version of Meteor, and it seems to occur in earlier versions too.
Here is a screen video demo of my bigger project showing the delay.
I downloaded the github repo, ran it, and duplicated the anomaly. I do not yet see why it’s taking so long for the FormDialog to load the first time it is called.
I see you are using the exact same dialog code that’s on the MUI demo page. And the dialog loads very quickly there.
I have not seen slow load times for MUI components in my Meteor app.
This is a React/MUI issue, so Meteor should not be contributing to the anomaly.
I will try to reproduce it without Meteor, but if I can’t doesn’t that mean that there could be something in MUI’s latest version packages that could be conflicting maybe? It is very odd though.
At first I thought it could be some of the packages I was using in my project, but I kept it light in the repo to test it.
And I just installed MUI with my two test dialog and menu and it seems fast here.
And to remove doubts, I also tried creating a new simple to do app react with meteor using the tutorial and just copied my dialog and menu and the same issue occurs when on meteor.
I updated the simple to do repo, I added a test with the Modal component, and that one seems to open quickly on the initial load, so it seems to only affect the Dialog and Menu components, no idea if any others are affected since I haven’t gotten to test them yet.
Are anyone running MUI v5 with Meteor without experiencing drastically slow first renders?
I have an older project with MUI v4 that’s working just fine, but in a new project with v5 everything is slow on the first render, even clicking a button will hang the application for secounds before continuing. After the first initial hang everything starts behaving as normal. The same issue occures everytime I open a modal without using the keepMounted prop wchich I guess is because a new component gets rendered for the first time.
It does not look like other frameworks are experiencing the same issue so I am wondering if someone with a greater knowlage of the Meteor internals might be able to find out why this is happening specifically in Meteor projects.
I am experiencing the same on my end, I opened an issue on MUI’s github, waiting on their findings. Another dev also posted a repo that demonstrated the issue is with all components which I did not notice. I haven’t opened an issue in Meteor’s github yet since its MUI’s package. Hopefully we’ll get answers soon, unless someone here or reading can figure out what the issue is or where it comes from to help speed up getting this fixed.
@kheang@zayco How are you guys importing the component?
There’s a difference when you import an MUI component like this:
import { TextField } from '@mui/material';
Instead of:
import TextField from '@mui/material/TextField';
When you import like in the first example, the whole MUI library will be downloaded to the client instead of just the component on the first load. After that the code stays kind of cached, that’s why the second load is faster.
@denyhs comment would make more sense before Meteor 2.4.
If you are using Meteor 2.4 the difference from importing everything shouldn’t be that bad (of course you could avoid it), specially in development.
It seems that you are not sure if this is a Meteor issue or a Material UI issue, right?
Could you use the Performance tab in Chrome Dev Tools to see which modules are being executed when the app is slow, so you would know better if maybe this is Meteor parsing the files or the library itself.
I haven’t tested the latest Meteor update yet, but as previously mentioned, we are using the demo with the correct imports directly for MUI’s documentation so that part should be ok.
I am not an expert with performance/profiling, I will try to test it in a bit.
If anyone else is more familiar and can do the test, I welcome it.