-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix App::get_added_plugins not working inside finish and cleanup #20506
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
Conversation
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.
Oof! Good find.
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.
Can't you just iterate over the plugins without mem taking them? Why remove and reinsert them? Does Plugin::finish
require the current plugin to not be in the plugin registry?
Asking because this seems to me like it's lowering the code quality to preserve this invariant and I don't understand why.
|
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.
makes sense, thx :)
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.
I'd like to see a regression test added, in this PR, to ensure we don't reintroduce this bug.
Does this work correctly when adding plugins in finish/cleanup? I wonder if it'll swap the correct thing if we're adding plugins |
Thats a really good point |
I think it didnt work before. Seems the plugin registry would just get overwritten lol, so this is actually gonna fix two bugs. |
What does it even mean for a plugin to get added during finish or cleanup though? should finish/cleanup run on those plugins? |
Okay i fixed all the things, assigned to @alice-i-cecile because hokey pokey :) |
You're totally correct that it's poorly defined. However it's something we've used in practice. I stumbled upon such a usage during my RenderStartup refactors. I can dig up that case if need be. In that context, it didn't use finish or cleanup so it was fine, but obviously not an ideal situation. |
Regression test has been added.
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.
Regression test LGTM, though adding new Plugins mid-finish
is mighty cursed. Left a comment regarding the HokeyPokey implementation that needs to be addressed before merging though.
It doesn't allocate, its ZST |
…yengine#20506) # Objective This assertion fails when called inside finish or cleanup: ```rs assert_eq!( app.is_plugin_added::<ImagePlugin>(), app.get_added_plugins::<ImagePlugin>().len() > 0 ); ``` ## Solution - Do the hokey pokey one plugin at a time - swap_remove to stay O(1), then push and swap back to preserve plugin order ## Testing - Someone should write unit tests for this and probably document that it hokey pokeys, although i dont think anyone will `get_added_plugins<Self>` because you have a `self` param in finish and cleanup anyways.
Objective
This assertion fails when called inside finish or cleanup:
Solution
Testing
get_added_plugins<Self>
because you have aself
param in finish and cleanup anyways.