-
-
Notifications
You must be signed in to change notification settings - Fork 341
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
[StimulusBundle] Improve StimulusAttributes
rendering performances by switching to html
escaping strategy
#2180
[StimulusBundle] Improve StimulusAttributes
rendering performances by switching to html
escaping strategy
#2180
Conversation
cd9c74a
to
1525a9a
Compare
Do we still need to call the Runtime then ? Would this not be sufficient ?
|
af1c114
to
6c92d01
Compare
If we assume UTF-8 is used everywhere, yes, but |
This bundle is the most used / downloaded. So we cannot release a version that will break tests (and maybe code) during a minor... so we need to find a way out here... what about thinking a new object ? less "stimulus" and more "attributes" ? |
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.
Hey! I am agree with @smnandre here! It's a BC break for me. Maybe we can have a config that allow to switch from html_attr to html ?
Sadly, it's difficult, as this class is directly used by other components / bundle.. and it's neither final or internal :| |
It's a BC for tests/assertions yes, but I don't really see how and where it can impact end users. However, we can't stay ad vitam aeternam with Since |
New bundle config? Deprecate not setting it to the new, desired value? |
We cannot here, this class may be instanciated directly in many projects, as it is not a service.
This is a good idea. Probably we can add an argument either in the render / toString methods, or maybe more in the constructor.. .. and deprecate no passing it (stating in 3.x it will use the new mode) ? |
Regarding performances, i'm very very happy you found this bottleneck and have a clean method to improve things. But as always, we cannot "force it" down, and it's been written everywhere Symfony UX would follow Symfony BC promise. To be clear, i'm not saying we cannot use these optimisations in the ux components
I'm concerned about two things here:
|
Constructor then, yes. |
I'm reverting to |
0ac2cf2
to
736543a
Compare
I've updated the PR and introduced a new config This configuration is injected to the I've rollbacked tests added in my first commit as it was considered as breaking changes. Instead, I've configured With all those changes, I took a new Blackfire profile on my page with a |
736543a
to
4af2a0e
Compare
@Kocal impressive performance improvement 🤯 thanks a lot 🙇 I still think this is not a true BC break and we shouldn't complicate things with the new config option. |
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 agree with Javier, no need for the option.
We might reconsider if we get enough reports but without, I wouldn't anticipate this aspect.
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'm still not convinced this should be considered a breaking change. The generated HTML string will be different, but this will not change anything for the output of parsing it.
src/StimulusBundle/src/DependencyInjection/StimulusExtension.php
Outdated
Show resolved
Hide resolved
I agree with all of you, I don't consider it a breaking change either. Let's revert the 2 last commit then, just in case. We will squash the PR at merging. |
77a08ac
to
34deb47
Compare
The PR is now back at its original state, there is no |
b35c2b8
to
e3b42f1
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
…by switching to `html` escaping strategy
e3b42f1
to
647532a
Compare
Thank you Hugo. |
…ests (Kocal) This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Map] Explicitly require StimulusBundle in Bridges, fix tests | Q | A | ------------- | --- | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Follows #2180. When installing a Map Bridge dependencies, the StimulusBundle was not the one from the PR's branch but from `2.x`, and so tests didn't fail in #2180 **but** started to fail after merging: <img width="661" alt="image" src="https://github.com/user-attachments/assets/de206abe-9490-4103-b1cb-a8fa48753cde"> Commits ------- 7164b57 [Map] Fix Bridges tests 01e902d [Map] Explicitly require StimulusBundle in Bridges
A better alternative to #2178, by changing the escaping strategy for HTML attributes value from
html_attr
tohtml
, as indicated by @stof in twigphp/Twig#4322 (comment).On my use case (a

Map
with 1000Marker
andInfoWindow
), I have a performance gain of ~68%:This PR should also improve performances of our packages using the
StimulusAttributes
DTO, like Chart.js, LiveComponent, ...Important
The initial PR changed a bit, the default rendering strategy does not change, but instead we introduce a new configuration to use the new (and optimized) rendering strategy, see #2180 (comment).