Skip to content
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

avoid the infinite loop issue of calling AddModuleMessage method. #3885

Merged
merged 3 commits into from
Feb 24, 2024

Conversation

zyhfish
Copy link
Contributor

@zyhfish zyhfish commented Feb 24, 2024

No description provided.

@sbwalker
Copy link
Member

@zyhfish this PR is actually not going to work because ModuleMessage is used in a variety of scenarios - not always within a module (ie. it is used in the SiteRouter, Themes, etc...). So the addition of the extra parameters and the fact that the caller needs to pass those parameters means that this solution is a breaking change.

@zyhfish
Copy link
Contributor Author

zyhfish commented Feb 24, 2024

Thanks @sbwalker , I updated the Visible parameter's default value to true so that it will not break any existing references.

@sbwalker
Copy link
Member

@zyhfish much better :) Basically, it appears you moved the StateHasChanged() logic from ModuleBase to RenderModeBoundary - which prevent the infinite looping issue and still allows a message to be displayed in OnParamatersSet within module components. I will merge this now and you can submit a PR to re-introduce the AddModuleMessage() calls I removed earlier this week.

@sbwalker sbwalker merged commit 98de661 into oqtane:dev Feb 24, 2024
1 check passed
@zyhfish zyhfish deleted the task/fix-infinite-loop-of-module-message branch February 24, 2024 15:16
@sbwalker
Copy link
Member

sbwalker commented Feb 26, 2024

@zyhfish this PR seems to have some side effects. When I manage module settings and choose the Permission tab, an extra close icon is displayed - which I believe is coming from the ModuleMessage component - however if the message is blank then the close button should not be displayed - in fact the component should not render anything in this scenario.

image

Basically this is related to what I was referring to in my earlier comment - the ModuleMessage component can be used as a standalone component - and in those cases if the message parameter is blank, the component should not render any markup.

sbwalker added a commit to sbwalker/oqtane.framework that referenced this pull request Feb 26, 2024
sbwalker added a commit that referenced this pull request Feb 26, 2024
fix #3885 - do not display modal if message is blank
@sbwalker
Copy link
Member

@zyhfish please verify if #3906 resolves the issue I outlined above

@zyhfish
Copy link
Contributor Author

zyhfish commented Feb 27, 2024

Hi @sbwalker , yeah the fix works great, thx so much!

@sbwalker
Copy link
Member

@zyhfish I am not sure if the new Visible parameter is even necessary? It seems that the Message parameter can be used to determine if a ModuleMessage component needs to render markup. I logged another issue #3907 which I am not sure is related to the recent changes or not.

@zyhfish
Copy link
Contributor Author

zyhfish commented Feb 27, 2024

Hi @sbwalker , the Visible parameter is needed in the RenderModeBoundary control, as there have 2 references, which is at top, another is at bottom, only one are visible and decided by the position value.

@sbwalker
Copy link
Member

@zyhfish I still do not think its necessary. RenderModeBoundary has a reference to 2 different instances of the ModuleMessage component. It is possible to call RefreshMessage on either of them independently (which basically calls StateHasChanged to update the UI). So there is no need for a Visible property - the Message property value can be used to determine visibility.

@zyhfish
Copy link
Contributor Author

zyhfish commented Feb 27, 2024

Hi @sbwalker , let me try to check whether it can works. I also tried to verify #3907 by reverting the changes of this, the error still occur, it maybe related to the dynamic render component in RenderModeBoundary that some component was not render in the refresh method, but need more investigation to identity the root cause.

@zyhfish
Copy link
Contributor Author

zyhfish commented Feb 27, 2024

HI @sbwalker , I submitted PR #3910 to remove the Visible parameter, please help to review, thx.

@sbwalker
Copy link
Member

sbwalker commented May 17, 2024

@zyhfish I never noticed this previously... but this PR now requires 2 ModuleMessage components to be created for each RenderModeBoundary component instance - whereas the previous implementation only created ModuleMessage components dynamically when they were required. From a performance and scalability perspective the new approach is not optimal, as the goal should always be to minimize the number of components required at run-time (since every component consumes state and needs to process life cycle events). So although this PR resolved the infinite loop issue when AddModuleMessage was called in OnParametersSet, it introduces other problems in terms of overhead. I think we are going to need to revisit this item to try and find a better solution.

@zyhfish
Copy link
Contributor Author

zyhfish commented May 18, 2024

This will be a challenge that if need to render the component dynamically then we need to trigger render method of RenderModeBoundary component instance, which is the root cause of the infinitely loop issue. let me try to check whether can find a magic solution to cover this.

@zyhfish
Copy link
Contributor Author

zyhfish commented May 18, 2024

Hi @sbwalker , I submitted PR #4268 to fix the issue by only re-render the components when the message really changed, please check whether it's better now.

sbwalker added a commit that referenced this pull request May 19, 2024
Fix #3885: only re-render the component when message changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants