-
Notifications
You must be signed in to change notification settings - Fork 1k
Fixes #38708 - Slow and unresponsive settings page #10673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
d567ae0
to
7f0a8fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Lukshio! some comments/questions below
setIsLoaded(true); | ||
}; | ||
|
||
window.addEventListener('load', handleLoad); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who emits the load
event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is build in generic event
https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
import { selectSettingsByCategory } from '../SettingRecords/SettingRecordsSelectors'; | ||
|
||
import SettingsTable from './SettingsTable'; | ||
|
||
const WrappedSettingsTable = props => { | ||
const [isLoaded, setIsLoaded] = useState(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the load
event has already been emitted upon reaching this code? Then it would never display the page.
I think we had a similar problem here -->
foreman/webpack/assets/javascripts/react_app/components/HostsIndex/index.js
Lines 121 to 135 in ee1afb9
useEffect(() => { | |
const handleLoadJS = () => { | |
setAllColumns(getColumnData({ tableName: 'hosts' })); | |
setAllJsLoaded(true); | |
}; | |
if (window.allJsLoaded) { | |
handleLoadJS(); | |
} else { | |
document.addEventListener('loadJS', handleLoadJS); | |
return () => { | |
document.removeEventListener('loadJS', handleLoadJS); | |
}; | |
} | |
}, [setAllColumns]); | |
const { |
and we solved it by relying on a boolean window.allJsLoaded
in addition to the event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side thought: you may be able to use the existing loadJS
event rather than creating a new load
event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review!
What is happening here is that JS is already loaded, but it starts firing its events, which "block" the page and its responses for clicking etc. even though it is "loaded" but window itself is still loading. So that is why I used 'load' event.
Nice catch with already emitted event - I replaced this code with simplified document.readyState === 'complete'. So it is not necessary to add additional eventListener and state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems better than creating our own events. @parthaa maybe we should look into doing that for HostsIndexPage too.
7f0a8fd
to
81d23ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @Lukshio, even though it's highly personal opinion, I think it's got even worse :D One inline thought to maybe try out:
@@ -1,7 +1,7 @@ | |||
import React from 'react'; | |||
import { useSelector } from 'react-redux'; | |||
import PropTypes from 'prop-types'; | |||
|
|||
import { Skeleton } from '@patternfly/react-core'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use our SkeletonLoader
instead?
@ofedoren The issue itself is somewhere deep in webpack and it is happening across multiple sites, this is just hotfix to prevent 'unresponsive table' by adding loader to prevent use clicking into table before full load. I think this is fastest way how to prevent this happening. |
I just tested this and it does indeed show a skeleton, but it doesn't help the loading time at all. Do we know where the bottlenecks are? |
Also one kind of odd thing is that I could click around the different tabs while the loading skeleton was showing. |
As I mentioned above, the issue itself is somewhere deep in webpack and it is occurring on multiple sites.
Yeah, that's true, it is rendered by two different components. In my opinion, one of the solutions is to rewrite the page to fully use react - we get rid of redux state, two components, etc... But it will take more time, so for this moment, I would use this hotfix |
Do you mean sites other than Foreman? Or multiple pages in Foreman? |
No description provided.