Skip to content

Conversation

Lukshio
Copy link
Contributor

@Lukshio Lukshio commented Sep 2, 2025

No description provided.

@github-actions github-actions bot added the UI label Sep 2, 2025
@Lukshio Lukshio force-pushed the 38708-slow_settings_page branch from d567ae0 to 7f0a8fd Compare September 2, 2025 15:25
@Lukshio Lukshio changed the title Fixes #38709 - Slow and unresponsive settings page Fixes #38708 - Slow and unresponsive settings page Sep 2, 2025
Copy link
Contributor

@jeremylenz jeremylenz left a 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);
Copy link
Contributor

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?

Copy link
Contributor Author

@Lukshio Lukshio Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import { selectSettingsByCategory } from '../SettingRecords/SettingRecordsSelectors';

import SettingsTable from './SettingsTable';

const WrappedSettingsTable = props => {
const [isLoaded, setIsLoaded] = useState(false);
Copy link
Contributor

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 -->

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.

Copy link
Contributor

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.

Copy link
Contributor Author

@Lukshio Lukshio Sep 3, 2025

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.

Copy link
Contributor

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.

@Lukshio Lukshio force-pushed the 38708-slow_settings_page branch from 7f0a8fd to 81d23ae Compare September 3, 2025 14:03
Copy link
Member

@ofedoren ofedoren left a 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';
Copy link
Member

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?

@Lukshio
Copy link
Contributor Author

Lukshio commented Sep 3, 2025

Thanks, @Lukshio, even though it's highly personal opinion, I think it's got even worse :D One inline thought to maybe try out:

@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.

@jeremylenz
Copy link
Contributor

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?

@jeremylenz
Copy link
Contributor

Also one kind of odd thing is that I could click around the different tabs while the loading skeleton was showing.

@Lukshio
Copy link
Contributor Author

Lukshio commented Sep 3, 2025

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?

As I mentioned above, the issue itself is somewhere deep in webpack and it is occurring on multiple sites.

Also one kind of odd thing is that I could click around the different tabs while the loading skeleton was showing.

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

@jeremylenz
Copy link
Contributor

it is occurring on multiple sites.

Do you mean sites other than Foreman? Or multiple pages in Foreman?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants